Bug 825730: Add a more convenient signature for ToDOMAnimatedLength r=longsonr
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 06 Jan 2013 04:32:02 -0500
changeset 126892 04e417ee3fe8a8841e81db40cf5217ee9d5b104b
parent 126891 2a2a7a9d4d3edccd7105b56c33f859c8f119165d
child 126893 2a404732e63848fde3bbf7a92a4f5f8a12a4c32d
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)
reviewerslongsonr
bugs825730
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 825730: Add a more convenient signature for ToDOMAnimatedLength r=longsonr
content/svg/content/src/SVGCircleElement.cpp
content/svg/content/src/SVGEllipseElement.cpp
content/svg/content/src/SVGForeignObjectElement.cpp
content/svg/content/src/SVGImageElement.cpp
content/svg/content/src/SVGRectElement.cpp
content/svg/content/src/nsSVGLength2.cpp
content/svg/content/src/nsSVGLength2.h
--- a/content/svg/content/src/SVGCircleElement.cpp
+++ b/content/svg/content/src/SVGCircleElement.cpp
@@ -63,49 +63,43 @@ NS_IMETHODIMP SVGCircleElement::GetCx(ns
 {
   *aCx = Cx().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGCircleElement::Cx()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> cx;
-  mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(getter_AddRefs(cx), this);
-  return cx.forget();
+  return mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
 NS_IMETHODIMP SVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
 {
   *aCy = Cy().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGCircleElement::Cy()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> cy;
-  mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(getter_AddRefs(cy), this);
-  return cy.forget();
+  return mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength r; */
 NS_IMETHODIMP SVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
 {
   *aR = R().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGCircleElement::R()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> r;
-  mLengthAttributes[ATTR_R].ToDOMAnimatedLength(getter_AddRefs(r), this);
-  return r.forget();
+  return mLengthAttributes[ATTR_R].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
 SVGCircleElement::HasValidDimensions() const
 {
--- a/content/svg/content/src/SVGEllipseElement.cpp
+++ b/content/svg/content/src/SVGEllipseElement.cpp
@@ -63,64 +63,56 @@ NS_IMETHODIMP SVGEllipseElement::GetCx(n
 {
   *aCx = Cx().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGEllipseElement::Cx()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> cx;
-  mLengthAttributes[CX].ToDOMAnimatedLength(getter_AddRefs(cx), this);
-  return cx.forget();
+  return mLengthAttributes[CX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
 NS_IMETHODIMP SVGEllipseElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
 {
   *aCy = Cy().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGEllipseElement::Cy()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> cy;
-  mLengthAttributes[CY].ToDOMAnimatedLength(getter_AddRefs(cy), this);
-  return cy.forget();
+  return mLengthAttributes[CY].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength rx; */
 NS_IMETHODIMP SVGEllipseElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
 {
   *aRx = Rx().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGEllipseElement::Rx()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> rx;
-  mLengthAttributes[RX].ToDOMAnimatedLength(getter_AddRefs(rx), this);
-  return rx.forget();
+  return mLengthAttributes[RX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength ry; */
 NS_IMETHODIMP SVGEllipseElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
 {
   *aRy = Ry().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGEllipseElement::Ry()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> ry;
-  mLengthAttributes[RY].ToDOMAnimatedLength(getter_AddRefs(ry), this);
-  return ry.forget();
+  return mLengthAttributes[RY].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
 SVGEllipseElement::HasValidDimensions() const
 {
--- a/content/svg/content/src/SVGForeignObjectElement.cpp
+++ b/content/svg/content/src/SVGForeignObjectElement.cpp
@@ -65,66 +65,58 @@ NS_IMETHODIMP SVGForeignObjectElement::G
 {
   *aX = X().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGForeignObjectElement::X()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> x;
-  mLengthAttributes[ATTR_X].ToDOMAnimatedLength(getter_AddRefs(x), this);
-  return x.forget();
+  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
 NS_IMETHODIMP SVGForeignObjectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
   *aY = Y().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGForeignObjectElement::Y()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> y;
-  mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(getter_AddRefs(y), this);
-  return y.forget();
+  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
 }
 
 
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
 NS_IMETHODIMP SVGForeignObjectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
   *aWidth = Width().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGForeignObjectElement::Width()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> width;
-  mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(getter_AddRefs(width), this);
-  return width.forget();
+  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
 }
 
 
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
 NS_IMETHODIMP SVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
   *aHeight = Height().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGForeignObjectElement::Height()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> height;
-  mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(getter_AddRefs(height), this);
-  return height.forget();
+  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ gfxMatrix
 SVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
                                                   TransformTypes aWhich) const
--- a/content/svg/content/src/SVGImageElement.cpp
+++ b/content/svg/content/src/SVGImageElement.cpp
@@ -86,64 +86,56 @@ NS_IMETHODIMP SVGImageElement::GetX(nsID
 {
   *aX = X().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGImageElement::X()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> x;
-  mLengthAttributes[ATTR_X].ToDOMAnimatedLength(getter_AddRefs(x), this);
-  return x.forget();
+  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
 NS_IMETHODIMP SVGImageElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
   *aY = Y().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGImageElement::Y()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> y;
-  mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(getter_AddRefs(y), this);
-  return y.forget();
+  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
 NS_IMETHODIMP SVGImageElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
   *aWidth = Width().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGImageElement::Width()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> width;
-  mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(getter_AddRefs(width), this);
-  return width.forget();
+  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
 NS_IMETHODIMP SVGImageElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
   *aHeight = Height().get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedLength>
 SVGImageElement::Height()
 {
-  nsCOMPtr<nsIDOMSVGAnimatedLength> height;
-  mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(getter_AddRefs(height), this);
-  return height.forget();
+  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
 SVGImageElement::GetPreserveAspectRatio(nsISupports
                                         **aPreserveAspectRatio)
 {
   *aPreserveAspectRatio = PreserveAspectRatio().get();
--- a/content/svg/content/src/SVGRectElement.cpp
+++ b/content/svg/content/src/SVGRectElement.cpp
@@ -66,94 +66,82 @@ NS_IMETHODIMP SVGRectElement::GetX(nsIDO
 {
   *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();
+  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
 NS_IMETHODIMP SVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
   *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();
+  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
 NS_IMETHODIMP SVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
   *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();
+  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
 NS_IMETHODIMP SVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
   *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();
+  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength rx; */
 NS_IMETHODIMP SVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
 {
   *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();
+  return mLengthAttributes[ATTR_RX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength ry; */
 NS_IMETHODIMP SVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
 {
   *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();
+  return mLengthAttributes[ATTR_RY].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
 SVGRectElement::HasValidDimensions() const
 {
--- a/content/svg/content/src/nsSVGLength2.cpp
+++ b/content/svg/content/src/nsSVGLength2.cpp
@@ -481,25 +481,31 @@ nsSVGLength2::SetAnimValue(float aValue,
                                                            mSpecifiedUnitType),
                                aSVGElement);
 }
 
 nsresult
 nsSVGLength2::ToDOMAnimatedLength(nsIDOMSVGAnimatedLength **aResult,
                                   nsSVGElement *aSVGElement)
 {
+  *aResult = ToDOMAnimatedLength(aSVGElement).get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+nsSVGLength2::ToDOMAnimatedLength(nsSVGElement* aSVGElement)
+{
   nsRefPtr<DOMAnimatedLength> domAnimatedLength =
     sSVGAnimatedLengthTearoffTable.GetTearoff(this);
   if (!domAnimatedLength) {
     domAnimatedLength = new DOMAnimatedLength(this, aSVGElement);
     sSVGAnimatedLengthTearoffTable.AddTearoff(this, domAnimatedLength);
   }
 
-  domAnimatedLength.forget(aResult);
-  return NS_OK;
+  return domAnimatedLength.forget();
 }
 
 nsSVGLength2::DOMAnimatedLength::~DOMAnimatedLength()
 {
   sSVGAnimatedLengthTearoffTable.RemoveTearoff(mVal);
 }
 
 nsISMILAttr*
--- a/content/svg/content/src/nsSVGLength2.h
+++ b/content/svg/content/src/nsSVGLength2.h
@@ -80,16 +80,20 @@ public:
   // explicitly set by markup or a DOM call), false otherwise.
   // If this returns false, the animated value is still valid, that is,
   // useable, and represents the default base value of the attribute.
   bool IsExplicitlySet() const
     { return mIsAnimated || mIsBaseSet; }
   
   nsresult ToDOMAnimatedLength(nsIDOMSVGAnimatedLength **aResult,
                                nsSVGElement* aSVGElement);
+
+  already_AddRefed<nsIDOMSVGAnimatedLength>
+  ToDOMAnimatedLength(nsSVGElement* aSVGElement);
+
   // Returns a new nsISMILAttr object that the caller must delete
   nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
 
 private:
   
   float mAnimVal;
   float mBaseVal;
   uint8_t mSpecifiedUnitType;