LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGGradientElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 76 0 0.0 %
Date: 2012-06-02 Functions: 37 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                 :  * Scooter Morris.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2004
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Scooter Morris <scootermorris@comcast.net>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * 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                 : #include "mozilla/Util.h"
      40                 : 
      41                 : #include "DOMSVGAnimatedTransformList.h"
      42                 : #include "nsIDOMSVGAnimatedEnum.h"
      43                 : #include "nsIDOMSVGURIReference.h"
      44                 : #include "nsIDOMSVGGradientElement.h"
      45                 : #include "nsIDOMMutationEvent.h"
      46                 : #include "nsCOMPtr.h"
      47                 : #include "nsSVGStylableElement.h"
      48                 : #include "nsGkAtoms.h"
      49                 : #include "nsSVGGradientElement.h"
      50                 : #include "nsIFrame.h"
      51                 : 
      52                 : using namespace mozilla;
      53                 : 
      54                 : //--------------------- Gradients------------------------
      55                 : 
      56                 : nsSVGEnumMapping nsSVGGradientElement::sSpreadMethodMap[] = {
      57                 :   {&nsGkAtoms::pad, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD},
      58                 :   {&nsGkAtoms::reflect, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT},
      59                 :   {&nsGkAtoms::repeat, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT},
      60                 :   {nsnull, 0}
      61                 : };
      62                 : 
      63                 : nsSVGElement::EnumInfo nsSVGGradientElement::sEnumInfo[2] =
      64                 : {
      65                 :   { &nsGkAtoms::gradientUnits,
      66                 :     sSVGUnitTypesMap,
      67                 :     nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
      68                 :   },
      69                 :   { &nsGkAtoms::spreadMethod,
      70                 :     sSpreadMethodMap,
      71                 :     nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD
      72                 :   }
      73                 : };
      74                 : 
      75                 : nsSVGElement::StringInfo nsSVGGradientElement::sStringInfo[1] =
      76                 : {
      77                 :   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
      78                 : };
      79                 : 
      80                 : //----------------------------------------------------------------------
      81                 : // nsISupports methods
      82                 : 
      83               0 : NS_IMPL_ADDREF_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
      84               0 : NS_IMPL_RELEASE_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
      85                 : 
      86               0 : NS_INTERFACE_MAP_BEGIN(nsSVGGradientElement)
      87               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
      88               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
      89               0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGGradientElementBase)
      90                 : 
      91                 : //----------------------------------------------------------------------
      92                 : // Implementation
      93                 : 
      94               0 : nsSVGGradientElement::nsSVGGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
      95               0 :   : nsSVGGradientElementBase(aNodeInfo)
      96                 : {
      97               0 : }
      98                 : 
      99                 : //----------------------------------------------------------------------
     100                 : // nsSVGElement methods
     101                 : 
     102                 : nsSVGElement::EnumAttributesInfo
     103               0 : nsSVGGradientElement::GetEnumInfo()
     104                 : {
     105                 :   return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
     106               0 :                             ArrayLength(sEnumInfo));
     107                 : }
     108                 : 
     109                 : nsSVGElement::StringAttributesInfo
     110               0 : nsSVGGradientElement::GetStringInfo()
     111                 : {
     112                 :   return StringAttributesInfo(mStringAttributes, sStringInfo,
     113               0 :                               ArrayLength(sStringInfo));
     114                 : }
     115                 : 
     116                 : //----------------------------------------------------------------------
     117                 : // nsIDOMSVGGradientElement methods
     118                 : 
     119                 : /* readonly attribute nsIDOMSVGAnimatedEnumeration gradientUnits; */
     120               0 : NS_IMETHODIMP nsSVGGradientElement::GetGradientUnits(nsIDOMSVGAnimatedEnumeration * *aGradientUnits)
     121                 : {
     122               0 :   return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(aGradientUnits, this);
     123                 : }
     124                 : 
     125                 : /* readonly attribute nsIDOMSVGAnimatedTransformList gradientTransform; */
     126               0 : NS_IMETHODIMP nsSVGGradientElement::GetGradientTransform(nsIDOMSVGAnimatedTransformList * *aGradientTransform)
     127                 : {
     128                 :   *aGradientTransform =
     129               0 :     DOMSVGAnimatedTransformList::GetDOMWrapper(GetAnimatedTransformList(), this)
     130               0 :     .get();
     131               0 :   return NS_OK;
     132                 : }
     133                 : 
     134                 : /* readonly attribute nsIDOMSVGAnimatedEnumeration spreadMethod; */
     135               0 : NS_IMETHODIMP nsSVGGradientElement::GetSpreadMethod(nsIDOMSVGAnimatedEnumeration * *aSpreadMethod)
     136                 : {
     137               0 :   return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(aSpreadMethod, this);
     138                 : }
     139                 : 
     140                 : //----------------------------------------------------------------------
     141                 : // nsIDOMSVGURIReference methods:
     142                 : 
     143                 : /* readonly attribute nsIDOMSVGAnimatedString href; */
     144                 : NS_IMETHODIMP
     145               0 : nsSVGGradientElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
     146                 : {
     147               0 :   return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
     148                 : }
     149                 : 
     150                 : //----------------------------------------------------------------------
     151                 : // nsIContent methods
     152                 : 
     153                 : NS_IMETHODIMP_(bool)
     154               0 : nsSVGGradientElement::IsAttributeMapped(const nsIAtom* name) const
     155                 : {
     156                 :   static const MappedAttributeEntry* const map[] = {
     157                 :     sColorMap,
     158                 :     sGradientStopMap
     159                 :   };
     160                 :   
     161               0 :   return FindAttributeDependence(name, map) ||
     162               0 :     nsSVGGradientElementBase::IsAttributeMapped(name);
     163                 : }
     164                 : 
     165                 : //---------------------Linear Gradients------------------------
     166                 : 
     167                 : nsSVGElement::LengthInfo nsSVGLinearGradientElement::sLengthInfo[4] =
     168                 : {
     169                 :   { &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X },
     170                 :   { &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
     171                 :   { &nsGkAtoms::x2, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X },
     172                 :   { &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
     173                 : };
     174                 : 
     175               0 : NS_IMPL_NS_NEW_SVG_ELEMENT(LinearGradient)
     176                 : 
     177                 : //----------------------------------------------------------------------
     178                 : // nsISupports methods
     179                 : 
     180               0 : NS_IMPL_ADDREF_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
     181               0 : NS_IMPL_RELEASE_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
     182                 : 
     183               0 : DOMCI_NODE_DATA(SVGLinearGradientElement, nsSVGLinearGradientElement)
     184                 : 
     185               0 : NS_INTERFACE_TABLE_HEAD(nsSVGLinearGradientElement)
     186               0 :   NS_NODE_INTERFACE_TABLE6(nsSVGLinearGradientElement, nsIDOMNode,
     187                 :                            nsIDOMElement, nsIDOMSVGElement,
     188                 :                            nsIDOMSVGTests,
     189                 :                            nsIDOMSVGGradientElement,
     190                 :                            nsIDOMSVGLinearGradientElement)
     191               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLinearGradientElement)
     192               0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGLinearGradientElementBase)
     193                 : 
     194                 : //----------------------------------------------------------------------
     195                 : // Implementation
     196                 : 
     197               0 : nsSVGLinearGradientElement::nsSVGLinearGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     198               0 :   : nsSVGLinearGradientElementBase(aNodeInfo)
     199                 : {
     200               0 : }
     201                 : 
     202                 : //----------------------------------------------------------------------
     203                 : // nsIDOMNode methods
     204                 : 
     205               0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGLinearGradientElement)
     206                 : 
     207                 : //----------------------------------------------------------------------
     208                 : // nsIDOMSVGLinearGradientElement methods
     209                 : 
     210                 : /* readonly attribute nsIDOMSVGAnimatedLength x1; */
     211               0 : NS_IMETHODIMP nsSVGLinearGradientElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
     212                 : {
     213               0 :   return mLengthAttributes[X1].ToDOMAnimatedLength(aX1, this);
     214                 : }
     215                 : 
     216                 : /* readonly attribute nsIDOMSVGAnimatedLength y1; */
     217               0 : NS_IMETHODIMP nsSVGLinearGradientElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
     218                 : {
     219               0 :   return mLengthAttributes[Y1].ToDOMAnimatedLength(aY1, this);
     220                 : }
     221                 : 
     222                 : /* readonly attribute nsIDOMSVGAnimatedLength x2; */
     223               0 : NS_IMETHODIMP nsSVGLinearGradientElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
     224                 : {
     225               0 :   return mLengthAttributes[X2].ToDOMAnimatedLength(aX2, this);
     226                 : }
     227                 : 
     228                 : /* readonly attribute nsIDOMSVGAnimatedLength y2; */
     229               0 : NS_IMETHODIMP nsSVGLinearGradientElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
     230                 : {
     231               0 :   return mLengthAttributes[Y2].ToDOMAnimatedLength(aY2, this);
     232                 : }
     233                 : 
     234                 : 
     235                 : //----------------------------------------------------------------------
     236                 : // nsSVGElement methods
     237                 : 
     238                 : SVGAnimatedTransformList*
     239               0 : nsSVGGradientElement::GetAnimatedTransformList()
     240                 : {
     241               0 :   if (!mGradientTransform) {
     242               0 :     mGradientTransform = new SVGAnimatedTransformList();
     243                 :   }
     244               0 :   return mGradientTransform;
     245                 : }
     246                 : 
     247                 : nsSVGElement::LengthAttributesInfo
     248               0 : nsSVGLinearGradientElement::GetLengthInfo()
     249                 : {
     250                 :   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
     251               0 :                               ArrayLength(sLengthInfo));
     252                 : }
     253                 : 
     254                 : //-------------------------- Radial Gradients ----------------------------
     255                 : 
     256                 : nsSVGElement::LengthInfo nsSVGRadialGradientElement::sLengthInfo[5] =
     257                 : {
     258                 :   { &nsGkAtoms::cx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X },
     259                 :   { &nsGkAtoms::cy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
     260                 :   { &nsGkAtoms::r, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::XY },
     261                 :   { &nsGkAtoms::fx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::X },
     262                 :   { &nsGkAtoms::fy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, nsSVGUtils::Y },
     263                 : };
     264                 : 
     265               0 : NS_IMPL_NS_NEW_SVG_ELEMENT(RadialGradient)
     266                 : 
     267                 : //----------------------------------------------------------------------
     268                 : // nsISupports methods
     269                 : 
     270               0 : NS_IMPL_ADDREF_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
     271               0 : NS_IMPL_RELEASE_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
     272                 : 
     273               0 : DOMCI_NODE_DATA(SVGRadialGradientElement, nsSVGRadialGradientElement)
     274                 : 
     275               0 : NS_INTERFACE_TABLE_HEAD(nsSVGRadialGradientElement)
     276               0 :   NS_NODE_INTERFACE_TABLE6(nsSVGRadialGradientElement, nsIDOMNode,
     277                 :                            nsIDOMElement, nsIDOMSVGElement,
     278                 :                            nsIDOMSVGTests,
     279                 :                            nsIDOMSVGGradientElement,
     280                 :                            nsIDOMSVGRadialGradientElement)
     281               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRadialGradientElement)
     282               0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGRadialGradientElementBase)
     283                 : 
     284                 : //----------------------------------------------------------------------
     285                 : // Implementation
     286                 : 
     287               0 : nsSVGRadialGradientElement::nsSVGRadialGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     288               0 :   : nsSVGRadialGradientElementBase(aNodeInfo)
     289                 : {
     290               0 : }
     291                 : 
     292                 : //----------------------------------------------------------------------
     293                 : // nsIDOMNode methods
     294                 : 
     295               0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRadialGradientElement)
     296                 : 
     297                 : //----------------------------------------------------------------------
     298                 : // nsIDOMSVGRadialGradientElement methods
     299                 : 
     300                 : /* readonly attribute nsIDOMSVGAnimatedLength cx; */
     301               0 : NS_IMETHODIMP nsSVGRadialGradientElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
     302                 : {
     303               0 :   return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
     304                 : }
     305                 : 
     306                 : /* readonly attribute nsIDOMSVGAnimatedLength cy; */
     307               0 : NS_IMETHODIMP nsSVGRadialGradientElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
     308                 : {
     309               0 :   return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
     310                 : }
     311                 : 
     312                 : /* readonly attribute nsIDOMSVGAnimatedLength R; */
     313               0 : NS_IMETHODIMP nsSVGRadialGradientElement::GetR(nsIDOMSVGAnimatedLength * *aR)
     314                 : {
     315               0 :   return mLengthAttributes[R].ToDOMAnimatedLength(aR, this);
     316                 : }
     317                 : 
     318                 : /* readonly attribute nsIDOMSVGAnimatedLength fx; */
     319               0 : NS_IMETHODIMP nsSVGRadialGradientElement::GetFx(nsIDOMSVGAnimatedLength * *aFx)
     320                 : {
     321               0 :   return mLengthAttributes[FX].ToDOMAnimatedLength(aFx, this);
     322                 : }
     323                 : 
     324                 : /* readonly attribute nsIDOMSVGAnimatedLength fy; */
     325               0 : NS_IMETHODIMP nsSVGRadialGradientElement::GetFy(nsIDOMSVGAnimatedLength * *aFy)
     326                 : {
     327               0 :   return mLengthAttributes[FY].ToDOMAnimatedLength(aFy, this);
     328                 : }
     329                 : 
     330                 : //----------------------------------------------------------------------
     331                 : // nsSVGElement methods
     332                 : 
     333                 : nsSVGElement::LengthAttributesInfo
     334               0 : nsSVGRadialGradientElement::GetLengthInfo()
     335                 : {
     336                 :   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
     337               0 :                               ArrayLength(sLengthInfo));
     338                 : }

Generated by: LCOV version 1.7