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
|
|
|
|
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsSVGString.h"
|
|
|
|
#include "nsReferencedElement.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
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2010-04-29 03:00:54 +04:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) override;
|
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNamespaceID, nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
2012-11-15 02:10:08 +04:00
|
|
|
// Element specializations
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2010-04-29 03:00:54 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) 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:
|
|
|
|
class PathReference : public nsReferencedElement {
|
|
|
|
public:
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit PathReference(SVGMPathElement* aMpathElement) :
|
2010-04-29 03:00:54 +04:00
|
|
|
mMpathElement(aMpathElement) {}
|
|
|
|
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 {
|
2010-05-14 21:04:51 +04:00
|
|
|
nsReferencedElement::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];
|
2010-04-29 03:00:54 +04:00
|
|
|
PathReference mHrefTarget;
|
|
|
|
};
|
|
|
|
|
2013-01-05 05:50:22 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGMPathElement_h
|