Bug 825147: Convert SVGRectElement to WebIDL r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 06 Jan 2013 04:32:01 -0500
changeset 126888 04feda337f8b75c1e09d2465ed2a90c3bad64a08
parent 126887 5ec2ebd28b1a6e7368f3f96ccf97aba6040d0ae2
child 126889 dd6b8ef397aa1cfdb285989362eb6c375f69a713
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs825147
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 825147: Convert SVGRectElement to WebIDL r=bz
content/svg/content/src/Makefile.in
content/svg/content/src/SVGRectElement.cpp
content/svg/content/src/SVGRectElement.h
content/svg/content/src/nsSVGRectElement.cpp
dom/webidl/SVGRectElement.webidl
dom/webidl/WebIDL.mk
--- a/content/svg/content/src/Makefile.in
+++ b/content/svg/content/src/Makefile.in
@@ -62,17 +62,16 @@ CPPSRCS		= \
 		nsSVGNumberPair.cpp \
 		nsSVGPathDataParser.cpp \
 		nsSVGPathElement.cpp \
 		nsSVGPathGeometryElement.cpp \
 		nsSVGPatternElement.cpp \
 		nsSVGPolyElement.cpp \
 		nsSVGString.cpp \
 		nsSVGRect.cpp \
-		nsSVGRectElement.cpp \
 		nsSVGSVGElement.cpp \
 		nsSVGSymbolElement.cpp \
 		nsSVGTSpanElement.cpp \
 		nsSVGTextContentElement.cpp \
 		nsSVGTextElement.cpp \
 		nsSVGTextPathElement.cpp \
 		nsSVGTextPositioningElement.cpp \
 		nsSVGUnknownElement.cpp \
@@ -94,16 +93,17 @@ CPPSRCS		= \
 		SVGImageElement.cpp \
 		SVGLength.cpp \
 		SVGLengthList.cpp \
 		SVGNumberList.cpp \
 		SVGPathData.cpp \
 		SVGPathSegUtils.cpp \
 		SVGPointList.cpp \
 		SVGPreserveAspectRatio.cpp \
+		SVGRectElement.cpp \
 		SVGStringList.cpp \
 		SVGTitleElement.cpp \
 		SVGTransform.cpp \
 		SVGTransformList.cpp \
 		SVGTransformListParser.cpp \
 		nsSVGAnimateElement.cpp \
 		nsSVGAnimateTransformElement.cpp \
 		nsSVGAnimateMotionElement.cpp \
@@ -162,16 +162,17 @@ EXPORTS_mozilla/dom = \
 	SVGGElement.h \
 	SVGGraphicsElement.h \
 	SVGImageElement.h \
 	SVGLocatableElement.h \
 	SVGMetadataElement.h \
 	SVGMPathElement.h \
 	SVGPolygonElement.h \
 	SVGPolylineElement.h \
+	SVGRectElement.h \
 	SVGScriptElement.h \
 	SVGStopElement.h \
 	SVGStyleElement.h \
 	SVGSwitchElement.h \
 	SVGTitleElement.h \
 	SVGTransformableElement.h \
 	$(NULL)
 
