2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
#ifndef mozilla_dom_SVGMPathElement_h
|
|
|
|
#define mozilla_dom_SVGMPathElement_h
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2017-09-08 12:02:05 +03:00
|
|
|
#include "mozilla/dom/IDTracker.h"
|
2010-04-29 03:00:54 +04:00
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsSVGString.h"
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
nsresult NS_NewSVGMPathElement(nsIContent **aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
typedef nsSVGElement SVGMPathElementBase;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-01-13 02:22:31 +04:00
|
|
|
class SVGPathElement;
|
2013-01-05 05:50:22 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class SVGMPathElement final : public SVGMPathElementBase,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsStubMutationObserver
|
2010-04-29 03:00:54 +04:00
|
|
|
{
|
|
|
|
protected:
|
2013-01-05 05:50:22 +04:00
|
|
|
friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-01-05 05:50:22 +04:00
|
|
|
~SVGMPathElement();
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// interfaces:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGMPathElement,
|
|
|
|
SVGMPathElementBase)
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
|
|
|
|
// nsIContent interface
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
2018-07-31 21:18:38 +03:00
|
|
|
nsIContent* aBindingParent) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
// Element specializations
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2010-04-29 03:00:54 +04:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2018-01-04 05:03:29 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify) override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
// Public helper method: If our xlink:href attribute links to a <path>
|
|
|
|
// element, this method returns a pointer to that element. Otherwise,
|
2012-07-30 18:20:58 +04:00
|
|
|
// this returns nullptr.
|
2013-01-13 02:22:31 +04:00
|
|
|
SVGPathElement* GetReferencedPath();
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
// WebIDL
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString> Href();
|
2013-01-05 05:50:22 +04:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
protected:
|
2017-09-12 16:37:10 +03:00
|
|
|
/**
|
|
|
|
* Helper that provides a reference to the 'path' element with the ID that is
|
|
|
|
* referenced by the 'mpath' element's 'href' attribute, and that will
|
|
|
|
* invalidate the parent of the 'mpath' and update mutation observers to the
|
|
|
|
* new path element if the element that that ID identifies changes to a
|
|
|
|
* different element (or none).
|
|
|
|
*/
|
|
|
|
class PathElementTracker final : public IDTracker {
|
2010-04-29 03:00:54 +04:00
|
|
|
public:
|
2017-09-12 16:37:10 +03:00
|
|
|
explicit PathElementTracker(SVGMPathElement* aMpathElement)
|
|
|
|
: mMpathElement(aMpathElement)
|
|
|
|
{}
|
2010-04-29 03:00:54 +04:00
|
|
|
protected:
|
|
|
|
// We need to be notified when target changes, in order to request a sample
|
|
|
|
// (which will clear animation effects that used the old target-path
|
|
|
|
// and recompute the animation effects using the new target-path).
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) override {
|
2017-09-08 12:02:05 +03:00
|
|
|
IDTracker::ElementChanged(aFrom, aTo);
|
2010-04-29 03:00:54 +04:00
|
|
|
if (aFrom) {
|
|
|
|
aFrom->RemoveMutationObserver(mMpathElement);
|
|
|
|
}
|
|
|
|
if (aTo) {
|
|
|
|
aTo->AddMutationObserver(mMpathElement);
|
|
|
|
}
|
|
|
|
mMpathElement->NotifyParentOfMpathChange(mMpathElement->GetParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need to override IsPersistent to get persistent tracking (beyond the
|
|
|
|
// first time the target changes)
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsPersistent() override { return true; }
|
2010-04-29 03:00:54 +04:00
|
|
|
private:
|
2013-01-05 05:50:22 +04:00
|
|
|
SVGMPathElement* const mMpathElement;
|
2010-04-29 03:00:54 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual StringAttributesInfo GetStringInfo() override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
|
|
|
void UpdateHrefTarget(nsIContent* aParent, const nsAString& aHrefStr);
|
2011-09-29 10:19:26 +04:00
|
|
|
void UnlinkHrefTarget(bool aNotifyParent);
|
2010-04-29 03:00:54 +04:00
|
|
|
void NotifyParentOfMpathChange(nsIContent* aParent);
|
|
|
|
|
2016-07-06 11:40:30 +03:00
|
|
|
enum { HREF, XLINK_HREF };
|
|
|
|
nsSVGString mStringAttributes[2];
|
|
|
|
static StringInfo sStringInfo[2];
|
2017-09-12 16:37:10 +03:00
|
|
|
PathElementTracker mPathTracker;
|
2010-04-29 03:00:54 +04:00
|
|
|
};
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGMPathElement_h
|