LCOV - code coverage report
Current view: top level - dom/svg - nsSVGElement.h (source / functions) Hit Total Coverage
Test: output.info Lines: 62 81 76.5 %
Date: 2017-07-14 16:53:18 Functions: 19 57 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef __NS_SVGELEMENT_H__
       8             : #define __NS_SVGELEMENT_H__
       9             : 
      10             : /*
      11             :   nsSVGElement is the base class for all SVG content elements.
      12             :   It implements all the common DOM interfaces and handles attributes.
      13             : */
      14             : 
      15             : #include "mozilla/Attributes.h"
      16             : #include "nsAutoPtr.h"
      17             : #include "nsChangeHint.h"
      18             : #include "nsCOMPtr.h"
      19             : #include "nsCycleCollectionParticipant.h"
      20             : #include "nsError.h"
      21             : #include "mozilla/dom/DOMRect.h"
      22             : #include "mozilla/dom/Element.h"
      23             : #include "mozilla/gfx/MatrixFwd.h"
      24             : #include "nsISupportsImpl.h"
      25             : #include "nsStyledElement.h"
      26             : #include "nsSVGClass.h"
      27             : #include "nsIDOMSVGElement.h"
      28             : #include "SVGContentUtils.h"
      29             : #include "gfxMatrix.h"
      30             : 
      31             : class nsSVGAngle;
      32             : class nsSVGBoolean;
      33             : class nsSVGEnum;
      34             : class nsSVGInteger;
      35             : class nsSVGIntegerPair;
      36             : class nsSVGLength2;
      37             : class nsSVGNumber2;
      38             : class nsSVGNumberPair;
      39             : class nsSVGString;
      40             : class nsSVGViewBox;
      41             : 
      42             : namespace mozilla {
      43             : class DeclarationBlock;
      44             : 
      45             : namespace dom {
      46             : class SVGSVGElement;
      47             : 
      48             : static const unsigned short SVG_UNIT_TYPE_UNKNOWN           = 0;
      49             : static const unsigned short SVG_UNIT_TYPE_USERSPACEONUSE    = 1;
      50             : static const unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2;
      51             : 
      52             : } // namespace dom
      53             : 
      54             : class SVGAnimatedNumberList;
      55             : class SVGNumberList;
      56             : class SVGAnimatedLengthList;
      57             : class SVGUserUnitList;
      58             : class SVGAnimatedPointList;
      59             : class SVGAnimatedPathSegList;
      60             : class SVGAnimatedPreserveAspectRatio;
      61             : class nsSVGAnimatedTransformList;
      62             : class SVGStringList;
      63             : class DOMSVGStringList;
      64             : 
      65             : } // namespace mozilla
      66             : 
      67             : struct nsSVGEnumMapping;
      68             : 
      69             : typedef nsStyledElement nsSVGElementBase;
      70             : 
      71             : class nsSVGElement : public nsSVGElementBase    // nsIContent
      72             :                    , public nsIDOMSVGElement
      73             : {
      74             : protected:
      75             :   explicit nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
      76             :   friend nsresult NS_NewSVGElement(mozilla::dom::Element **aResult,
      77             :                                    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
      78             :   nsresult Init();
      79             :   virtual ~nsSVGElement();
      80             : 
      81             : public:
      82             : 
      83             :   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
      84             :                          bool aPreallocateChildren) const MOZ_MUST_OVERRIDE override;
      85             : 
      86             :   typedef mozilla::SVGNumberList SVGNumberList;
      87             :   typedef mozilla::SVGAnimatedNumberList SVGAnimatedNumberList;
      88             :   typedef mozilla::SVGUserUnitList SVGUserUnitList;
      89             :   typedef mozilla::SVGAnimatedLengthList SVGAnimatedLengthList;
      90             :   typedef mozilla::SVGAnimatedPointList SVGAnimatedPointList;
      91             :   typedef mozilla::SVGAnimatedPathSegList SVGAnimatedPathSegList;
      92             :   typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
      93             :   typedef mozilla::nsSVGAnimatedTransformList nsSVGAnimatedTransformList;
      94             :   typedef mozilla::SVGStringList SVGStringList;
      95             : 
      96             :   // nsISupports
      97             :   NS_DECL_ISUPPORTS_INHERITED
      98             : 
      99             :   void DidAnimateClass();
     100             : 
     101             :   // nsIContent interface methods
     102             : 
     103             :   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
     104             :                               nsIContent* aBindingParent,
     105             :                               bool aCompileEventHandlers) override;
     106             : 
     107             :   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
     108             :                              bool aNotify) override;
     109             : 
     110             :   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
     111             :                                               int32_t aModType) const override;
     112             : 
     113             :   virtual bool IsNodeOfType(uint32_t aFlags) const override;
     114             : 
     115             :   /**
     116             :    * We override the default to unschedule computation of Servo declaration blocks
     117             :    * when adopted across documents.
     118             :    */
     119             :   virtual void NodeInfoChanged(nsIDocument* aOldDoc) override;
     120             : 
     121             :   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) override;
     122             :   void WalkAnimatedContentStyleRules(nsRuleWalker* aRuleWalker);
     123             : 
     124             :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
     125             : 
     126             :   static const MappedAttributeEntry sFillStrokeMap[];
     127             :   static const MappedAttributeEntry sGraphicsMap[];
     128             :   static const MappedAttributeEntry sTextContentElementsMap[];
     129             :   static const MappedAttributeEntry sFontSpecificationMap[];
     130             :   static const MappedAttributeEntry sGradientStopMap[];
     131             :   static const MappedAttributeEntry sViewportsMap[];
     132             :   static const MappedAttributeEntry sMarkersMap[];
     133             :   static const MappedAttributeEntry sColorMap[];
     134             :   static const MappedAttributeEntry sFiltersMap[];
     135             :   static const MappedAttributeEntry sFEFloodMap[];
     136             :   static const MappedAttributeEntry sLightingEffectsMap[];
     137             :   static const MappedAttributeEntry sMaskMap[];
     138             : 
     139           0 :   NS_FORWARD_NSIDOMNODE_TO_NSINODE
     140           0 :   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
     141             :   NS_DECL_NSIDOMSVGELEMENT
     142             : 
     143           0 :   NS_IMPL_FROMCONTENT(nsSVGElement, kNameSpaceID_SVG)
     144             : 
     145             :   // Gets the element that establishes the rectangular viewport against which
     146             :   // we should resolve percentage lengths (our "coordinate context"). Returns
     147             :   // nullptr for outer <svg> or SVG without an <svg> parent (invalid SVG).
     148             :   mozilla::dom::SVGSVGElement* GetCtx() const;
     149             : 
     150             :   /**
     151             :    * Returns aMatrix pre-multiplied by (explicit or implicit) transforms that
     152             :    * are introduced by attributes on this element.
     153             :    *
     154             :    * If aWhich is eAllTransforms, then all the transforms from the coordinate
     155             :    * space established by this element for its children to the coordinate
     156             :    * space established by this element's parent element for this element, are
     157             :    * included.
     158             :    *
     159             :    * If aWhich is eUserSpaceToParent, then only the transforms from this
     160             :    * element's userspace to the coordinate space established by its parent is
     161             :    * included. This includes any transforms introduced by the 'transform'
     162             :    * attribute, transform animations and animateMotion, but not any offsets
     163             :    * due to e.g. 'x'/'y' attributes, or any transform due to a 'viewBox'
     164             :    * attribute. (SVG userspace is defined to be the coordinate space in which
     165             :    * coordinates on an element apply.)
     166             :    *
     167             :    * If aWhich is eChildToUserSpace, then only the transforms from the
     168             :    * coordinate space established by this element for its childre to this
     169             :    * elements userspace are included. This includes any offsets due to e.g.
     170             :    * 'x'/'y' attributes, and any transform due to a 'viewBox' attribute, but
     171             :    * does not include any transforms due to the 'transform' attribute.
     172             :    */
     173             :   virtual gfxMatrix PrependLocalTransformsTo(
     174             :     const gfxMatrix &aMatrix, SVGTransformTypes aWhich = eAllTransforms) const;
     175             : 
     176             :   // Setter for to set the current <animateMotion> transformation
     177             :   // Only visible for nsSVGGraphicElement, so it's a no-op here, and that
     178             :   // subclass has the useful implementation.
     179           0 :   virtual void SetAnimateMotionTransform(const mozilla::gfx::Matrix* aMatrix) {/*no-op*/}
     180           0 :   virtual const mozilla::gfx::Matrix* GetAnimateMotionTransform() const { return nullptr; }
     181             : 
     182           0 :   bool IsStringAnimatable(uint8_t aAttrEnum) {
     183           0 :     return GetStringInfo().mStringInfo[aAttrEnum].mIsAnimatable;
     184             :   }
     185           0 :   bool NumberAttrAllowsPercentage(uint8_t aAttrEnum) {
     186           0 :     return GetNumberInfo().mNumberInfo[aAttrEnum].mPercentagesAllowed;
     187             :   }
     188           9 :   virtual bool HasValidDimensions() const {
     189           9 :     return true;
     190             :   }
     191             :   void SetLength(nsIAtom* aName, const nsSVGLength2 &aLength);
     192             : 
     193             :   nsAttrValue WillChangeLength(uint8_t aAttrEnum);
     194             :   nsAttrValue WillChangeNumberPair(uint8_t aAttrEnum);
     195             :   nsAttrValue WillChangeIntegerPair(uint8_t aAttrEnum);
     196             :   nsAttrValue WillChangeAngle(uint8_t aAttrEnum);
     197             :   nsAttrValue WillChangeViewBox();
     198             :   nsAttrValue WillChangePreserveAspectRatio();
     199             :   nsAttrValue WillChangeNumberList(uint8_t aAttrEnum);
     200             :   nsAttrValue WillChangeLengthList(uint8_t aAttrEnum);
     201             :   nsAttrValue WillChangePointList();
     202             :   nsAttrValue WillChangePathSegList();
     203             :   nsAttrValue WillChangeTransformList();
     204             :   nsAttrValue WillChangeStringList(bool aIsConditionalProcessingAttribute,
     205             :                                    uint8_t aAttrEnum);
     206             : 
     207             :   void DidChangeLength(uint8_t aAttrEnum, const nsAttrValue& aEmptyOrOldValue);
     208             :   void DidChangeNumber(uint8_t aAttrEnum);
     209             :   void DidChangeNumberPair(uint8_t aAttrEnum,
     210             :                            const nsAttrValue& aEmptyOrOldValue);
     211             :   void DidChangeInteger(uint8_t aAttrEnum);
     212             :   void DidChangeIntegerPair(uint8_t aAttrEnum,
     213             :                             const nsAttrValue& aEmptyOrOldValue);
     214             :   void DidChangeAngle(uint8_t aAttrEnum, const nsAttrValue& aEmptyOrOldValue);
     215             :   void DidChangeBoolean(uint8_t aAttrEnum);
     216             :   void DidChangeEnum(uint8_t aAttrEnum);
     217             :   void DidChangeViewBox(const nsAttrValue& aEmptyOrOldValue);
     218             :   void DidChangePreserveAspectRatio(const nsAttrValue& aEmptyOrOldValue);
     219             :   void DidChangeNumberList(uint8_t aAttrEnum,
     220             :                            const nsAttrValue& aEmptyOrOldValue);
     221             :   void DidChangeLengthList(uint8_t aAttrEnum,
     222             :                            const nsAttrValue& aEmptyOrOldValue);
     223             :   void DidChangePointList(const nsAttrValue& aEmptyOrOldValue);
     224             :   void DidChangePathSegList(const nsAttrValue& aEmptyOrOldValue);
     225             :   void DidChangeTransformList(const nsAttrValue& aEmptyOrOldValue);
     226          29 :   void DidChangeString(uint8_t aAttrEnum) {}
     227             :   void DidChangeStringList(bool aIsConditionalProcessingAttribute,
     228             :                            uint8_t aAttrEnum,
     229             :                            const nsAttrValue& aEmptyOrOldValue);
     230             : 
     231             :   void DidAnimateLength(uint8_t aAttrEnum);
     232             :   void DidAnimateNumber(uint8_t aAttrEnum);
     233             :   void DidAnimateNumberPair(uint8_t aAttrEnum);
     234             :   void DidAnimateInteger(uint8_t aAttrEnum);
     235             :   void DidAnimateIntegerPair(uint8_t aAttrEnum);
     236             :   void DidAnimateAngle(uint8_t aAttrEnum);
     237             :   void DidAnimateBoolean(uint8_t aAttrEnum);
     238             :   void DidAnimateEnum(uint8_t aAttrEnum);
     239             :   void DidAnimateViewBox();
     240             :   void DidAnimatePreserveAspectRatio();
     241             :   void DidAnimateNumberList(uint8_t aAttrEnum);
     242             :   void DidAnimateLengthList(uint8_t aAttrEnum);
     243             :   void DidAnimatePointList();
     244             :   void DidAnimatePathSegList();
     245             :   void DidAnimateTransformList(int32_t aModType);
     246             :   void DidAnimateString(uint8_t aAttrEnum);
     247             : 
     248             :   enum {
     249             :     /**
     250             :      * Flag to indicate to GetAnimatedXxx() methods that the object being
     251             :      * requested should be allocated if it hasn't already been allocated, and
     252             :      * that the method should not return null. Only applicable to methods that
     253             :      * need to allocate the object that they return.
     254             :      */
     255             :     DO_ALLOCATE = 0x1
     256             :   };
     257             : 
     258             :   nsSVGLength2* GetAnimatedLength(const nsIAtom *aAttrName);
     259             :   void GetAnimatedLengthValues(float *aFirst, ...);
     260             :   void GetAnimatedNumberValues(float *aFirst, ...);
     261             :   void GetAnimatedIntegerValues(int32_t *aFirst, ...);
     262             :   SVGAnimatedNumberList* GetAnimatedNumberList(uint8_t aAttrEnum);
     263             :   SVGAnimatedNumberList* GetAnimatedNumberList(nsIAtom *aAttrName);
     264             :   void GetAnimatedLengthListValues(SVGUserUnitList *aFirst, ...);
     265             :   SVGAnimatedLengthList* GetAnimatedLengthList(uint8_t aAttrEnum);
     266           0 :   virtual SVGAnimatedPointList* GetAnimatedPointList() {
     267           0 :     return nullptr;
     268             :   }
     269           0 :   virtual SVGAnimatedPathSegList* GetAnimPathSegList() {
     270             :     // DOM interface 'SVGAnimatedPathData' (*inherited* by nsSVGPathElement)
     271             :     // has a member called 'animatedPathSegList' member, so we have a shorter
     272             :     // name so we don't get hidden by the GetAnimatedPathSegList declared by
     273             :     // NS_DECL_NSIDOMSVGANIMATEDPATHDATA.
     274           0 :     return nullptr;
     275             :   }
     276             :   /**
     277             :    * Get the nsSVGAnimatedTransformList for this element.
     278             :    *
     279             :    * Despite the fact that animated transform lists are used for a variety of
     280             :    * attributes, no SVG element uses more than one.
     281             :    *
     282             :    * It's relatively uncommon for elements to have their transform attribute
     283             :    * set, so to save memory the nsSVGAnimatedTransformList is not allocated until
     284             :    * the attribute is set/animated or its DOM wrapper is created. Callers that
     285             :    * require the nsSVGAnimatedTransformList to be allocated and for this method
     286             :    * to return non-null must pass the DO_ALLOCATE flag.
     287             :    */
     288           0 :   virtual nsSVGAnimatedTransformList* GetAnimatedTransformList(
     289             :                                                         uint32_t aFlags = 0) {
     290           0 :     return nullptr;
     291             :   }
     292             : 
     293             :   mozilla::UniquePtr<nsISMILAttr> GetAnimatedAttr(int32_t aNamespaceID,
     294             :                                                   nsIAtom* aName) override;
     295             :   void AnimationNeedsResample();
     296             :   void FlushAnimations();
     297             : 
     298             :   virtual void RecompileScriptEventListeners() override;
     299             : 
     300             :   void GetStringBaseValue(uint8_t aAttrEnum, nsAString& aResult) const;
     301             :   void SetStringBaseValue(uint8_t aAttrEnum, const nsAString& aValue);
     302             : 
     303         178 :   virtual nsIAtom* GetPointListAttrName() const {
     304         178 :     return nullptr;
     305             :   }
     306         109 :   virtual nsIAtom* GetPathDataAttrName() const {
     307         109 :     return nullptr;
     308             :   }
     309           2 :   virtual nsIAtom* GetTransformListAttrName() const {
     310           2 :     return nullptr;
     311             :   }
     312         112 :   const nsAttrValue* GetAnimatedClassName() const
     313             :   {
     314         112 :     if (!mClassAttribute.IsAnimated()) {
     315         112 :       return nullptr;
     316             :     }
     317           0 :     return mClassAnimAttr;
     318             :   }
     319             : 
     320           0 :   virtual void ClearAnyCachedPath() {}
     321           0 :   virtual nsIDOMNode* AsDOMNode() final override { return this; }
     322           0 :   virtual bool IsTransformable() { return false; }
     323             : 
     324             :   // WebIDL
     325             :   mozilla::dom::SVGSVGElement* GetOwnerSVGElement();
     326             :   nsSVGElement* GetViewportElement();
     327             :   already_AddRefed<mozilla::dom::SVGAnimatedString> ClassName();
     328             : 
     329             :   virtual bool IsSVGFocusable(bool* aIsFocusable, int32_t* aTabIndex);
     330             :   virtual bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override;
     331             : 
     332             :   void UpdateContentDeclarationBlock(mozilla::StyleBackendType aBackend);
     333             :   const mozilla::DeclarationBlock* GetContentDeclarationBlock() const;
     334             : 
     335             : protected:
     336             :   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
     337             : 
     338             : #ifdef DEBUG
     339             :   // We define BeforeSetAttr here and mark it final to ensure it is NOT used
     340             :   // by SVG elements.
     341             :   // This is because we're not currently passing the correct value for aValue to
     342             :   // BeforeSetAttr since it would involve allocating extra SVG value types.
     343             :   // See the comment in nsSVGElement::WillChangeValue.
     344         374 :   virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
     345             :                                  const nsAttrValueOrString* aValue,
     346             :                                  bool aNotify) override final
     347             :   {
     348         374 :     return nsSVGElementBase::BeforeSetAttr(aNamespaceID, aName, aValue, aNotify);
     349             :   }
     350             : #endif // DEBUG
     351             :   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
     352             :                                 const nsAttrValue* aValue,
     353             :                                 const nsAttrValue* aOldValue,
     354             :                                 bool aNotify) override;
     355             :   virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
     356             :                                 const nsAString& aValue, nsAttrValue& aResult) override;
     357             :   static nsresult ReportAttributeParseFailure(nsIDocument* aDocument,
     358             :                                               nsIAtom* aAttribute,
     359             :                                               const nsAString& aValue);
     360             : 
     361             :   nsAttrValue WillChangeValue(nsIAtom* aName);
     362             :   // aNewValue is set to the old value. This value may be invalid if
     363             :   // !StoresOwnData.
     364             :   void DidChangeValue(nsIAtom* aName, const nsAttrValue& aEmptyOrOldValue,
     365             :                       nsAttrValue& aNewValue);
     366             :   void MaybeSerializeAttrBeforeRemoval(nsIAtom* aName, bool aNotify);
     367             : 
     368             :   static nsIAtom* GetEventNameForAttr(nsIAtom* aAttr);
     369             : 
     370             :   struct LengthInfo {
     371             :     nsIAtom** mName;
     372             :     float     mDefaultValue;
     373             :     uint8_t   mDefaultUnitType;
     374             :     uint8_t   mCtxType;
     375             :   };
     376             : 
     377             :   struct LengthAttributesInfo {
     378             :     nsSVGLength2* mLengths;
     379             :     LengthInfo*   mLengthInfo;
     380             :     uint32_t      mLengthCount;
     381             : 
     382         594 :     LengthAttributesInfo(nsSVGLength2 *aLengths,
     383             :                          LengthInfo *aLengthInfo,
     384         594 :                          uint32_t aLengthCount) :
     385         594 :       mLengths(aLengths), mLengthInfo(aLengthInfo), mLengthCount(aLengthCount)
     386         594 :       {}
     387             : 
     388             :     void Reset(uint8_t aAttrEnum);
     389             :   };
     390             : 
     391             :   struct NumberInfo {
     392             :     nsIAtom** mName;
     393             :     float     mDefaultValue;
     394             :     bool mPercentagesAllowed;
     395             :   };
     396             : 
     397             :   struct NumberAttributesInfo {
     398             :     nsSVGNumber2* mNumbers;
     399             :     NumberInfo*   mNumberInfo;
     400             :     uint32_t      mNumberCount;
     401             : 
     402         299 :     NumberAttributesInfo(nsSVGNumber2 *aNumbers,
     403             :                          NumberInfo *aNumberInfo,
     404         299 :                          uint32_t aNumberCount) :
     405         299 :       mNumbers(aNumbers), mNumberInfo(aNumberInfo), mNumberCount(aNumberCount)
     406         299 :       {}
     407             : 
     408             :     void Reset(uint8_t aAttrEnum);
     409             :   };
     410             : 
     411             :   struct NumberPairInfo {
     412             :     nsIAtom** mName;
     413             :     float     mDefaultValue1;
     414             :     float     mDefaultValue2;
     415             :   };
     416             : 
     417             :   struct NumberPairAttributesInfo {
     418             :     nsSVGNumberPair* mNumberPairs;
     419             :     NumberPairInfo*  mNumberPairInfo;
     420             :     uint32_t         mNumberPairCount;
     421             : 
     422         299 :     NumberPairAttributesInfo(nsSVGNumberPair *aNumberPairs,
     423             :                              NumberPairInfo *aNumberPairInfo,
     424         299 :                              uint32_t aNumberPairCount) :
     425             :       mNumberPairs(aNumberPairs), mNumberPairInfo(aNumberPairInfo),
     426         299 :       mNumberPairCount(aNumberPairCount)
     427         299 :       {}
     428             : 
     429             :     void Reset(uint8_t aAttrEnum);
     430             :   };
     431             : 
     432             :   struct IntegerInfo {
     433             :     nsIAtom** mName;
     434             :     int32_t   mDefaultValue;
     435             :   };
     436             : 
     437             :   struct IntegerAttributesInfo {
     438             :     nsSVGInteger* mIntegers;
     439             :     IntegerInfo*  mIntegerInfo;
     440             :     uint32_t      mIntegerCount;
     441             : 
     442         299 :     IntegerAttributesInfo(nsSVGInteger *aIntegers,
     443             :                           IntegerInfo *aIntegerInfo,
     444         299 :                           uint32_t aIntegerCount) :
     445         299 :       mIntegers(aIntegers), mIntegerInfo(aIntegerInfo), mIntegerCount(aIntegerCount)
     446         299 :       {}
     447             : 
     448             :     void Reset(uint8_t aAttrEnum);
     449             :   };
     450             : 
     451             :   struct IntegerPairInfo {
     452             :     nsIAtom** mName;
     453             :     int32_t   mDefaultValue1;
     454             :     int32_t   mDefaultValue2;
     455             :   };
     456             : 
     457             :   struct IntegerPairAttributesInfo {
     458             :     nsSVGIntegerPair* mIntegerPairs;
     459             :     IntegerPairInfo*  mIntegerPairInfo;
     460             :     uint32_t          mIntegerPairCount;
     461             : 
     462         299 :     IntegerPairAttributesInfo(nsSVGIntegerPair *aIntegerPairs,
     463             :                               IntegerPairInfo *aIntegerPairInfo,
     464         299 :                               uint32_t aIntegerPairCount) :
     465             :       mIntegerPairs(aIntegerPairs), mIntegerPairInfo(aIntegerPairInfo),
     466         299 :       mIntegerPairCount(aIntegerPairCount)
     467         299 :       {}
     468             : 
     469             :     void Reset(uint8_t aAttrEnum);
     470             :   };
     471             : 
     472             :   struct AngleInfo {
     473             :     nsIAtom** mName;
     474             :     float     mDefaultValue;
     475             :     uint8_t   mDefaultUnitType;
     476             :   };
     477             : 
     478             :   struct AngleAttributesInfo {
     479             :     nsSVGAngle* mAngles;
     480             :     AngleInfo*  mAngleInfo;
     481             :     uint32_t    mAngleCount;
     482             : 
     483         299 :     AngleAttributesInfo(nsSVGAngle *aAngles,
     484             :                         AngleInfo *aAngleInfo,
     485         299 :                         uint32_t aAngleCount) :
     486         299 :       mAngles(aAngles), mAngleInfo(aAngleInfo), mAngleCount(aAngleCount)
     487         299 :       {}
     488             : 
     489             :     void Reset(uint8_t aAttrEnum);
     490             :   };
     491             : 
     492             :   struct BooleanInfo {
     493             :     nsIAtom**    mName;
     494             :     bool mDefaultValue;
     495             :   };
     496             : 
     497             :   struct BooleanAttributesInfo {
     498             :     nsSVGBoolean* mBooleans;
     499             :     BooleanInfo*  mBooleanInfo;
     500             :     uint32_t      mBooleanCount;
     501             : 
     502         299 :     BooleanAttributesInfo(nsSVGBoolean *aBooleans,
     503             :                           BooleanInfo *aBooleanInfo,
     504         299 :                           uint32_t aBooleanCount) :
     505         299 :       mBooleans(aBooleans), mBooleanInfo(aBooleanInfo), mBooleanCount(aBooleanCount)
     506         299 :       {}
     507             : 
     508             :     void Reset(uint8_t aAttrEnum);
     509             :   };
     510             : 
     511             :   friend class nsSVGEnum;
     512             : 
     513             :   struct EnumInfo {
     514             :     nsIAtom**         mName;
     515             :     nsSVGEnumMapping* mMapping;
     516             :     uint16_t          mDefaultValue;
     517             :   };
     518             : 
     519             :   struct EnumAttributesInfo {
     520             :     nsSVGEnum* mEnums;
     521             :     EnumInfo*  mEnumInfo;
     522             :     uint32_t   mEnumCount;
     523             : 
     524         305 :     EnumAttributesInfo(nsSVGEnum *aEnums,
     525             :                        EnumInfo *aEnumInfo,
     526         305 :                        uint32_t aEnumCount) :
     527         305 :       mEnums(aEnums), mEnumInfo(aEnumInfo), mEnumCount(aEnumCount)
     528         305 :       {}
     529             : 
     530             :     void Reset(uint8_t aAttrEnum);
     531             :   };
     532             : 
     533             :   struct NumberListInfo {
     534             :     nsIAtom** mName;
     535             :   };
     536             : 
     537             :   struct NumberListAttributesInfo {
     538             :     SVGAnimatedNumberList* mNumberLists;
     539             :     NumberListInfo*        mNumberListInfo;
     540             :     uint32_t               mNumberListCount;
     541             : 
     542         357 :     NumberListAttributesInfo(SVGAnimatedNumberList *aNumberLists,
     543             :                              NumberListInfo *aNumberListInfo,
     544             :                              uint32_t aNumberListCount)
     545         357 :       : mNumberLists(aNumberLists)
     546             :       , mNumberListInfo(aNumberListInfo)
     547         357 :       , mNumberListCount(aNumberListCount)
     548         357 :     {}
     549             : 
     550             :     void Reset(uint8_t aAttrEnum);
     551             :   };
     552             : 
     553             :   struct LengthListInfo {
     554             :     nsIAtom** mName;
     555             :     uint8_t   mAxis;
     556             :     /**
     557             :      * Flag to indicate whether appending zeros to the end of the list would
     558             :      * change the rendering of the SVG for the attribute in question. For x and
     559             :      * y on the <text> element this is true, but for dx and dy on <text> this
     560             :      * is false. This flag is fed down to SVGLengthListSMILType so it can
     561             :      * determine if it can sensibly animate from-to lists of different lengths,
     562             :      * which is desirable in the case of dx and dy.
     563             :      */
     564             :     bool mCouldZeroPadList;
     565             :   };
     566             : 
     567             :   struct LengthListAttributesInfo {
     568             :     SVGAnimatedLengthList* mLengthLists;
     569             :     LengthListInfo*        mLengthListInfo;
     570             :     uint32_t               mLengthListCount;
     571             : 
     572         357 :     LengthListAttributesInfo(SVGAnimatedLengthList *aLengthLists,
     573             :                              LengthListInfo *aLengthListInfo,
     574             :                              uint32_t aLengthListCount)
     575         357 :       : mLengthLists(aLengthLists)
     576             :       , mLengthListInfo(aLengthListInfo)
     577         357 :       , mLengthListCount(aLengthListCount)
     578         357 :     {}
     579             : 
     580             :     void Reset(uint8_t aAttrEnum);
     581             :   };
     582             : 
     583             :   struct StringInfo {
     584             :     nsIAtom**    mName;
     585             :     int32_t      mNamespaceID;
     586             :     bool mIsAnimatable;
     587             :   };
     588             : 
     589             :   struct StringAttributesInfo {
     590             :     nsSVGString*  mStrings;
     591             :     StringInfo*   mStringInfo;
     592             :     uint32_t      mStringCount;
     593             : 
     594         338 :     StringAttributesInfo(nsSVGString *aStrings,
     595             :                          StringInfo *aStringInfo,
     596         338 :                          uint32_t aStringCount) :
     597         338 :       mStrings(aStrings), mStringInfo(aStringInfo), mStringCount(aStringCount)
     598         338 :       {}
     599             : 
     600             :     void Reset(uint8_t aAttrEnum);
     601             :   };
     602             : 
     603             :   friend class mozilla::DOMSVGStringList;
     604             : 
     605             :   struct StringListInfo {
     606             :     nsIAtom**    mName;
     607             :   };
     608             : 
     609             :   struct StringListAttributesInfo {
     610             :     SVGStringList*    mStringLists;
     611             :     StringListInfo*   mStringListInfo;
     612             :     uint32_t          mStringListCount;
     613             : 
     614         142 :     StringListAttributesInfo(SVGStringList  *aStringLists,
     615             :                              StringListInfo *aStringListInfo,
     616         142 :                              uint32_t aStringListCount) :
     617             :       mStringLists(aStringLists), mStringListInfo(aStringListInfo),
     618         142 :       mStringListCount(aStringListCount)
     619         142 :       {}
     620             : 
     621             :     void Reset(uint8_t aAttrEnum);
     622             :   };
     623             : 
     624             :   virtual LengthAttributesInfo GetLengthInfo();
     625             :   virtual NumberAttributesInfo GetNumberInfo();
     626             :   virtual NumberPairAttributesInfo GetNumberPairInfo();
     627             :   virtual IntegerAttributesInfo GetIntegerInfo();
     628             :   virtual IntegerPairAttributesInfo GetIntegerPairInfo();
     629             :   virtual AngleAttributesInfo GetAngleInfo();
     630             :   virtual BooleanAttributesInfo GetBooleanInfo();
     631             :   virtual EnumAttributesInfo GetEnumInfo();
     632             :   // We assume all viewboxes and preserveAspectRatios are alike
     633             :   // so we don't need to wrap the class
     634             :   virtual nsSVGViewBox *GetViewBox();
     635             :   virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio();
     636             :   virtual NumberListAttributesInfo GetNumberListInfo();
     637             :   virtual LengthListAttributesInfo GetLengthListInfo();
     638             :   virtual StringAttributesInfo GetStringInfo();
     639             :   virtual StringListAttributesInfo GetStringListInfo();
     640             : 
     641             :   static nsSVGEnumMapping sSVGUnitTypesMap[];
     642             : 
     643             : private:
     644             :   void UnsetAttrInternal(int32_t aNameSpaceID, nsIAtom* aAttribute,
     645             :                          bool aNotify);
     646             : 
     647             :   nsSVGClass mClassAttribute;
     648             :   nsAutoPtr<nsAttrValue> mClassAnimAttr;
     649             :   RefPtr<mozilla::DeclarationBlock> mContentDeclarationBlock;
     650             : };
     651             : 
     652             : /**
     653             :  * A macro to implement the NS_NewSVGXXXElement() functions.
     654             :  */
     655             : #define NS_IMPL_NS_NEW_SVG_ELEMENT(_elementName)                             \
     656             : nsresult                                                                     \
     657             : NS_NewSVG##_elementName##Element(nsIContent **aResult,                       \
     658             :                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)  \
     659             : {                                                                            \
     660             :   RefPtr<nsSVG##_elementName##Element> it =                                \
     661             :     new nsSVG##_elementName##Element(aNodeInfo);                             \
     662             :                                                                              \
     663             :   nsresult rv = it->Init();                                                  \
     664             :                                                                              \
     665             :   if (NS_FAILED(rv)) {                                                       \
     666             :     return rv;                                                               \
     667             :   }                                                                          \
     668             :                                                                              \
     669             :   it.forget(aResult);                                                        \
     670             :                                                                              \
     671             :   return rv;                                                                 \
     672             : }
     673             : 
     674             : #define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(_elementName)                  \
     675             : nsresult                                                                     \
     676             : NS_NewSVG##_elementName##Element(nsIContent **aResult,                       \
     677             :                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)  \
     678             : {                                                                            \
     679             :   RefPtr<mozilla::dom::SVG##_elementName##Element> it =                    \
     680             :     new mozilla::dom::SVG##_elementName##Element(aNodeInfo);                 \
     681             :                                                                              \
     682             :   nsresult rv = it->Init();                                                  \
     683             :                                                                              \
     684             :   if (NS_FAILED(rv)) {                                                       \
     685             :     return rv;                                                               \
     686             :   }                                                                          \
     687             :                                                                              \
     688             :   it.forget(aResult);                                                        \
     689             :                                                                              \
     690             :   return rv;                                                                 \
     691             : }
     692             : 
     693             : #define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT_CHECK_PARSER(_elementName)     \
     694             : nsresult                                                                     \
     695             : NS_NewSVG##_elementName##Element(nsIContent **aResult,                       \
     696             :                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,  \
     697             :                                  mozilla::dom::FromParser aFromParser)       \
     698             : {                                                                            \
     699             :   RefPtr<mozilla::dom::SVG##_elementName##Element> it =                    \
     700             :     new mozilla::dom::SVG##_elementName##Element(aNodeInfo, aFromParser);    \
     701             :                                                                              \
     702             :   nsresult rv = it->Init();                                                  \
     703             :                                                                              \
     704             :   if (NS_FAILED(rv)) {                                                       \
     705             :     return rv;                                                               \
     706             :   }                                                                          \
     707             :                                                                              \
     708             :   it.forget(aResult);                                                        \
     709             :                                                                              \
     710             :   return rv;                                                                 \
     711             : }
     712             : 
     713             : // No unlinking, we'd need to null out the value pointer (the object it
     714             : // points to is held by the element) and null-check it everywhere.
     715             : #define NS_SVG_VAL_IMPL_CYCLE_COLLECTION(_val, _element)                     \
     716             : NS_IMPL_CYCLE_COLLECTION_CLASS(_val)                                         \
     717             : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_val)                                \
     718             :   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_element) \
     719             : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END                                        \
     720             : NS_IMPL_CYCLE_COLLECTION_UNLINK_0(_val)
     721             : 
     722             : #define NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(_val, _element)       \
     723             : NS_IMPL_CYCLE_COLLECTION_CLASS(_val)                                         \
     724             : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_val)                                  \
     725             : NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER                            \
     726             : NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                          \
     727             : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_val)                                \
     728             :   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_element)                                \
     729             : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END                                        \
     730             : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_val)                                   \
     731             : NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER                             \
     732             : NS_IMPL_CYCLE_COLLECTION_TRACE_END
     733             : 
     734             : #endif // __NS_SVGELEMENT_H__

Generated by: LCOV version 1.13