2007-02-18 17:34:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-01-16 20:50:58 +00:00
|
|
|
#ifndef mozilla_dom_SVGUseElement_h
|
|
|
|
#define mozilla_dom_SVGUseElement_h
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2012-01-26 09:57:21 +00:00
|
|
|
#include "mozilla/dom/FromParser.h"
|
|
|
|
#include "nsReferencedElement.h"
|
2007-03-10 13:49:43 +00:00
|
|
|
#include "nsStubMutationObserver.h"
|
2013-01-16 20:50:58 +00:00
|
|
|
#include "mozilla/dom/SVGGraphicsElement.h"
|
2007-02-18 17:34:09 +00:00
|
|
|
#include "nsSVGLength2.h"
|
2008-06-14 09:01:02 +00:00
|
|
|
#include "nsSVGString.h"
|
2007-02-18 17:34:09 +00:00
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
class nsIContent;
|
2013-01-16 20:50:59 +00:00
|
|
|
class nsSVGUseFrame;
|
2007-02-18 17:34:09 +00:00
|
|
|
|
|
|
|
nsresult
|
2010-07-23 09:49:57 +00:00
|
|
|
NS_NewSVGSVGElement(nsIContent **aResult,
|
2014-06-20 02:01:40 +00:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2010-10-25 12:17:38 +00:00
|
|
|
mozilla::dom::FromParser aFromParser);
|
2013-01-16 20:50:58 +00:00
|
|
|
nsresult NS_NewSVGUseElement(nsIContent **aResult,
|
2014-06-20 02:01:40 +00:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-01-16 20:50:58 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-01-16 20:50:58 +00:00
|
|
|
typedef SVGGraphicsElement SVGUseElementBase;
|
|
|
|
|
|
|
|
class SVGUseElement MOZ_FINAL : public SVGUseElementBase,
|
|
|
|
public nsStubMutationObserver
|
2007-02-18 17:34:09 +00:00
|
|
|
{
|
2013-01-16 20:50:59 +00:00
|
|
|
friend class ::nsSVGUseFrame;
|
2007-02-18 17:34:09 +00:00
|
|
|
protected:
|
2013-01-16 20:50:58 +00:00
|
|
|
friend nsresult (::NS_NewSVGUseElement(nsIContent **aResult,
|
2014-06-20 02:01:40 +00:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2014-09-01 01:08:04 +00:00
|
|
|
explicit SVGUseElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-01-16 20:50:58 +00:00
|
|
|
virtual ~SVGUseElement();
|
2014-04-08 22:27:17 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *cx) MOZ_OVERRIDE;
|
2013-01-16 20:50:58 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
public:
|
|
|
|
// interfaces:
|
2013-01-16 20:50:58 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-01-16 20:50:58 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGUseElement, SVGUseElementBase)
|
2007-03-10 13:49:43 +00:00
|
|
|
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
2007-02-18 17:34:09 +00:00
|
|
|
|
|
|
|
// for nsSVGUseFrame's nsIAnonymousContentCreator implementation.
|
|
|
|
nsIContent* CreateAnonymousContent();
|
2010-02-11 17:34:01 +00:00
|
|
|
nsIContent* GetAnonymousContent() const { return mClone; }
|
2007-02-18 17:34:09 +00:00
|
|
|
void DestroyAnonymousContent();
|
|
|
|
|
|
|
|
// nsSVGElement specializations:
|
2013-12-26 20:13:57 +00:00
|
|
|
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
2013-05-08 05:11:24 +00:00
|
|
|
TransformTypes aWhich = eAllTransforms) const MOZ_OVERRIDE;
|
|
|
|
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
|
2007-02-18 17:34:09 +00:00
|
|
|
|
|
|
|
// nsIContent interface
|
2014-06-20 02:01:40 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
2013-05-08 05:11:24 +00:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-01-16 20:50:59 +00:00
|
|
|
// WebIDL
|
2013-06-14 22:37:27 +00:00
|
|
|
already_AddRefed<SVGAnimatedString> Href();
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength> X();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Y();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Width();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Height();
|
2013-01-16 20:50:59 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
protected:
|
2008-06-25 22:41:04 +00:00
|
|
|
class SourceReference : public nsReferencedElement {
|
|
|
|
public:
|
2014-09-01 01:08:04 +00:00
|
|
|
explicit SourceReference(SVGUseElement* aContainer) : mContainer(aContainer) {}
|
2008-06-25 22:41:04 +00:00
|
|
|
protected:
|
2013-05-08 05:11:24 +00:00
|
|
|
virtual void ElementChanged(Element* aFrom, Element* aTo) MOZ_OVERRIDE {
|
2010-05-14 17:04:51 +00:00
|
|
|
nsReferencedElement::ElementChanged(aFrom, aTo);
|
2008-07-09 10:50:48 +00:00
|
|
|
if (aFrom) {
|
|
|
|
aFrom->RemoveMutationObserver(mContainer);
|
|
|
|
}
|
2008-06-25 22:41:04 +00:00
|
|
|
mContainer->TriggerReclone();
|
|
|
|
}
|
|
|
|
private:
|
2013-01-16 20:50:58 +00:00
|
|
|
SVGUseElement* mContainer;
|
2008-06-25 22:41:04 +00:00
|
|
|
};
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-05-08 05:11:24 +00:00
|
|
|
virtual LengthAttributesInfo GetLengthInfo() MOZ_OVERRIDE;
|
|
|
|
virtual StringAttributesInfo GetStringInfo() MOZ_OVERRIDE;
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2012-06-23 16:36:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if our width and height should be used, or false if they
|
|
|
|
* should be ignored. As per the spec, this depends on the type of the
|
|
|
|
* element that we're referencing.
|
|
|
|
*/
|
|
|
|
bool OurWidthAndHeightAreUsed() const;
|
2012-03-03 09:21:09 +00:00
|
|
|
void SyncWidthOrHeight(nsIAtom *aName);
|
2008-06-25 22:41:04 +00:00
|
|
|
void LookupHref();
|
2007-02-18 17:34:09 +00:00
|
|
|
void TriggerReclone();
|
2008-06-25 22:41:04 +00:00
|
|
|
void UnlinkSource();
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-01-16 20:50:59 +00:00
|
|
|
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
|
2007-02-18 17:34:09 +00:00
|
|
|
nsSVGLength2 mLengthAttributes[4];
|
|
|
|
static LengthInfo sLengthInfo[4];
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
enum { HREF };
|
|
|
|
nsSVGString mStringAttributes[1];
|
|
|
|
static StringInfo sStringInfo[1];
|
2007-02-18 17:34:09 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mOriginal; // if we've been cloned, our "real" copy
|
|
|
|
nsCOMPtr<nsIContent> mClone; // cloned tree
|
2008-06-25 22:41:04 +00:00
|
|
|
SourceReference mSource; // observed element
|
2007-02-18 17:34:09 +00:00
|
|
|
};
|
|
|
|
|
2013-01-16 20:50:58 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2007-02-19 19:40:38 +00:00
|
|
|
|
2013-01-16 20:50:58 +00:00
|
|
|
#endif // mozilla_dom_SVGUseElement_h
|