Back to index

lightning-sunbird  0.9+nobinonly
nsSVGGradientElement.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Mozilla SVG project.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Scooter Morris.
00019  * Portions created by the Initial Developer are Copyright (C) 2004
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Scooter Morris <scootermorris@comcast.net>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsSVGLength.h"
00040 #include "nsSVGAnimatedLength.h"
00041 #include "nsSVGTransformList.h"
00042 #include "nsSVGAnimatedTransformList.h"
00043 #include "nsSVGEnum.h"
00044 #include "nsSVGAnimatedEnumeration.h"
00045 #include "nsIDOMSVGAnimatedEnum.h"
00046 #include "nsIDOMSVGURIReference.h"
00047 #include "nsIDOMSVGGradientElement.h"
00048 #include "nsSVGAnimatedString.h"
00049 #include "nsCOMPtr.h"
00050 #include "nsISVGSVGElement.h"
00051 #include "nsSVGStylableElement.h"
00052 #include "nsSVGAtoms.h"
00053 
00054 //--------------------- Gradients------------------------
00055 
00056 typedef nsSVGStylableElement nsSVGGradientElementBase;
00057 
00058 class nsSVGGradientElement : public nsSVGGradientElementBase,
00059                              public nsIDOMSVGURIReference
00060 {
00061 protected:
00062   nsSVGGradientElement(nsINodeInfo* aNodeInfo);
00063   virtual ~nsSVGGradientElement();
00064   nsresult Init();
00065 
00066 public:
00067   // interfaces:
00068   NS_DECL_ISUPPORTS_INHERITED
00069 
00070   // Gradient Element
00071   NS_DECL_NSIDOMSVGGRADIENTELEMENT
00072 
00073   // URI Reference
00074   NS_DECL_NSIDOMSVGURIREFERENCE
00075 
00076   // nsISVGContent specializations:
00077   virtual void ParentChainChanged();
00078 
00079   // nsIStyledContent
00080   NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
00081 
00082 protected:
00083   
00084   // nsIDOMSVGGradientElement values
00085   nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mGradientUnits;
00086   nsCOMPtr<nsIDOMSVGAnimatedTransformList> mGradientTransform;
00087   nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mSpreadMethod;
00088 
00089   // nsIDOMSVGURIReference properties
00090   nsCOMPtr<nsIDOMSVGAnimatedString> mHref;
00091 };
00092 
00093 
00094 //----------------------------------------------------------------------
00095 // nsISupports methods
00096 
00097 NS_IMPL_ADDREF_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
00098 NS_IMPL_RELEASE_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
00099 
00100 NS_INTERFACE_MAP_BEGIN(nsSVGGradientElement)
00101   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
00102 NS_INTERFACE_MAP_END_INHERITING(nsSVGGradientElementBase)
00103 
00104 //----------------------------------------------------------------------
00105 // Implementation
00106 
00107 nsSVGGradientElement::nsSVGGradientElement(nsINodeInfo* aNodeInfo)
00108   : nsSVGGradientElementBase(aNodeInfo)
00109 {
00110 
00111 }
00112 
00113 nsSVGGradientElement::~nsSVGGradientElement()
00114 {
00115 }
00116 
00117 
00118 nsresult
00119 nsSVGGradientElement::Init()
00120 {
00121   nsresult rv = nsSVGGradientElementBase::Init();
00122   NS_ENSURE_SUCCESS(rv,rv);
00123 
00124   // Define enumeration mappings
00125   static struct nsSVGEnumMapping gUnitMap[] = {
00126         {&nsSVGAtoms::objectBoundingBox, nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX},
00127         {&nsSVGAtoms::userSpaceOnUse, nsIDOMSVGGradientElement::SVG_GRUNITS_USERSPACEONUSE},
00128         {nsnull, 0}
00129   };
00130 
00131   static struct nsSVGEnumMapping gSpreadMap[] = {
00132         {&nsSVGAtoms::pad, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD},
00133         {&nsSVGAtoms::reflect, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT},
00134         {&nsSVGAtoms::repeat, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT},
00135         {nsnull, 0}
00136   };
00137 
00138   // Create mapped attributes
00139 
00140   // DOM property: gradientUnits ,  #IMPLIED attrib: gradientUnits
00141   {
00142     nsCOMPtr<nsISVGEnum> units;
00143     rv = NS_NewSVGEnum(getter_AddRefs(units),
00144                        nsIDOMSVGGradientElement::SVG_GRUNITS_OBJECTBOUNDINGBOX, gUnitMap);
00145     NS_ENSURE_SUCCESS(rv,rv);
00146     rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mGradientUnits), units);
00147     NS_ENSURE_SUCCESS(rv,rv);
00148     rv = AddMappedSVGValue(nsSVGAtoms::gradientUnits, mGradientUnits);
00149     NS_ENSURE_SUCCESS(rv,rv);
00150   }
00151 
00152   // DOM property: gradientTransform ,  #IMPLIED attrib: gradientTransform
00153   {
00154     nsCOMPtr<nsIDOMSVGTransformList> transformList;
00155     rv = nsSVGTransformList::Create(getter_AddRefs(transformList));
00156     NS_ENSURE_SUCCESS(rv,rv);
00157     rv = NS_NewSVGAnimatedTransformList(getter_AddRefs(mGradientTransform),
00158                                         transformList);
00159     NS_ENSURE_SUCCESS(rv,rv);
00160     rv = AddMappedSVGValue(nsSVGAtoms::gradientTransform, mGradientTransform);
00161     NS_ENSURE_SUCCESS(rv,rv);
00162   }
00163 
00164   // DOM property: spreadMethod ,  #IMPLIED  attrib: spreadMethod
00165   {
00166     nsCOMPtr<nsISVGEnum> spread;
00167     rv = NS_NewSVGEnum(getter_AddRefs(spread), 
00168                        nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD, gSpreadMap );
00169     NS_ENSURE_SUCCESS(rv,rv);
00170     rv = NS_NewSVGAnimatedEnumeration(getter_AddRefs(mSpreadMethod), spread);
00171     NS_ENSURE_SUCCESS(rv,rv);
00172     rv = AddMappedSVGValue(nsSVGAtoms::spreadMethod, mSpreadMethod);
00173     NS_ENSURE_SUCCESS(rv,rv);
00174   }
00175 
00176   // nsIDOMSVGURIReference properties
00177 
00178   // DOM property: href , #IMPLIED attrib: xlink:href
00179   {
00180     rv = NS_NewSVGAnimatedString(getter_AddRefs(mHref));
00181     NS_ENSURE_SUCCESS(rv,rv);
00182     rv = AddMappedSVGValue(nsSVGAtoms::href, mHref, kNameSpaceID_XLink);
00183     NS_ENSURE_SUCCESS(rv,rv);
00184   }
00185 
00186   return NS_OK;
00187 }
00188 
00189 //----------------------------------------------------------------------
00190 // nsIDOMSVGGradientElement methods
00191 
00192 /* readonly attribute nsIDOMSVGAnimatedEnumeration gradientUnits; */
00193 NS_IMETHODIMP nsSVGGradientElement::GetGradientUnits(nsIDOMSVGAnimatedEnumeration * *aGradientUnits)
00194 {
00195   *aGradientUnits = mGradientUnits;
00196   NS_IF_ADDREF(*aGradientUnits);
00197   return NS_OK;
00198 }
00199 
00200 /* readonly attribute nsIDOMSVGAnimatedTransformList gradientTransform; */
00201 NS_IMETHODIMP nsSVGGradientElement::GetGradientTransform(nsIDOMSVGAnimatedTransformList * *aGradientTransform)
00202 {
00203   *aGradientTransform = mGradientTransform;
00204   NS_IF_ADDREF(*aGradientTransform);
00205   return NS_OK;
00206 }
00207 
00208 /* readonly attribute nsIDOMSVGAnimatedEnumeration spreadMethod; */
00209 NS_IMETHODIMP nsSVGGradientElement::GetSpreadMethod(nsIDOMSVGAnimatedEnumeration * *aSpreadMethod)
00210 {
00211   *aSpreadMethod = mSpreadMethod;
00212   NS_IF_ADDREF(*aSpreadMethod);
00213   return NS_OK;
00214 }
00215 
00216 //----------------------------------------------------------------------
00217 // nsIDOMSVGURIReference methods:
00218 
00219 /* readonly attribute nsIDOMSVGAnimatedString href; */
00220 NS_IMETHODIMP
00221 nsSVGGradientElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
00222 {
00223   *aHref = mHref;
00224   NS_IF_ADDREF(*aHref);
00225   return NS_OK;
00226 }
00227 
00228 //----------------------------------------------------------------------
00229 // nsISVGContent methods
00230 
00231 void nsSVGGradientElement::ParentChainChanged()
00232 {
00233   // Gradient length properties are relative to the target element
00234   // (the one calling the gradient), so we don't set their
00235   // contexts here.
00236   // Also, gradient child elements (stops) don't have any length
00237   // properties, so no need to recurse into children here.
00238 }  
00239 
00240 //----------------------------------------------------------------------
00241 // nsIStyledContent methods
00242 
00243 NS_IMETHODIMP_(PRBool)
00244 nsSVGGradientElement::IsAttributeMapped(const nsIAtom* name) const
00245 {
00246   static const MappedAttributeEntry* const map[] = {
00247     sGradientStopMap,
00248     sColorMap
00249   };
00250   
00251   return FindAttributeDependence(name, map, NS_ARRAY_LENGTH(map)) ||
00252     nsSVGGradientElementBase::IsAttributeMapped(name);
00253 }
00254 
00255 //---------------------Linear Gradients------------------------
00256 
00257 typedef nsSVGGradientElement nsSVGLinearGradientElementBase;
00258 
00259 class nsSVGLinearGradientElement : public nsSVGLinearGradientElementBase,
00260                                    public nsIDOMSVGLinearGradientElement
00261 {
00262 protected:
00263   friend nsresult NS_NewSVGLinearGradientElement(nsIContent **aResult,
00264                                                  nsINodeInfo *aNodeInfo);
00265   nsSVGLinearGradientElement(nsINodeInfo* aNodeInfo);
00266   virtual ~nsSVGLinearGradientElement();
00267   nsresult Init();
00268 
00269 public:
00270   // interfaces:
00271   NS_DECL_ISUPPORTS_INHERITED
00272 
00273   // Gradient Element
00274   NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(nsSVGLinearGradientElementBase::)
00275 
00276   // Linear Gradient
00277   NS_DECL_NSIDOMSVGLINEARGRADIENTELEMENT
00278 
00279   // The Gradient Element base class implements these
00280   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLinearGradientElementBase::)
00281 
00282   NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGLinearGradientElementBase::)
00283   NS_FORWARD_NSIDOMELEMENT(nsSVGLinearGradientElementBase::)
00284 
00285 protected:
00286   
00287   // nsIDOMSVGLinearGradientElement values
00288   nsCOMPtr<nsIDOMSVGAnimatedLength> mX1;
00289   nsCOMPtr<nsIDOMSVGAnimatedLength> mY1;
00290   nsCOMPtr<nsIDOMSVGAnimatedLength> mX2;
00291   nsCOMPtr<nsIDOMSVGAnimatedLength> mY2;
00292 };
00293 
00294 NS_IMPL_NS_NEW_SVG_ELEMENT(LinearGradient)
00295 
00296 //----------------------------------------------------------------------
00297 // nsISupports methods
00298 
00299 NS_IMPL_ADDREF_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
00300 NS_IMPL_RELEASE_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
00301 
00302 NS_INTERFACE_MAP_BEGIN(nsSVGLinearGradientElement)
00303   NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
00304   NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
00305   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
00306   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGGradientElement)
00307   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
00308   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGLinearGradientElement)
00309 NS_INTERFACE_MAP_END_INHERITING(nsSVGLinearGradientElementBase)
00310 
00311 //----------------------------------------------------------------------
00312 // Implementation
00313 
00314 nsSVGLinearGradientElement::nsSVGLinearGradientElement(nsINodeInfo* aNodeInfo)
00315   : nsSVGLinearGradientElementBase(aNodeInfo)
00316 {
00317 
00318 }
00319 
00320 nsSVGLinearGradientElement::~nsSVGLinearGradientElement()
00321 {
00322 }
00323 
00324 
00325 nsresult
00326 nsSVGLinearGradientElement::Init()
00327 {
00328   nsresult rv = nsSVGLinearGradientElementBase::Init();
00329   NS_ENSURE_SUCCESS(rv,rv);
00330 
00331   // DOM property: x1 ,  #IMPLIED attrib: x1
00332   {
00333     nsCOMPtr<nsISVGLength> length;
00334     rv = NS_NewSVGLength(getter_AddRefs(length),
00335                          0.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00336     NS_ENSURE_SUCCESS(rv,rv);
00337     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mX1), length);
00338     NS_ENSURE_SUCCESS(rv,rv);
00339     rv = AddMappedSVGValue(nsSVGAtoms::x1, mX1);
00340     NS_ENSURE_SUCCESS(rv,rv);
00341   }
00342 
00343   // DOM property: y1 ,  #IMPLIED attrib: y1
00344   {
00345     nsCOMPtr<nsISVGLength> length;
00346     rv = NS_NewSVGLength(getter_AddRefs(length),
00347                          0.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00348     NS_ENSURE_SUCCESS(rv,rv);
00349     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mY1), length);
00350     NS_ENSURE_SUCCESS(rv,rv);
00351     rv = AddMappedSVGValue(nsSVGAtoms::y1, mY1);
00352     NS_ENSURE_SUCCESS(rv,rv);
00353   }
00354 
00355   // DOM property: x2 ,  #IMPLIED  attrib: x2
00356   {
00357     nsCOMPtr<nsISVGLength> length;
00358     rv = NS_NewSVGLength(getter_AddRefs(length),
00359                          100.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00360     NS_ENSURE_SUCCESS(rv,rv);
00361     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mX2), length);
00362     NS_ENSURE_SUCCESS(rv,rv);
00363     rv = AddMappedSVGValue(nsSVGAtoms::x2, mX2);
00364     NS_ENSURE_SUCCESS(rv,rv);
00365   }
00366 
00367   // DOM property: y2 ,  #IMPLIED  attrib: height
00368   {
00369     nsCOMPtr<nsISVGLength> length;
00370     rv = NS_NewSVGLength(getter_AddRefs(length),
00371                          0.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00372     NS_ENSURE_SUCCESS(rv,rv);
00373     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mY2), length);
00374     NS_ENSURE_SUCCESS(rv,rv);
00375     rv = AddMappedSVGValue(nsSVGAtoms::y2, mY2);
00376     NS_ENSURE_SUCCESS(rv,rv);
00377   }
00378 
00379   return NS_OK;
00380 }
00381 
00382 //----------------------------------------------------------------------
00383 // nsIDOMNode methods
00384 
00385 NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGLinearGradientElement)
00386 
00387 //----------------------------------------------------------------------
00388 // nsIDOMSVGLinearGradientElement methods
00389 
00390 /* readonly attribute nsIDOMSVGAnimatedLength x1; */
00391 NS_IMETHODIMP nsSVGLinearGradientElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
00392 {
00393   *aX1 = mX1;
00394   NS_IF_ADDREF(*aX1);
00395   return NS_OK;
00396 }
00397 
00398 /* readonly attribute nsIDOMSVGAnimatedLength y1; */
00399 NS_IMETHODIMP nsSVGLinearGradientElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
00400 {
00401   *aY1 = mY1;
00402   NS_IF_ADDREF(*aY1);
00403   return NS_OK;
00404 }
00405 
00406 /* readonly attribute nsIDOMSVGAnimatedLength x2; */
00407 NS_IMETHODIMP nsSVGLinearGradientElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
00408 {
00409   *aX2 = mX2;
00410   NS_IF_ADDREF(*aX2);
00411   return NS_OK;
00412 }
00413 
00414 /* readonly attribute nsIDOMSVGAnimatedLength y2; */
00415 NS_IMETHODIMP nsSVGLinearGradientElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
00416 {
00417   *aY2 = mY2;
00418   NS_IF_ADDREF(*aY2);
00419   return NS_OK;
00420 }
00421 
00422 //----------------------------------------------------------------------
00423 // nsISVGContent methods
00424 
00425 //-------------------------- Radial Gradients ----------------------------
00426 
00427 typedef nsSVGGradientElement nsSVGRadialGradientElementBase;
00428 
00429 class nsSVGRadialGradientElement : public nsSVGRadialGradientElementBase,
00430                                    public nsIDOMSVGRadialGradientElement
00431 {
00432 protected:
00433   friend nsresult NS_NewSVGRadialGradientElement(nsIContent **aResult,
00434                                                  nsINodeInfo *aNodeInfo);
00435   nsSVGRadialGradientElement(nsINodeInfo* aNodeInfo);
00436   virtual ~nsSVGRadialGradientElement();
00437   nsresult Init();
00438 
00439 public:
00440   // interfaces:
00441 
00442   NS_DECL_ISUPPORTS_INHERITED
00443 
00444   // Gradient Element
00445   NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(nsSVGRadialGradientElementBase::)
00446 
00447   // Radial Gradient
00448   NS_DECL_NSIDOMSVGRADIALGRADIENTELEMENT
00449 
00450   // xxx I wish we could use virtual inheritance
00451   NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGRadialGradientElementBase::)
00452   NS_FORWARD_NSIDOMELEMENT(nsSVGRadialGradientElementBase::)
00453   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRadialGradientElementBase::)
00454 
00455 protected:
00456   
00457   // nsIDOMSVGRadialGradientElement values
00458   nsCOMPtr<nsIDOMSVGAnimatedLength> mCx;
00459   nsCOMPtr<nsIDOMSVGAnimatedLength> mCy;
00460   nsCOMPtr<nsIDOMSVGAnimatedLength> mR;
00461   nsCOMPtr<nsIDOMSVGAnimatedLength> mFx;
00462   nsCOMPtr<nsIDOMSVGAnimatedLength> mFy;
00463 };
00464 
00465 NS_IMPL_NS_NEW_SVG_ELEMENT(RadialGradient)
00466 
00467 //----------------------------------------------------------------------
00468 // nsISupports methods
00469 
00470 NS_IMPL_ADDREF_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
00471 NS_IMPL_RELEASE_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
00472 
00473 NS_INTERFACE_MAP_BEGIN(nsSVGRadialGradientElement)
00474   NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
00475   NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
00476   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
00477   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGGradientElement)
00478   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
00479   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGRadialGradientElement)
00480 NS_INTERFACE_MAP_END_INHERITING(nsSVGRadialGradientElementBase)
00481 
00482 //----------------------------------------------------------------------
00483 // Implementation
00484 
00485 nsSVGRadialGradientElement::nsSVGRadialGradientElement(nsINodeInfo* aNodeInfo)
00486   : nsSVGRadialGradientElementBase(aNodeInfo)
00487 {
00488 
00489 }
00490 
00491 nsSVGRadialGradientElement::~nsSVGRadialGradientElement()
00492 {
00493 }
00494 
00495 
00496 nsresult
00497 nsSVGRadialGradientElement::Init()
00498 {
00499   nsresult rv = nsSVGRadialGradientElementBase::Init();
00500   NS_ENSURE_SUCCESS(rv,rv);
00501 
00502   // Create mapped properties:
00503 
00504   // DOM property: cx ,  #IMPLIED attrib: cx
00505   {
00506     nsCOMPtr<nsISVGLength> length;
00507     rv = NS_NewSVGLength(getter_AddRefs(length),
00508                          50.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00509     NS_ENSURE_SUCCESS(rv,rv);
00510     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mCx), length);
00511     NS_ENSURE_SUCCESS(rv,rv);
00512     rv = AddMappedSVGValue(nsSVGAtoms::cx, mCx);
00513     NS_ENSURE_SUCCESS(rv,rv);
00514   }
00515 
00516   // DOM property: cy ,  #IMPLIED attrib: cy
00517   {
00518     nsCOMPtr<nsISVGLength> length;
00519     rv = NS_NewSVGLength(getter_AddRefs(length),
00520                          50.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00521     NS_ENSURE_SUCCESS(rv,rv);
00522     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mCy), length);
00523     NS_ENSURE_SUCCESS(rv,rv);
00524     rv = AddMappedSVGValue(nsSVGAtoms::cy, mCy);
00525     NS_ENSURE_SUCCESS(rv,rv);
00526   }
00527 
00528   // DOM property: r ,  #IMPLIED  attrib: r
00529   {
00530     nsCOMPtr<nsISVGLength> length;
00531     rv = NS_NewSVGLength(getter_AddRefs(length),
00532                          50.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00533     NS_ENSURE_SUCCESS(rv,rv);
00534     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mR), length);
00535     NS_ENSURE_SUCCESS(rv,rv);
00536     rv = AddMappedSVGValue(nsSVGAtoms::r, mR);
00537     NS_ENSURE_SUCCESS(rv,rv);
00538   }
00539 
00540   // DOM property: fx ,  #IMPLIED  attrib: fx
00541   {
00542     nsCOMPtr<nsISVGLength> length;
00543     rv = NS_NewSVGLength(getter_AddRefs(length),
00544                          50.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00545     NS_ENSURE_SUCCESS(rv,rv);
00546     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mFx), length);
00547     NS_ENSURE_SUCCESS(rv,rv);
00548     rv = AddMappedSVGValue(nsSVGAtoms::fx, mFx);
00549     NS_ENSURE_SUCCESS(rv,rv);
00550   }
00551 
00552   // DOM property: fy ,  #IMPLIED  attrib: fy
00553   {
00554     nsCOMPtr<nsISVGLength> length;
00555     rv = NS_NewSVGLength(getter_AddRefs(length),
00556                          50.0,nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
00557     NS_ENSURE_SUCCESS(rv,rv);
00558     rv = NS_NewSVGAnimatedLength(getter_AddRefs(mFy), length);
00559     NS_ENSURE_SUCCESS(rv,rv);
00560     rv = AddMappedSVGValue(nsSVGAtoms::fy, mFy);
00561     NS_ENSURE_SUCCESS(rv,rv);
00562   }
00563 
00564   return NS_OK;
00565 }
00566 
00567 //----------------------------------------------------------------------
00568 // nsIDOMNode methods
00569 
00570 NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGRadialGradientElement)
00571 
00572 //----------------------------------------------------------------------
00573 // nsIDOMSVGRadialGradientElement methods
00574 
00575 /* readonly attribute nsIDOMSVGAnimatedLength cx; */
00576 NS_IMETHODIMP nsSVGRadialGradientElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
00577 {
00578   *aCx = mCx;
00579   NS_IF_ADDREF(*aCx);
00580   return NS_OK;
00581 }
00582 
00583 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
00584 NS_IMETHODIMP nsSVGRadialGradientElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
00585 {
00586   *aCy = mCy;
00587   NS_IF_ADDREF(*aCy);
00588   return NS_OK;
00589 }
00590 
00591 /* readonly attribute nsIDOMSVGAnimatedLength R; */
00592 NS_IMETHODIMP nsSVGRadialGradientElement::GetR(nsIDOMSVGAnimatedLength * *aR)
00593 {
00594   *aR = mR;
00595   NS_IF_ADDREF(*aR);
00596   return NS_OK;
00597 }
00598 
00599 /* readonly attribute nsIDOMSVGAnimatedLength fx; */
00600 NS_IMETHODIMP nsSVGRadialGradientElement::GetFx(nsIDOMSVGAnimatedLength * *aFx)
00601 {
00602   *aFx = mFx;
00603   NS_IF_ADDREF(*aFx);
00604   return NS_OK;
00605 }
00606 
00607 /* readonly attribute nsIDOMSVGAnimatedLength fy; */
00608 NS_IMETHODIMP nsSVGRadialGradientElement::GetFy(nsIDOMSVGAnimatedLength * *aFy)
00609 {
00610   *aFy = mFy;
00611   NS_IF_ADDREF(*aFy);
00612   return NS_OK;
00613 }
00614 
00615