LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGElement.h (source / functions) Found Hit Coverage
Test: app.info Lines: 59 0 0.0 %
Date: 2012-06-02 Functions: 26 0 0.0 %

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

Generated by: LCOV version 1.7