Bug 825749 - Convert SVG gradient elements to WebIDL; r=bz
authorMs2ger <ms2ger@gmail.com>
Fri, 11 Jan 2013 09:43:01 +0100
changeset 118374 84ad8539acfd77740cec3fb6dc11648f3a070283
parent 118373 1f06b6661df73867e1e122c95cc82c22c33f3f1e
child 118375 5b3c75e859d958d50952b4382728d5d58b24065a
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs825749
milestone21.0a1
Bug 825749 - Convert SVG gradient elements to WebIDL; r=bz
content/svg/content/src/Makefile.in
content/svg/content/src/SVGGradientElement.cpp
content/svg/content/src/SVGGradientElement.h
content/svg/content/src/nsSVGGradientElement.cpp
content/svg/content/src/nsSVGGradientElement.h
dom/bindings/Bindings.conf
dom/webidl/SVGGradientElement.webidl
dom/webidl/SVGLinearGradientElement.webidl
dom/webidl/SVGRadialGradientElement.webidl
dom/webidl/SVGUnitTypes.webidl
dom/webidl/WebIDL.mk
layout/svg/nsSVGGradientFrame.cpp
layout/svg/nsSVGGradientFrame.h
--- a/content/svg/content/src/Makefile.in
+++ b/content/svg/content/src/Makefile.in
@@ -42,17 +42,16 @@ CPPSRCS		= \
 		nsSVGClipPathElement.cpp \
 		nsSVGDataParser.cpp \
 		nsSVGElement.cpp \
 		nsSVGElementFactory.cpp \
 		nsSVGEnum.cpp \
 		nsSVGFeatures.cpp \
 		nsSVGFilterElement.cpp \
 		nsSVGFilters.cpp \
-		nsSVGGradientElement.cpp \
 		nsSVGInteger.cpp \
 		nsSVGIntegerPair.cpp \
 		nsSVGLength2.cpp \
 		nsSVGMarkerElement.cpp \
 		nsSVGMaskElement.cpp \
 		nsSVGNumber2.cpp \
 		nsSVGNumberPair.cpp \
 		nsSVGPathDataParser.cpp \
@@ -85,16 +84,17 @@ CPPSRCS		= \
 		SVGCircleElement.cpp \
 		SVGContentUtils.cpp \
 		SVGDefsElement.cpp \
 		SVGDescElement.cpp \
 		SVGEllipseElement.cpp \
 		SVGForeignObjectElement.cpp \
 		SVGFragmentIdentifier.cpp \
 		SVGGElement.cpp \
+		SVGGradientElement.cpp \
 		SVGGraphicsElement.cpp \
 		SVGImageElement.cpp \
 		SVGIntegerPairSMILType.cpp \
 		SVGLength.cpp \
 		SVGLengthList.cpp \
 		SVGLengthListSMILType.cpp \
 		SVGLineElement.cpp \
 		SVGLocatableElement.cpp \
@@ -163,16 +163,17 @@ EXPORTS_mozilla/dom = \
 	SVGAnimateMotionElement.h \
 	SVGAnimationElement.h \
 	SVGCircleElement.h \
 	SVGDefsElement.h \
 	SVGDescElement.h \
 	SVGEllipseElement.h \
 	SVGForeignObjectElement.h \
 	SVGGElement.h \
+	SVGGradientElement.h \
 	SVGGraphicsElement.h \
 	SVGImageElement.h \
 	SVGLineElement.h \
 	SVGLocatableElement.h \
 	SVGMetadataElement.h \
 	SVGMPathElement.h \
 	SVGPolygonElement.h \
 	SVGPolylineElement.h \
rename from content/svg/content/src/nsSVGGradientElement.cpp
rename to content/svg/content/src/SVGGradientElement.cpp
--- a/content/svg/content/src/nsSVGGradientElement.cpp
+++ b/content/svg/content/src/SVGGradientElement.cpp
@@ -1,303 +1,414 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/Util.h"
+#include "mozilla/dom/SVGGradientElement.h"
 
 #include "DOMSVGAnimatedTransformList.h"
-#include "nsIDOMSVGAnimatedEnum.h"
-#include "nsIDOMSVGURIReference.h"
-#include "nsIDOMSVGGradientElement.h"
-#include "nsIDOMMutationEvent.h"
+#include "mozilla/dom/SVGRadialGradientElementBinding.h"
+#include "mozilla/dom/SVGLinearGradientElementBinding.h"
+#include "mozilla/Util.h"
 #include "nsCOMPtr.h"
+#include "nsGkAtoms.h"
+#include "nsIDOMMutationEvent.h"
+#include "nsIDOMSVGAnimatedEnum.h"
+#include "nsIDOMSVGGradientElement.h"
+#include "nsIDOMSVGURIReference.h"
 #include "nsSVGElement.h"
-#include "nsGkAtoms.h"
-#include "nsSVGGradientElement.h"
+
+DOMCI_NODE_DATA(SVGRadialGradientElement, mozilla::dom::SVGRadialGradientElement)
+DOMCI_NODE_DATA(SVGLinearGradientElement, mozilla::dom::SVGLinearGradientElement)
 