rename from content/svg/content/src/nsSVGRectElement.cpp
rename to content/svg/content/src/SVGRectElement.cpp
--- a/content/svg/content/src/nsSVGRectElement.cpp
+++ b/content/svg/content/src/SVGRectElement.cpp
@@ -1,166 +1,185 @@
 /* -*- 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 "nsSVGPathGeometryElement.h"
-#include "nsIDOMSVGRectElement.h"
-#include "nsSVGLength2.h"
+#include "mozilla/dom/SVGRectElement.h"
 #include "nsGkAtoms.h"
 #include "gfxContext.h"
-
-using namespace mozilla;
-
-typedef nsSVGPathGeometryElement nsSVGRectElementBase;
+#include "mozilla/dom/SVGRectElementBinding.h"
 
-class nsSVGRectElement : public nsSVGRectElementBase,
-                         public nsIDOMSVGRectElement
-{
-protected:
-  friend nsresult NS_NewSVGRectElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGRectElement, mozilla::dom::SVGRectElement)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGRECTELEMENT
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Rect)
 
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
-
-  // nsSVGSVGElement methods:
-  virtual bool HasValidDimensions() const;
-
-  // nsSVGPathGeometryElement methods:
-  virtual void ConstructPath(gfxContext *aCtx);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+namespace mozilla {
+namespace dom {
 
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
+JSObject*
+SVGRectElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGRectElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
-  virtual LengthAttributesInfo GetLengthInfo();
- 
-  enum { X, Y, WIDTH, HEIGHT, RX, RY };
-  nsSVGLength2 mLengthAttributes[6];
-  static LengthInfo sLengthInfo[6];
-};
-
-nsSVGElement::LengthInfo nsSVGRectElement::sLengthInfo[6] =
+nsSVGElement::LengthInfo SVGRectElement::sLengthInfo[6] =
 {
   { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Rect)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGRectElement,SVGRectElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGRectElement,SVGRectElementBase)
 
-DOMCI_NODE_DATA(SVGRectElement, nsSVGRectElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGRectElement)
-  NS_NODE_INTERFACE_TABLE4(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
+NS_INTERFACE_TABLE_HEAD(SVGRectElement)
+  NS_NODE_INTERFACE_TABLE4(SVGRectElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement,
                            nsIDOMSVGRectElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRectElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGRectElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGRectElement::nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGRectElementBase(aNodeInfo)
+SVGRectElement::SVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGRectElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRectElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGRectElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGRectElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength x; */
-NS_IMETHODIMP nsSVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
+NS_IMETHODIMP SVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
 {
-  return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
+  *aX = X().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::X()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedLength> x;
+  mLengthAttributes[ATTR_X].ToDOMAnimatedLength(getter_AddRefs(x), this);
+  return x.forget();
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
-NS_IMETHODIMP nsSVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
+NS_IMETHODIMP SVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
-  return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
+  *aY = Y().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Y()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedLength> y;
+  mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(getter_AddRefs(y), this);
+  return y.forget();
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
-NS_IMETHODIMP nsSVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
+NS_IMETHODIMP SVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
-  return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
+  *aWidth = Width().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Width()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedLength> width;
+  mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(getter_AddRefs(width), this);
+  return width.forget();
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
-NS_IMETHODIMP nsSVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
+NS_IMETHODIMP SVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
-  return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
+  *aHeight = Height().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Height()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedLength> height;
+  mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(getter_AddRefs(height), this);
+  return height.forget();
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
+NS_IMETHODIMP SVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
 {
-  return mLengthAttributes[RX].ToDOMAnimatedLength(aRx, this);
+  *aRx = Rx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Rx()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedLength> Rx;
+  mLengthAttributes[ATTR_RX].ToDOMAnimatedLength(getter_AddRefs(Rx), this);
+  return Rx.forget();
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
+NS_IMETHODIMP SVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
 {
-  return mLengthAttributes[RY].ToDOMAnimatedLength(aRy, this);
+  *aRy = Ry().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Ry()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedLength> Ry;
+  mLengthAttributes[ATTR_RY].ToDOMAnimatedLength(getter_AddRefs(Ry), this);
+  return Ry.forget();
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
-nsSVGRectElement::HasValidDimensions() const
+SVGRectElement::HasValidDimensions() const
 {
-  return mLengthAttributes[WIDTH].IsExplicitlySet() &&
-         mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[HEIGHT].IsExplicitlySet() &&
-         mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
+  return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
+         mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
 }
 
 nsSVGElement::LengthAttributesInfo
-nsSVGRectElement::GetLengthInfo()
+SVGRectElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
-nsSVGRectElement::ConstructPath(gfxContext *aCtx)
+SVGRectElement::ConstructPath(gfxContext *aCtx)
 {
   float x, y, width, height, rx, ry;
 
   GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
 
   /* In a perfect world, this would be handled by the DOM, and
      return a DOM exception. */
   if (width <= 0 || height <= 0)
@@ -172,18 +191,18 @@ nsSVGRectElement::ConstructPath(gfxConte
   /* optimize the no rounded corners case */
   if (rx == 0 && ry == 0) {
     aCtx->Rectangle(gfxRect(x, y, width, height));
     return;
   }
 
   /* If either the 'rx' or the 'ry' attribute isn't set, then we
      have to set it to the value of the other. */
-  bool hasRx = mLengthAttributes[RX].IsExplicitlySet();
-  bool hasRy = mLengthAttributes[RY].IsExplicitlySet();
+  bool hasRx = mLengthAttributes[ATTR_RX].IsExplicitlySet();
+  bool hasRy = mLengthAttributes[ATTR_RY].IsExplicitlySet();
   if (hasRx && !hasRy)
     ry = rx;
   else if (hasRy && !hasRx)
     rx = ry;
 
   /* Clamp rx and ry to half the rect's width and height respectively. */
   float halfWidth  = width/2;
   float halfHeight = height/2;
@@ -191,8 +210,11 @@ nsSVGRectElement::ConstructPath(gfxConte
     rx = halfWidth;
   if (ry > halfHeight)
     ry = halfHeight;
 
   gfxSize corner(rx, ry);
   aCtx->RoundedRectangle(gfxRect(x, y, width, height),
                          gfxCornerSizes(corner, corner, corner, corner));
 }
+
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGRectElement.cpp
copy to content/svg/content/src/SVGRectElement.h
--- a/content/svg/content/src/nsSVGRectElement.cpp
+++ b/content/svg/content/src/SVGRectElement.h
@@ -1,198 +1,72 @@
 /* -*- 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"
+#ifndef mozilla_dom_SVGRectElement_h
+#define mozilla_dom_SVGRectElement_h
 
 #include "nsSVGPathGeometryElement.h"
 #include "nsIDOMSVGRectElement.h"
 #include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
-#include "gfxContext.h"
 
-using namespace mozilla;
+nsresult NS_NewSVGRectElement(nsIContent **aResult,
+                              already_AddRefed<nsINodeInfo> aNodeInfo);
+
+typedef nsSVGPathGeometryElement SVGRectElementBase;
 
-typedef nsSVGPathGeometryElement nsSVGRectElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGRectElement : public nsSVGRectElementBase,
-                         public nsIDOMSVGRectElement
+class SVGRectElement MOZ_FINAL : public SVGRectElementBase,
+                                 public nsIDOMSVGRectElement
 {
 protected:
-  friend nsresult NS_NewSVGRectElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGRectElement(nsIContent **aResult,
+                                          already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGRECTELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGRectElementBase::)
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const;
 
   // nsSVGPathGeometryElement methods:
   virtual void ConstructPath(gfxContext *aCtx);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> X();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Height();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Width();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Rx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Ry();
+
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
- 
-  enum { X, Y, WIDTH, HEIGHT, RX, RY };
+
+  enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT, ATTR_RX, ATTR_RY };
   nsSVGLength2 mLengthAttributes[6];
   static LengthInfo sLengthInfo[6];
 };
 
-nsSVGElement::LengthInfo nsSVGRectElement::sLengthInfo[6] =
-{
-  { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Rect)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
-
-DOMCI_NODE_DATA(SVGRectElement, nsSVGRectElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGRectElement)
-  NS_NODE_INTERFACE_TABLE4(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement,
-                           nsIDOMSVGRectElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRectElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGRectElement::nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGRectElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRectElement)
-
-//----------------------------------------------------------------------
-// nsIDOMSVGRectElement methods
-
-/* readonly attribute nsIDOMSVGAnimatedLength x; */
-NS_IMETHODIMP nsSVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
-{
-  return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength y; */
-NS_IMETHODIMP nsSVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
-{
-  return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength width; */
-NS_IMETHODIMP nsSVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
-{
-  return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength height; */
-NS_IMETHODIMP nsSVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
-{
-  return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
-}
+} // namespace dom
+} // namespace mozilla
 
-/* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
-{
-  return mLengthAttributes[RX].ToDOMAnimatedLength(aRx, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
-{
-  return mLengthAttributes[RY].ToDOMAnimatedLength(aRy, this);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement methods
-
-/* virtual */ bool
-nsSVGRectElement::HasValidDimensions() const
-{
-  return mLengthAttributes[WIDTH].IsExplicitlySet() &&
-         mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[HEIGHT].IsExplicitlySet() &&
-         mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
-}
-
-nsSVGElement::LengthAttributesInfo
-nsSVGRectElement::GetLengthInfo()
-{
-  return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
-                              ArrayLength(sLengthInfo));
-}
-
-//----------------------------------------------------------------------
-// nsSVGPathGeometryElement methods
-
-void
-nsSVGRectElement::ConstructPath(gfxContext *aCtx)
-{
-  float x, y, width, height, rx, ry;
-
-  GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
-
-  /* In a perfect world, this would be handled by the DOM, and
-     return a DOM exception. */
-  if (width <= 0 || height <= 0)
-    return;
-
-  rx = NS_MAX(rx, 0.0f);
-  ry = NS_MAX(ry, 0.0f);
-
-  /* optimize the no rounded corners case */
-  if (rx == 0 && ry == 0) {
-    aCtx->Rectangle(gfxRect(x, y, width, height));
-    return;
-  }
-
-  /* If either the 'rx' or the 'ry' attribute isn't set, then we
-     have to set it to the value of the other. */
-  bool hasRx = mLengthAttributes[RX].IsExplicitlySet();
-  bool hasRy = mLengthAttributes[RY].IsExplicitlySet();
-  if (hasRx && !hasRy)
-    ry = rx;
-  else if (hasRy && !hasRx)
-    rx = ry;
-
-  /* Clamp rx and ry to half the rect's width and height respectively. */
-  float halfWidth  = width/2;
-  float halfHeight = height/2;
-  if (rx > halfWidth)
-    rx = halfWidth;
-  if (ry > halfHeight)
-    ry = halfHeight;
-
-  gfxSize corner(rx, ry);
-  aCtx->RoundedRectangle(gfxRect(x, y, width, height),
-                         gfxCornerSizes(corner, corner, corner, corner));
-}
+#endif // mozilla_dom_SVGRectElement_h
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGRectElement.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
+ * http://www.w3.org/TR/SVG2/
+ *
+ * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * liability, trademark and document use rules apply.
+ */
+
+interface SVGAnimatedLength;
+
+interface SVGRectElement : SVGGraphicsElement {
+  [Constant]
+  readonly attribute SVGAnimatedLength x;
+  [Constant]
+  readonly attribute SVGAnimatedLength y;
+  [Constant]
+  readonly attribute SVGAnimatedLength width;
+  [Constant]
+  readonly attribute SVGAnimatedLength height;
+  [Constant]
+  readonly attribute SVGAnimatedLength rx;
+  [Constant]
+  readonly attribute SVGAnimatedLength ry;
+};
+
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -119,16 +119,17 @@ webidl_files = \
   SVGNumberList.webidl \
   SVGPathSeg.webidl \
   SVGPathSegList.webidl \
   SVGPoint.webidl \
   SVGPointList.webidl \
   SVGPolygonElement.webidl \
   SVGPolylineElement.webidl \
   SVGPreserveAspectRatio.webidl \
+  SVGRectElement.webidl \
   SVGScriptElement.webidl \
   SVGStopElement.webidl \
   SVGStyleElement.webidl \
   SVGSwitchElement.webidl \
   SVGTests.webidl \
   SVGTitleElement.webidl \
   SVGTransform.webidl \
   SVGTransformableElement.webidl \