2010-04-28 16:00:54 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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-28 16:00:54 -07:00
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
#ifndef mozilla_dom_SVGMPathElement_h
|
|
|
|
#define mozilla_dom_SVGMPathElement_h
|
2010-04-28 16:00:54 -07:00
|
|
|
|
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsSVGString.h"
|
|
|
|
#include "nsReferencedElement.h"
|
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
nsresult NS_NewSVGMPathElement(nsIContent **aResult,
|
2014-06-19 19:01:40 -07:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2010-04-28 16:00:54 -07:00
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
typedef nsSVGElement SVGMPathElementBase;
|
2010-04-28 16:00:54 -07:00
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-01-12 14:22:31 -08:00
|
|
|
class SVGPathElement;
|
2013-01-04 17:50:22 -08:00
|
|
|
|
|
|
|
class SVGMPathElement MOZ_FINAL : public SVGMPathElementBase,
|
|
|
|
public nsStubMutationObserver
|
2010-04-28 16:00:54 -07:00
|
|
|
{
|
|
|
|
protected:
|
2013-01-04 17:50:22 -08:00
|
|
|
friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult,
|
2014-06-19 19:01:40 -07:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2014-08-31 18:08:04 -07:00
|
|
|
explicit SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-01-04 17:50:22 -08:00
|
|
|
~SVGMPathElement();
|
2010-04-28 16:00:54 -07:00
|
|
|
|
2014-04-08 15:27:17 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
|
2010-04-28 16:00:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
// interfaces:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGMPathElement,
|
|
|
|
SVGMPathElementBase)
|
2010-04-28 16:00:54 -07:00
|
|
|
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
|
|
|
|
// nsIContent interface
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
2010-04-28 16:00:54 -07:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-07 22:11:24 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE;
|
2010-04-28 16:00:54 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNamespaceID, nsIAtom* aAttribute,
|
2013-05-07 22:11:24 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
2012-11-14 14:10:08 -08:00
|
|
|
// Element specializations
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2010-04-28 16:00:54 -07:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2013-05-07 22:11:24 -07:00
|
|
|
nsAttrValue& aResult) MOZ_OVERRIDE;
|
2010-04-28 16:00:54 -07: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 07:20:58 -07:00
|
|
|
// this returns nullptr.
|
2013-01-12 14:22:31 -08:00
|
|
|
SVGPathElement* GetReferencedPath();
|
2010-04-28 16:00:54 -07:00
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
// WebIDL
|
2013-06-14 15:37:27 -07:00
|
|
|
already_AddRefed<SVGAnimatedString> Href();
|
2013-01-04 17:50:22 -08:00
|
|
|
|
2010-04-28 16:00:54 -07:00
|
|
|
protected:
|
|
|
|
class PathReference : public nsReferencedElement {
|
|
|
|
public:
|
2014-08-31 18:08:04 -07:00
|
|
|
explicit PathReference(SVGMPathElement* aMpathElement) :
|
2010-04-28 16:00:54 -07: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).
|
2013-05-07 22:11:24 -07:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) MOZ_OVERRIDE {
|
2010-05-14 10:04:51 -07:00
|
|
|
nsReferencedElement::ElementChanged(aFrom, aTo);
|
2010-04-28 16:00:54 -07: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)
|
2013-05-07 22:11:24 -07:00
|
|
|
virtual bool IsPersistent() MOZ_OVERRIDE { return true; }
|
2010-04-28 16:00:54 -07:00
|
|
|
private:
|
2013-01-04 17:50:22 -08:00
|
|
|
SVGMPathElement* const mMpathElement;
|
2010-04-28 16:00:54 -07:00
|
|
|
};
|
|
|
|
|
2013-05-07 22:11:24 -07:00
|
|
|
virtual StringAttributesInfo GetStringInfo() MOZ_OVERRIDE;
|
2010-04-28 16:00:54 -07:00
|
|
|
|
|
|
|
void UpdateHrefTarget(nsIContent* aParent, const nsAString& aHrefStr);
|
2011-09-28 23:19:26 -07:00
|
|
|
void UnlinkHrefTarget(bool aNotifyParent);
|
2010-04-28 16:00:54 -07:00
|
|
|
void NotifyParentOfMpathChange(nsIContent* aParent);
|
|
|
|
|
|
|
|
enum { HREF };
|
|
|
|
nsSVGString mStringAttributes[1];
|
|
|
|
static StringInfo sStringInfo[1];
|
|
|
|
PathReference mHrefTarget;
|
|
|
|
};
|
|
|
|
|
2013-01-04 17:50:22 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGMPathElement_h
|