-using namespace mozilla;
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(LinearGradient)
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(RadialGradient)
+
+namespace mozilla {
+namespace dom {
 
 //--------------------- Gradients------------------------
 
-nsSVGEnumMapping nsSVGGradientElement::sSpreadMethodMap[] = {
+nsSVGEnumMapping SVGGradientElement::sSpreadMethodMap[] = {
   {&nsGkAtoms::pad, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD},
   {&nsGkAtoms::reflect, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT},
   {&nsGkAtoms::repeat, nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT},
   {nullptr, 0}
 };
 
-nsSVGElement::EnumInfo nsSVGGradientElement::sEnumInfo[2] =
+nsSVGElement::EnumInfo SVGGradientElement::sEnumInfo[2] =
 {
   { &nsGkAtoms::gradientUnits,
     sSVGUnitTypesMap,
     nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
   },
   { &nsGkAtoms::spreadMethod,
     sSpreadMethodMap,
     nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD
   }
 };
 
-nsSVGElement::StringInfo nsSVGGradientElement::sStringInfo[1] =
+nsSVGElement::StringInfo SVGGradientElement::sStringInfo[1] =
 {
   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
 };
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGGradientElement,nsSVGGradientElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGGradientElement, SVGGradientElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGGradientElement, SVGGradientElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGGradientElement)
+NS_INTERFACE_MAP_BEGIN(SVGGradientElement)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGGradientElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGGradientElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGGradientElement::nsSVGGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGGradientElementBase(aNodeInfo)
+SVGGradientElement::SVGGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGGradientElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 nsSVGElement::EnumAttributesInfo
-nsSVGGradientElement::GetEnumInfo()
+SVGGradientElement::GetEnumInfo()
 {
   return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
                             ArrayLength(sEnumInfo));
 }
 
 nsSVGElement::StringAttributesInfo
-nsSVGGradientElement::GetStringInfo()
+SVGGradientElement::GetStringInfo()
 {
   return StringAttributesInfo(mStringAttributes, sStringInfo,
                               ArrayLength(sStringInfo));
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGGradientElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedEnumeration gradientUnits; */
-NS_IMETHODIMP nsSVGGradientElement::GetGradientUnits(nsIDOMSVGAnimatedEnumeration * *aGradientUnits)
+already_AddRefed<nsIDOMSVGAnimatedEnumeration>
+SVGGradientElement::GradientUnits()
 {
-  return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(aGradientUnits, this);
+  return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(this);
 }
 
-/* readonly attribute nsISupports gradientTransform; */
-NS_IMETHODIMP nsSVGGradientElement::GetGradientTransform(nsISupports * *aGradientTransform)
+NS_IMETHODIMP SVGGradientElement::GetGradientUnits(nsIDOMSVGAnimatedEnumeration * *aGradientUnits)
+{
+  *aGradientUnits = GradientUnits().get();
+  return NS_OK;
+}
+
+/* readonly attribute SVGAnimatedTransformList gradientTransform; */
+already_AddRefed<DOMSVGAnimatedTransformList>
+SVGGradientElement::GradientTransform()
 {
   // We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
   // to allocate the SVGAnimatedTransformList if it hasn't already done so:
-  *aGradientTransform = DOMSVGAnimatedTransformList::GetDOMWrapper(
-                          GetAnimatedTransformList(DO_ALLOCATE), this).get();
+  return DOMSVGAnimatedTransformList::GetDOMWrapper(
+           GetAnimatedTransformList(DO_ALLOCATE), this);
+}
+
+NS_IMETHODIMP SVGGradientElement::GetGradientTransform(nsISupports * *aGradientTransform)
+{
+  *aGradientTransform = GradientTransform().get();
   return NS_OK;
 }
 
 /* readonly attribute nsIDOMSVGAnimatedEnumeration spreadMethod; */
-NS_IMETHODIMP nsSVGGradientElement::GetSpreadMethod(nsIDOMSVGAnimatedEnumeration * *aSpreadMethod)
+already_AddRefed<nsIDOMSVGAnimatedEnumeration>
+SVGGradientElement::SpreadMethod()
 {
-  return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(aSpreadMethod, this);
+  return mEnumAttributes[SPREADMETHOD].ToDOMAnimatedEnum(this);
+}
+
+NS_IMETHODIMP SVGGradientElement::GetSpreadMethod(nsIDOMSVGAnimatedEnumeration * *aSpreadMethod)
+{
+  *aSpreadMethod = SpreadMethod().get();
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGURIReference methods:
 
 /* readonly attribute nsIDOMSVGAnimatedString href; */
+already_AddRefed<nsIDOMSVGAnimatedString>
+SVGGradientElement::Href()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedString> href;
+  mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
+  return href.forget();
+}
+
 NS_IMETHODIMP
-nsSVGGradientElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
+SVGGradientElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
 {
-  return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
+  *aHref = Href().get();
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGGradientElement::IsAttributeMapped(const nsIAtom* name) const
+SVGGradientElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sColorMap,
     sGradientStopMap
   };
   
   return FindAttributeDependence(name, map) ||
-    nsSVGGradientElementBase::IsAttributeMapped(name);
+    SVGGradientElementBase::IsAttributeMapped(name);
 }
 
 //---------------------Linear Gradients------------------------
 
-nsSVGElement::LengthInfo nsSVGLinearGradientElement::sLengthInfo[4] =
+JSObject*
+SVGLinearGradientElement::WrapNode(JSContext* aCx, JSObject* aScope,
+                                   bool* aTriedToWrap)
+{
+  return SVGLinearGradientElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
+nsSVGElement::LengthInfo SVGLinearGradientElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
   { &nsGkAtoms::x2, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(LinearGradient)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGLinearGradientElement,SVGLinearGradientElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGLinearGradientElement,SVGLinearGradientElementBase)
 
-DOMCI_NODE_DATA(SVGLinearGradientElement, nsSVGLinearGradientElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGLinearGradientElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGLinearGradientElement, nsIDOMNode,
+NS_INTERFACE_TABLE_HEAD(SVGLinearGradientElement)
+  NS_NODE_INTERFACE_TABLE5(SVGLinearGradientElement, nsIDOMNode,
                            nsIDOMElement, nsIDOMSVGElement,
                            nsIDOMSVGGradientElement,
                            nsIDOMSVGLinearGradientElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLinearGradientElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGLinearGradientElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGLinearGradientElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGLinearGradientElement::nsSVGLinearGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGLinearGradientElementBase(aNodeInfo)
+SVGLinearGradientElement::SVGLinearGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGLinearGradientElementBase(aNodeInfo)
 {
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGLinearGradientElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGLinearGradientElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGLinearGradientElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength x1; */
-NS_IMETHODIMP nsSVGLinearGradientElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
+NS_IMETHODIMP SVGLinearGradientElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
 {
-  return mLengthAttributes[X1].ToDOMAnimatedLength(aX1, this);
+  *aX1 = X1().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLinearGradientElement::X1()
+{
+  return mLengthAttributes[ATTR_X1].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y1; */
-NS_IMETHODIMP nsSVGLinearGradientElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
+NS_IMETHODIMP SVGLinearGradientElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
 {
-  return mLengthAttributes[Y1].ToDOMAnimatedLength(aY1, this);
+  *aY1 = Y1().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLinearGradientElement::Y1()
+{
+  return mLengthAttributes[ATTR_Y1].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength x2; */
-NS_IMETHODIMP nsSVGLinearGradientElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
+NS_IMETHODIMP SVGLinearGradientElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
 {
-  return mLengthAttributes[X2].ToDOMAnimatedLength(aX2, this);
+  *aX2 = X2().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLinearGradientElement::X2()
+{
+  return mLengthAttributes[ATTR_X2].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y2; */
-NS_IMETHODIMP nsSVGLinearGradientElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
+NS_IMETHODIMP SVGLinearGradientElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
 {
-  return mLengthAttributes[Y2].ToDOMAnimatedLength(aY2, this);
+  *aY2 = Y2().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLinearGradientElement::Y2()
+{
+  return mLengthAttributes[ATTR_Y2].ToDOMAnimatedLength(this);
 }
 
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 SVGAnimatedTransformList*
-nsSVGGradientElement::GetAnimatedTransformList(uint32_t aFlags)
+SVGGradientElement::GetAnimatedTransformList(uint32_t aFlags)
 {
   if (!mGradientTransform && (aFlags & DO_ALLOCATE)) {
     mGradientTransform = new SVGAnimatedTransformList();
   }
   return mGradientTransform;
 }
 
 nsSVGElement::LengthAttributesInfo
-nsSVGLinearGradientElement::GetLengthInfo()
+SVGLinearGradientElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 //-------------------------- Radial Gradients ----------------------------
 
-nsSVGElement::LengthInfo nsSVGRadialGradientElement::sLengthInfo[5] =
+JSObject*
+SVGRadialGradientElement::WrapNode(JSContext* aCx, JSObject* aScope,
+                                   bool* aTriedToWrap)
+{
+  return SVGRadialGradientElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
+nsSVGElement::LengthInfo SVGRadialGradientElement::sLengthInfo[5] =
 {
   { &nsGkAtoms::cx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::cy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
   { &nsGkAtoms::r, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY },
   { &nsGkAtoms::fx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::fy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(RadialGradient)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGRadialGradientElement, SVGRadialGradientElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGRadialGradientElement, SVGRadialGradientElementBase)
 
-DOMCI_NODE_DATA(SVGRadialGradientElement, nsSVGRadialGradientElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGRadialGradientElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGRadialGradientElement, nsIDOMNode,
+NS_INTERFACE_TABLE_HEAD(SVGRadialGradientElement)
+  NS_NODE_INTERFACE_TABLE5(SVGRadialGradientElement, nsIDOMNode,
                            nsIDOMElement, nsIDOMSVGElement,
                            nsIDOMSVGGradientElement,
                            nsIDOMSVGRadialGradientElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRadialGradientElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGRadialGradientElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGRadialGradientElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGRadialGradientElement::nsSVGRadialGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGRadialGradientElementBase(aNodeInfo)
+SVGRadialGradientElement::SVGRadialGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGRadialGradientElementBase(aNodeInfo)
 {
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRadialGradientElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGRadialGradientElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGRadialGradientElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGRadialGradientElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
+NS_IMETHODIMP SVGRadialGradientElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
 {
-  return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
+  *aCx = Cx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRadialGradientElement::Cx()
+{
+  return mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGRadialGradientElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
+NS_IMETHODIMP SVGRadialGradientElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
 {
-  return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
+  *aCy = Cy().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRadialGradientElement::Cy()
+{
+  return mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(this);
 }
 
-/* readonly attribute nsIDOMSVGAnimatedLength R; */
-NS_IMETHODIMP nsSVGRadialGradientElement::GetR(nsIDOMSVGAnimatedLength * *aR)
+/* readonly attribute nsIDOMSVGAnimatedLength r; */
+NS_IMETHODIMP SVGRadialGradientElement::GetR(nsIDOMSVGAnimatedLength * *aR)
 {
-  return mLengthAttributes[R].ToDOMAnimatedLength(aR, this);
+  *aR = R().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRadialGradientElement::R()
+{
+  return mLengthAttributes[ATTR_R].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength fx; */
-NS_IMETHODIMP nsSVGRadialGradientElement::GetFx(nsIDOMSVGAnimatedLength * *aFx)
+NS_IMETHODIMP SVGRadialGradientElement::GetFx(nsIDOMSVGAnimatedLength * *aFx)
 {
-  return mLengthAttributes[FX].ToDOMAnimatedLength(aFx, this);
+  *aFx = Fx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRadialGradientElement::Fx()
+{
+  return mLengthAttributes[ATTR_FX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength fy; */
-NS_IMETHODIMP nsSVGRadialGradientElement::GetFy(nsIDOMSVGAnimatedLength * *aFy)
+NS_IMETHODIMP SVGRadialGradientElement::GetFy(nsIDOMSVGAnimatedLength * *aFy)
 {
-  return mLengthAttributes[FY].ToDOMAnimatedLength(aFy, this);
+  *aFy = Fy().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRadialGradientElement::Fy()
+{
+  return mLengthAttributes[ATTR_FY].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 nsSVGElement::LengthAttributesInfo
-nsSVGRadialGradientElement::GetLengthInfo()
+SVGRadialGradientElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
+
+} // namespace dom
+} // namespace mozilla
rename from content/svg/content/src/nsSVGGradientElement.h
rename to content/svg/content/src/SVGGradientElement.h
--- a/content/svg/content/src/nsSVGGradientElement.h
+++ b/content/svg/content/src/SVGGradientElement.h
@@ -10,148 +10,196 @@
 #include "nsIDOMSVGGradientElement.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "nsSVGElement.h"
 #include "nsSVGLength2.h"
 #include "nsSVGEnum.h"
 #include "nsSVGString.h"
 #include "SVGAnimatedTransformList.h"
 
+class nsSVGGradientFrame;
+class nsSVGLinearGradientFrame;
+class nsSVGRadialGradientFrame;
+
+nsresult
+NS_NewSVGLinearGradientElement(nsIContent** aResult,
+                               already_AddRefed<nsINodeInfo> aNodeInfo);
+nsresult
+NS_NewSVGRadialGradientElement(nsIContent** aResult,
+                               already_AddRefed<nsINodeInfo> aNodeInfo);
+
+namespace mozilla {
+
+class DOMSVGAnimatedTransformList;
+
+namespace dom {
+
 //--------------------- Gradients------------------------
 
-typedef nsSVGElement nsSVGGradientElementBase;
+typedef nsSVGElement SVGGradientElementBase;
 
-class nsSVGGradientElement : public nsSVGGradientElementBase,
-                             public nsIDOMSVGURIReference,
-                             public nsIDOMSVGUnitTypes
+class SVGGradientElement : public SVGGradientElementBase
+                         , public nsIDOMSVGURIReference
+                         , public nsIDOMSVGUnitTypes
 {
-  friend class nsSVGGradientFrame;
+  friend class ::nsSVGGradientFrame;
 
 protected:
-  nsSVGGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject*
+  WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap) MOZ_OVERRIDE = 0;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
   // Gradient Element
   NS_DECL_NSIDOMSVGGRADIENTELEMENT
 
   // URI Reference
   NS_DECL_NSIDOMSVGURIREFERENCE
 
   // nsIContent
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
 
-  virtual mozilla::SVGAnimatedTransformList*
+  virtual SVGAnimatedTransformList*
     GetAnimatedTransformList(uint32_t aFlags = 0);
   virtual nsIAtom* GetTransformListAttrName() const {
     return nsGkAtoms::gradientTransform;
   }
 
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedEnumeration> GradientUnits();
+  already_AddRefed<DOMSVGAnimatedTransformList> GradientTransform();
+  already_AddRefed<nsIDOMSVGAnimatedEnumeration> SpreadMethod();
+  already_AddRefed<nsIDOMSVGAnimatedString> Href();
+
 protected:
   virtual EnumAttributesInfo GetEnumInfo();
   virtual StringAttributesInfo GetStringInfo();
 
   enum { GRADIENTUNITS, SPREADMETHOD };
   nsSVGEnum mEnumAttributes[2];
   static nsSVGEnumMapping sSpreadMethodMap[];
   static EnumInfo sEnumInfo[2];
 
   enum { HREF };
   nsSVGString mStringAttributes[1];
   static StringInfo sStringInfo[1];
 
   // nsIDOMSVGGradientElement values
-  nsAutoPtr<mozilla::SVGAnimatedTransformList> mGradientTransform;
+  nsAutoPtr<SVGAnimatedTransformList> mGradientTransform;
 };
 
 //---------------------Linear Gradients------------------------
 
-typedef nsSVGGradientElement nsSVGLinearGradientElementBase;
+typedef SVGGradientElement SVGLinearGradientElementBase;
 
-class nsSVGLinearGradientElement : public nsSVGLinearGradientElementBase,
-                                   public nsIDOMSVGLinearGradientElement
+class SVGLinearGradientElement : public SVGLinearGradientElementBase
+                               , public nsIDOMSVGLinearGradientElement
 {
-  friend class nsSVGLinearGradientFrame;
+  friend class ::nsSVGLinearGradientFrame;
+  friend nsresult
+    (::NS_NewSVGLinearGradientElement(nsIContent** aResult,
+                                      already_AddRefed<nsINodeInfo> aNodeInfo));
 
 protected:
-  friend nsresult NS_NewSVGLinearGradientElement(nsIContent **aResult,
-                                                 already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGLinearGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGLinearGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject*
+  WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
   // Gradient Element
-  NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(nsSVGLinearGradientElementBase::)
+  NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(SVGLinearGradientElementBase::)
 
   // Linear Gradient
   NS_DECL_NSIDOMSVGLINEARGRADIENTELEMENT
 
   // The Gradient Element base class implements these
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLinearGradientElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGLinearGradientElementBase::)
 
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> X1();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y1();
+  already_AddRefed<nsIDOMSVGAnimatedLength> X2();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y2();
+
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
 
   // nsIDOMSVGLinearGradientElement values
-  enum { X1, Y1, X2, Y2 };
+  enum { ATTR_X1, ATTR_Y1, ATTR_X2, ATTR_Y2 };
   nsSVGLength2 mLengthAttributes[4];
   static LengthInfo sLengthInfo[4];
 };
 
 //-------------------------- Radial Gradients ----------------------------
 
-typedef nsSVGGradientElement nsSVGRadialGradientElementBase;
+typedef SVGGradientElement SVGRadialGradientElementBase;
 
-class nsSVGRadialGradientElement : public nsSVGRadialGradientElementBase,
-                                   public nsIDOMSVGRadialGradientElement
+class SVGRadialGradientElement : public SVGRadialGradientElementBase
+                               , public nsIDOMSVGRadialGradientElement
 {
-  friend class nsSVGRadialGradientFrame;
+  friend class ::nsSVGRadialGradientFrame;
+  friend nsresult
+    (::NS_NewSVGRadialGradientElement(nsIContent** aResult,
+                                      already_AddRefed<nsINodeInfo> aNodeInfo));
 
 protected:
-  friend nsresult NS_NewSVGRadialGradientElement(nsIContent **aResult,
-                                                 already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGRadialGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGRadialGradientElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject*
+  WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Gradient Element
-  NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(nsSVGRadialGradientElementBase::)
+  NS_FORWARD_NSIDOMSVGGRADIENTELEMENT(SVGRadialGradientElementBase::)
 
   // Radial Gradient
   NS_DECL_NSIDOMSVGRADIALGRADIENTELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRadialGradientElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGRadialGradientElementBase::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> Cx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Cy();
+  already_AddRefed<nsIDOMSVGAnimatedLength> R();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Fx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Fy();
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
 
   // nsIDOMSVGRadialGradientElement values
-  enum { CX, CY, R, FX, FY };
+  enum { ATTR_CX, ATTR_CY, ATTR_R, ATTR_FX, ATTR_FY };
   nsSVGLength2 mLengthAttributes[5];
   static LengthInfo sLengthInfo[5];
 };
 
+} // namespace dom
+} // namespace mozilla
+
 #endif
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -624,32 +624,40 @@ DOMInterfaces = {
     'hasInstanceInterface': 'nsIDOMSVGElement',
     'resultNotAddRefed': ['ownerSVGElement', 'viewportElement', 'style']
 },
 
 'SVGGraphicsElement': {
     'hasXPConnectImpls': True,
 },
 
+'SVGGradientElement': {
+    'concrete': False,
+},
+
 'SVGImageElement': {
-  'hasInstanceInterface': 'nsIDOMSVGImageElement',
+    'hasInstanceInterface': 'nsIDOMSVGImageElement',
 },
 
 'SVGLocatableElement': {
     'hasXPConnectImpls': True,
     'concrete': False,
     'resultNotAddRefed': ['nearestViewportElement', 'farthestViewportElement']
 },
 
 'SVGLengthList': {
     'nativeType': 'mozilla::DOMSVGLengthList',
     'headerFile': 'DOMSVGLengthList.h',
     'resultNotAddRefed': [ 'getItem' ]
 },
 
+'SVGLinearGradientElement': {
+    'headerFile': 'mozilla/dom/SVGGradientElement.h',
+},
+
 'SVGMatrix': {
     'nativeType': 'mozilla::DOMSVGMatrix',
     'headerFile': 'DOMSVGMatrix.h'
 },
 
 'SVGNumberList': {
     'nativeType': 'mozilla::DOMSVGNumberList',
     'headerFile': 'DOMSVGNumberList.h',
@@ -774,16 +782,20 @@ DOMInterfaces = {
     'resultNotAddRefed': [ 'getItem' ]
 },
 
 'SVGPreserveAspectRatio': {
     'nativeType': 'mozilla::dom::DOMSVGPreserveAspectRatio',
     'headerFile': 'SVGPreserveAspectRatio.h'
 },
 
+'SVGRadialGradientElement': {
+    'headerFile': 'mozilla/dom/SVGGradientElement.h',
+},
+
 'SVGTextContentElement': {
     'concrete': False
 },
 
 'SVGTextPositioningElement': {
     'concrete': False
 },
 
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGGradientElement.webidl
@@ -0,0 +1,29 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * https://svgwg.org/svg2-draft/
+ *
+ * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * liability, trademark and document use rules apply.
+ */
+
+/* SVGDefinitionElement support is bug 825769. */
+
+interface SVGGradientElement /* : SVGDefinitionElement */ : SVGElement {
+
+  // Spread Method Types
+  const unsigned short SVG_SPREADMETHOD_UNKNOWN = 0;
+  const unsigned short SVG_SPREADMETHOD_PAD = 1;
+  const unsigned short SVG_SPREADMETHOD_REFLECT = 2;
+  const unsigned short SVG_SPREADMETHOD_REPEAT = 3;
+
+  readonly attribute SVGAnimatedEnumeration gradientUnits;
+  readonly attribute SVGAnimatedTransformList gradientTransform;
+  readonly attribute SVGAnimatedEnumeration spreadMethod;
+};
+
+SVGGradientElement implements SVGURIReference;
+SVGGradientElement implements SVGUnitTypes;
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGLinearGradientElement.webidl
@@ -0,0 +1,18 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * https://svgwg.org/svg2-draft/
+ *
+ * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * liability, trademark and document use rules apply.
+ */
+
+interface SVGLinearGradientElement : SVGGradientElement {
+  readonly attribute SVGAnimatedLength x1;
+  readonly attribute SVGAnimatedLength y1;
+  readonly attribute SVGAnimatedLength x2;
+  readonly attribute SVGAnimatedLength y2;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGRadialGradientElement.webidl
@@ -0,0 +1,20 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * https://svgwg.org/svg2-draft/
+ *
+ * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * liability, trademark and document use rules apply.
+ */
+
+interface SVGRadialGradientElement : SVGGradientElement {
+  readonly attribute SVGAnimatedLength cx;
+  readonly attribute SVGAnimatedLength cy;
+  readonly attribute SVGAnimatedLength r;
+  readonly attribute SVGAnimatedLength fx;
+  readonly attribute SVGAnimatedLength fy;
+  // readonly attribute SVGAnimatedLength fr;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGUnitTypes.webidl
@@ -0,0 +1,19 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * https://svgwg.org/svg2-draft/
+ *
+ * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * liability, trademark and document use rules apply.
+ */
+
+[NoInterfaceObject]
+interface SVGUnitTypes {
+  // Unit Types
+  const unsigned short SVG_UNIT_TYPE_UNKNOWN = 0;
+  const unsigned short SVG_UNIT_TYPE_USERSPACEONUSE = 1;
+  const unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -115,32 +115,35 @@ webidl_files = \
   SVGCircleElement.webidl \
   SVGDefsElement.webidl \
   SVGDescElement.webidl \
   SVGElement.webidl \
   SVGEllipseElement.webidl \
   SVGFitToViewBox.webidl \
   SVGForeignObjectElement.webidl \
   SVGGElement.webidl \
+  SVGGradientElement.webidl \
   SVGGraphicsElement.webidl \
   SVGImageElement.webidl \
   SVGLengthList.webidl \
+  SVGLinearGradientElement.webidl \
   SVGLineElement.webidl \
   SVGLocatableElement.webidl \
   SVGMatrix.webidl \
   SVGMetadataElement.webidl \
   SVGMPathElement.webidl \
   SVGNumberList.webidl \
   SVGPathSeg.webidl \
   SVGPathSegList.webidl \
   SVGPoint.webidl \
   SVGPointList.webidl \
   SVGPolygonElement.webidl \
   SVGPolylineElement.webidl \
   SVGPreserveAspectRatio.webidl \
+  SVGRadialGradientElement.webidl \
   SVGRectElement.webidl \
   SVGScriptElement.webidl \
   SVGSetElement.webidl \
   SVGStopElement.webidl \
   SVGStyleElement.webidl \
   SVGSVGElement.webidl \
   SVGSwitchElement.webidl \
   SVGTests.webidl \
@@ -148,16 +151,17 @@ webidl_files = \
   SVGTextElement.webidl \
   SVGTextPathElement.webidl \
   SVGTextPositioningElement.webidl \
   SVGTitleElement.webidl \
   SVGTransform.webidl \
   SVGTransformableElement.webidl \
   SVGTransformList.webidl \
   SVGTSpanElement.webidl \
+  SVGUnitTypes.webidl \
   SVGURIReference.webidl \
   SVGViewElement.webidl \
   SVGZoomAndPan.webidl \
   Text.webidl \
   TextDecoder.webidl \
   TextEncoder.webidl \
   URL.webidl \
   WebSocket.webidl \
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -3,22 +3,24 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Main header first:
 #include "nsSVGGradientFrame.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfxPattern.h"
+#include "mozilla/dom/SVGGradientElement.h"
+#include "mozilla/dom/SVGStopElement.h"
 #include "nsContentUtils.h"
 #include "nsIDOMSVGAnimatedNumber.h"
 #include "nsSVGEffects.h"
-#include "nsSVGGradientElement.h"
 #include "SVGAnimatedTransformList.h"
-#include "mozilla/dom/SVGStopElement.h"
+
+// XXX Tight coupling with content classes ahead!
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 // Helper classes
 
 class nsSVGGradientFrame::AutoGradientReferencer
@@ -123,56 +125,56 @@ nsSVGGradientFrame::GetStopInformation(i
   *aStopColor   = stopFrame->GetStyleSVGReset()->mStopColor;
   *aStopOpacity = stopFrame->GetStyleSVGReset()->mStopOpacity;
 }
 
 uint16_t
 nsSVGGradientFrame::GetEnumValue(uint32_t aIndex, nsIContent *aDefault)
 {
   const nsSVGEnum& thisEnum =
-    static_cast<nsSVGGradientElement *>(mContent)->mEnumAttributes[aIndex];
+    static_cast<dom::SVGGradientElement*>(mContent)->mEnumAttributes[aIndex];
 
   if (thisEnum.IsExplicitlySet())
     return thisEnum.GetAnimValue();
 
   AutoGradientReferencer gradientRef(this);
 
   nsSVGGradientFrame *next = GetReferencedGradientIfNotInUse();
   return next ? next->GetEnumValue(aIndex, aDefault) :
-    static_cast<nsSVGGradientElement *>(aDefault)->
+    static_cast<dom::SVGGradientElement*>(aDefault)->
       mEnumAttributes[aIndex].GetAnimValue();
 }
 
 uint16_t
 nsSVGGradientFrame::GetGradientUnits()
 {
   // This getter is called every time the others are called - maybe cache it?
-  return GetEnumValue(nsSVGGradientElement::GRADIENTUNITS);
+  return GetEnumValue(dom::SVGGradientElement::GRADIENTUNITS);
 }
 
 uint16_t
 nsSVGGradientFrame::GetSpreadMethod()
 {
-  return GetEnumValue(nsSVGGradientElement::SPREADMETHOD);
+  return GetEnumValue(dom::SVGGradientElement::SPREADMETHOD);
 }
 
 const SVGAnimatedTransformList*
 nsSVGGradientFrame::GetGradientTransformList(nsIContent* aDefault)
 {
   SVGAnimatedTransformList *thisTransformList =
-    static_cast<nsSVGGradientElement *>(mContent)->GetAnimatedTransformList();
+    static_cast<dom::SVGGradientElement*>(mContent)->GetAnimatedTransformList();
 
   if (thisTransformList && thisTransformList->IsExplicitlySet())
     return thisTransformList;
 
   AutoGradientReferencer gradientRef(this);
 
   nsSVGGradientFrame *next = GetReferencedGradientIfNotInUse();
   return next ? next->GetGradientTransformList(aDefault) :
-    static_cast<const nsSVGGradientElement *>(aDefault)
+    static_cast<const dom::SVGGradientElement*>(aDefault)
       ->mGradientTransform.get();
 }
 
 gfxMatrix
 nsSVGGradientFrame::GetGradientTransform(nsIFrame *aSource,
                                          const gfxRect *aOverrideBounds)
 {
   gfxMatrix bboxMatrix;
@@ -203,33 +205,33 @@ nsSVGGradientFrame::GetGradientTransform
   if (!animTransformList)
     return bboxMatrix;
 
   gfxMatrix gradientTransform =
     animTransformList->GetAnimValue().GetConsolidationMatrix();
   return bboxMatrix.PreMultiply(gradientTransform);
 }
 
-nsSVGLinearGradientElement *
+dom::SVGLinearGradientElement*
 nsSVGGradientFrame::GetLinearGradientWithLength(uint32_t aIndex,
-  nsSVGLinearGradientElement* aDefault)
+  dom::SVGLinearGradientElement* aDefault)
 {
   // If this was a linear gradient with the required length, we would have
   // already found it in nsSVGLinearGradientFrame::GetLinearGradientWithLength.
   // Since we didn't find the length, continue looking down the chain.
 
   AutoGradientReferencer gradientRef(this);
 
   nsSVGGradientFrame *next = GetReferencedGradientIfNotInUse();
   return next ? next->GetLinearGradientWithLength(aIndex, aDefault) : aDefault;
 }
 
-nsSVGRadialGradientElement *
+dom::SVGRadialGradientElement*
 nsSVGGradientFrame::GetRadialGradientWithLength(uint32_t aIndex,
-  nsSVGRadialGradientElement* aDefault)
+  dom::SVGRadialGradientElement* aDefault)
 {
   // If this was a radial gradient with the required length, we would have
   // already found it in nsSVGRadialGradientFrame::GetRadialGradientWithLength.
   // Since we didn't find the length, continue looking down the chain.
 
   AutoGradientReferencer gradientRef(this);
 
   nsSVGGradientFrame *next = GetReferencedGradientIfNotInUse();
@@ -330,19 +332,19 @@ nsSVGGradientFrame::GetReferencedGradien
   if (mNoHRefURI)
     return nullptr;
 
   nsSVGPaintingProperty *property = static_cast<nsSVGPaintingProperty*>
     (Properties().Get(nsSVGEffects::HrefProperty()));
 
   if (!property) {
     // Fetch our gradient element's xlink:href attribute
-    nsSVGGradientElement *grad = static_cast<nsSVGGradientElement *>(mContent);
+    dom::SVGGradientElement*grad = static_cast<dom::SVGGradientElement*>(mContent);
     nsAutoString href;
-    grad->mStringAttributes[nsSVGGradientElement::HREF].GetAnimValue(href, grad);
+    grad->mStringAttributes[dom::SVGGradientElement::HREF].GetAnimValue(href, grad);
     if (href.IsEmpty()) {
       mNoHRefURI = true;
       return nullptr; // no URL
     }
 
     // Convert href to an nsIURI
     nsCOMPtr<nsIURI> targetURI;
     nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
@@ -452,19 +454,19 @@ nsSVGLinearGradientFrame::AttributeChang
                                               aAttribute, aModType);
 }
 
 //----------------------------------------------------------------------
 
 float
 nsSVGLinearGradientFrame::GetLengthValue(uint32_t aIndex)
 {
-  nsSVGLinearGradientElement* lengthElement =
+  dom::SVGLinearGradientElement* lengthElement =
     GetLinearGradientWithLength(aIndex,
-      static_cast<nsSVGLinearGradientElement *>(mContent));
+      static_cast<dom::SVGLinearGradientElement*>(mContent));
   // We passed in mContent as a fallback, so, assuming mContent is non-null, the
   // return value should also be non-null.
   NS_ABORT_IF_FALSE(lengthElement,
     "Got unexpected null element from GetLinearGradientWithLength");
   const nsSVGLength2 &length = lengthElement->mLengthAttributes[aIndex];
 
   // Object bounding box units are handled by setting the appropriate
   // transform in GetGradientTransform, but we need to handle user
@@ -477,53 +479,53 @@ nsSVGLinearGradientFrame::GetLengthValue
 
   NS_ASSERTION(
     gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
     "Unknown gradientUnits type");
 
   return length.GetAnimValue(static_cast<SVGSVGElement*>(nullptr));
 }
 
-nsSVGLinearGradientElement *
+dom::SVGLinearGradientElement*
 nsSVGLinearGradientFrame::GetLinearGradientWithLength(uint32_t aIndex,
-  nsSVGLinearGradientElement* aDefault)
+  dom::SVGLinearGradientElement* aDefault)
 {
-  nsSVGLinearGradientElement* thisElement =
-    static_cast<nsSVGLinearGradientElement *>(mContent);
+  dom::SVGLinearGradientElement* thisElement =
+    static_cast<dom::SVGLinearGradientElement*>(mContent);
   const nsSVGLength2 &length = thisElement->mLengthAttributes[aIndex];
 
   if (length.IsExplicitlySet()) {
     return thisElement;
   }
 
   return nsSVGLinearGradientFrameBase::GetLinearGradientWithLength(aIndex,
                                                                    aDefault);
 }
 
 bool
 nsSVGLinearGradientFrame::IsSingleColour(uint32_t nStops)
 {
   NS_ABORT_IF_FALSE(nStops == GetStopCount(), "Unexpected number of stops");
 
   return nStops == 1 ||
-         (GetLengthValue(nsSVGLinearGradientElement::X1) ==
-          GetLengthValue(nsSVGLinearGradientElement::X2) &&
-          GetLengthValue(nsSVGLinearGradientElement::Y1) ==
-          GetLengthValue(nsSVGLinearGradientElement::Y2));
+         (GetLengthValue(dom::SVGLinearGradientElement::ATTR_X1) ==
+          GetLengthValue(dom::SVGLinearGradientElement::ATTR_X2) &&
+          GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y1) ==
+          GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y2));
 }
 
 already_AddRefed<gfxPattern>
 nsSVGLinearGradientFrame::CreateGradient()
 {
   float x1, y1, x2, y2;
 
-  x1 = GetLengthValue(nsSVGLinearGradientElement::X1);
-  y1 = GetLengthValue(nsSVGLinearGradientElement::Y1);
-  x2 = GetLengthValue(nsSVGLinearGradientElement::X2);
-  y2 = GetLengthValue(nsSVGLinearGradientElement::Y2);
+  x1 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_X1);
+  y1 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y1);
+  x2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_X2);
+  y2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y2);
 
   gfxPattern *pattern = new gfxPattern(x1, y1, x2, y2);
   NS_IF_ADDREF(pattern);
   return pattern;
 }
 
 // -------------------------------------------------------------------------
 // Radial Gradients
@@ -566,39 +568,39 @@ nsSVGRadialGradientFrame::AttributeChang
                                               aAttribute, aModType);
 }
 
 //----------------------------------------------------------------------
 
 float
 nsSVGRadialGradientFrame::GetLengthValue(uint32_t aIndex)
 {
-  nsSVGRadialGradientElement* lengthElement =
+  dom::SVGRadialGradientElement* lengthElement =
     GetRadialGradientWithLength(aIndex,
-      static_cast<nsSVGRadialGradientElement *>(mContent));
+      static_cast<dom::SVGRadialGradientElement*>(mContent));
   // We passed in mContent as a fallback, so, assuming mContent is non-null,
   // the return value should also be non-null.
   NS_ABORT_IF_FALSE(lengthElement,
     "Got unexpected null element from GetRadialGradientWithLength");
   return GetLengthValueFromElement(aIndex, *lengthElement);
 }
 
 float
 nsSVGRadialGradientFrame::GetLengthValue(uint32_t aIndex, float aDefaultValue)
 {
-  nsSVGRadialGradientElement* lengthElement =
+  dom::SVGRadialGradientElement* lengthElement =
     GetRadialGradientWithLength(aIndex, nullptr);
 
   return lengthElement ? GetLengthValueFromElement(aIndex, *lengthElement)
                        : aDefaultValue;
 }
 
 float
 nsSVGRadialGradientFrame::GetLengthValueFromElement(uint32_t aIndex,
-  nsSVGRadialGradientElement& aElement)
+  dom::SVGRadialGradientElement& aElement)
 {
   const nsSVGLength2 &length = aElement.mLengthAttributes[aIndex];
 
   // Object bounding box units are handled by setting the appropriate
   // transform in GetGradientTransform, but we need to handle user
   // space units as part of the individual Get* routines.  Fixes 323669.
 
   uint16_t gradientUnits = GetGradientUnits();
@@ -608,52 +610,52 @@ nsSVGRadialGradientFrame::GetLengthValue
 
   NS_ASSERTION(
     gradientUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
     "Unknown gradientUnits type");
 
   return length.GetAnimValue(static_cast<SVGSVGElement*>(nullptr));
 }
 
-nsSVGRadialGradientElement *
+dom::SVGRadialGradientElement*
 nsSVGRadialGradientFrame::GetRadialGradientWithLength(uint32_t aIndex,
-  nsSVGRadialGradientElement* aDefault)
+  dom::SVGRadialGradientElement* aDefault)
 {
-  nsSVGRadialGradientElement* thisElement =
-    static_cast<nsSVGRadialGradientElement *>(mContent);
+  dom::SVGRadialGradientElement* thisElement =
+    static_cast<dom::SVGRadialGradientElement*>(mContent);
   const nsSVGLength2 &length = thisElement->mLengthAttributes[aIndex];
 
   if (length.IsExplicitlySet()) {
     return thisElement;
   }
 
   return nsSVGRadialGradientFrameBase::GetRadialGradientWithLength(aIndex,
                                                                    aDefault);
 }
 
 bool
 nsSVGRadialGradientFrame::IsSingleColour(uint32_t nStops)
 {
   NS_ABORT_IF_FALSE(nStops == GetStopCount(), "Unexpected number of stops");
 
   return nStops == 1 ||
-         GetLengthValue(nsSVGRadialGradientElement::R) == 0;
+         GetLengthValue(dom::SVGRadialGradientElement::ATTR_R) == 0;
 }
 
 already_AddRefed<gfxPattern>
 nsSVGRadialGradientFrame::CreateGradient()
 {
   float cx, cy, r, fx, fy;
 
-  cx = GetLengthValue(nsSVGRadialGradientElement::CX);
-  cy = GetLengthValue(nsSVGRadialGradientElement::CY);
-  r  = GetLengthValue(nsSVGRadialGradientElement::R);
+  cx = GetLengthValue(dom::SVGRadialGradientElement::ATTR_CX);
+  cy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_CY);
+  r  = GetLengthValue(dom::SVGRadialGradientElement::ATTR_R);
   // If fx or fy are not set, use cx/cy instead
-  fx = GetLengthValue(nsSVGRadialGradientElement::FX, cx);
-  fy = GetLengthValue(nsSVGRadialGradientElement::FY, cy);
+  fx = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FX, cx);
+  fy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FY, cy);
 
   if (fx != cx || fy != cy) {
     // The focal point (fFx and fFy) must be clamped to be *inside* - not on -
     // the circumference of the gradient or we'll get rendering anomalies. We
     // calculate the distance from the focal point to the gradient center and
     // make sure it is *less* than the gradient radius.
     // 1/128 is the limit of the fractional part of cairo's 24.8 fixed point
     // representation divided by 2 to ensure that we get different cairo
--- a/layout/svg/nsSVGGradientFrame.h
+++ b/layout/svg/nsSVGGradientFrame.h
@@ -13,24 +13,27 @@
 #include "nsSVGPaintServerFrame.h"
 
 class gfxPattern;
 class nsIAtom;
 class nsIContent;
 class nsIFrame;
 class nsIPresShell;
 class nsStyleContext;
-class nsSVGLinearGradientElement;
-class nsSVGRadialGradientElement;
 
 struct gfxRect;
 
 namespace mozilla {
 class SVGAnimatedTransformList;
-}
+
+namespace dom {
+class SVGLinearGradientElement;
+class SVGRadialGradientElement;
+} // namespace dom
+} // namespace mozilla
 
 typedef nsSVGPaintServerFrame nsSVGGradientFrameBase;
 
 /**
  * Gradients can refer to other gradients. We create an nsSVGPaintingProperty
  * with property type nsGkAtoms::href to track the referenced gradient.
  */
 class nsSVGGradientFrame : public nsSVGGradientFrameBase
@@ -97,20 +100,20 @@ protected:
   {
     return GetEnumValue(aIndex, mContent);
   }
   uint16_t GetGradientUnits();
   uint16_t GetSpreadMethod();
 
   // Gradient-type-specific lookups since the length values differ between
   // linear and radial gradients
-  virtual nsSVGLinearGradientElement * GetLinearGradientWithLength(
-    uint32_t aIndex, nsSVGLinearGradientElement* aDefault);
-  virtual nsSVGRadialGradientElement * GetRadialGradientWithLength(
-    uint32_t aIndex, nsSVGRadialGradientElement* aDefault);
+  virtual mozilla::dom::SVGLinearGradientElement * GetLinearGradientWithLength(
+    uint32_t aIndex, mozilla::dom::SVGLinearGradientElement* aDefault);
+  virtual mozilla::dom::SVGRadialGradientElement * GetRadialGradientWithLength(
+    uint32_t aIndex, mozilla::dom::SVGRadialGradientElement* aDefault);
 
   // The frame our gradient is (currently) being applied to
   nsIFrame*                              mSource;
 
 private:
   // Flag to mark this frame as "in use" during recursive calls along our
   // gradient's reference chain so we can detect reference loops. See:
   // http://www.w3.org/TR/SVG11/pservers.html#LinearGradientElementHrefAttribute
@@ -155,18 +158,18 @@ public:
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGLinearGradient"), aResult);
   }
 #endif // DEBUG
 
 protected:
   float GetLengthValue(uint32_t aIndex);
-  virtual nsSVGLinearGradientElement * GetLinearGradientWithLength(
-    uint32_t aIndex, nsSVGLinearGradientElement* aDefault);
+  virtual mozilla::dom::SVGLinearGradientElement* GetLinearGradientWithLength(
+    uint32_t aIndex, mozilla::dom::SVGLinearGradientElement* aDefault);
   virtual bool IsSingleColour(uint32_t nStops);
   virtual already_AddRefed<gfxPattern> CreateGradient();
 };
 
 // -------------------------------------------------------------------------
 // Radial Gradients
 // -------------------------------------------------------------------------
 
@@ -202,17 +205,17 @@ public:
     return MakeFrameName(NS_LITERAL_STRING("SVGRadialGradient"), aResult);
   }
 #endif // DEBUG
 
 protected:
   float GetLengthValue(uint32_t aIndex);
   float GetLengthValue(uint32_t aIndex, float aDefaultValue);
   float GetLengthValueFromElement(uint32_t aIndex,
-                                  nsSVGRadialGradientElement& aElement);
-  virtual nsSVGRadialGradientElement * GetRadialGradientWithLength(
-    uint32_t aIndex, nsSVGRadialGradientElement* aDefault);
+                                  mozilla::dom::SVGRadialGradientElement& aElement);
+  virtual mozilla::dom::SVGRadialGradientElement* GetRadialGradientWithLength(
+    uint32_t aIndex, mozilla::dom::SVGRadialGradientElement* aDefault);
   virtual bool IsSingleColour(uint32_t nStops);
   virtual already_AddRefed<gfxPattern> CreateGradient();
 };
 
 #endif // __NS_SVGGRADIENTFRAME_H__