Bug 743888 - Part 2: Update SVG exception types. r=jwatt
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Wed, 13 Jun 2012 21:12:37 -0400
changeset 96650 c051f2810865b39db2e839119fb58ca6b6dd5f2f
parent 96649 42056a433aee57856fd01cb15b30d2879822c381
child 96651 66b45adcc4c5326ec0080556705140cb55d6e80f
push id22925
push useremorley@mozilla.com
push dateThu, 14 Jun 2012 09:21:42 +0000
treeherdermozilla-central@85e31a4bdd41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs743888
milestone16.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 743888 - Part 2: Update SVG exception types. r=jwatt
content/svg/content/src/DOMSVGMatrix.cpp
content/svg/content/src/DOMSVGStringList.cpp
content/svg/content/src/SVGTransform.cpp
content/svg/content/src/nsSVGSVGElement.cpp
content/svg/content/src/nsSVGViewElement.cpp
content/svg/content/test/test_SVGMatrix.xhtml
--- a/content/svg/content/src/DOMSVGMatrix.cpp
+++ b/content/svg/content/src/DOMSVGMatrix.cpp
@@ -230,17 +230,17 @@ NS_IMETHODIMP DOMSVGMatrix::Rotate(float
 /* nsIDOMSVGMatrix rotateFromVector (in float x, in float y); */
 NS_IMETHODIMP DOMSVGMatrix::RotateFromVector(float x, float y,
                                              nsIDOMSVGMatrix **_retval)
 {
   *_retval = nsnull;
   NS_ENSURE_FINITE2(x, y, NS_ERROR_ILLEGAL_VALUE);
 
   if (x == 0.0 || y == 0.0)
-    return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
+    return NS_ERROR_RANGE_ERR;
 
   NS_ADDREF(*_retval =
     new DOMSVGMatrix(gfxMatrix(Matrix()).Rotate(atan2(y, x))));
   return NS_OK;
 }
 
 /* nsIDOMSVGMatrix flipX (); */
 NS_IMETHODIMP DOMSVGMatrix::FlipX(nsIDOMSVGMatrix **_retval)
@@ -264,34 +264,34 @@ NS_IMETHODIMP DOMSVGMatrix::FlipY(nsIDOM
 
 /* nsIDOMSVGMatrix skewX (in float angle); */
 NS_IMETHODIMP DOMSVGMatrix::SkewX(float angle, nsIDOMSVGMatrix **_retval)
 {
   *_retval = nsnull;
   NS_ENSURE_FINITE(angle, NS_ERROR_ILLEGAL_VALUE);
 
   double ta = tan( angle*radPerDegree );
-  NS_ENSURE_FINITE(ta, NS_ERROR_DOM_SVG_INVALID_VALUE_ERR);
+  NS_ENSURE_FINITE(ta, NS_ERROR_RANGE_ERR);
 
   const gfxMatrix& mx = Matrix();
   gfxMatrix skewMx(mx.xx, mx.yx,
                    (float) (mx.xy + mx.xx*ta), (float) (mx.yy + mx.yx*ta),
                    mx.x0, mx.y0);
   NS_ADDREF(*_retval = new DOMSVGMatrix(skewMx));
   return NS_OK;
 }
 
 /* nsIDOMSVGMatrix skewY (in float angle); */
 NS_IMETHODIMP DOMSVGMatrix::SkewY(float angle, nsIDOMSVGMatrix **_retval)
 {
   *_retval = nsnull;
   NS_ENSURE_FINITE(angle, NS_ERROR_ILLEGAL_VALUE);
 
   double ta = tan( angle*radPerDegree );
-  NS_ENSURE_FINITE(ta, NS_ERROR_DOM_SVG_INVALID_VALUE_ERR);
+  NS_ENSURE_FINITE(ta, NS_ERROR_RANGE_ERR);
 
   const gfxMatrix& mx = Matrix();
   gfxMatrix skewMx((float) (mx.xx + mx.xy*ta), (float) (mx.yx + mx.yy*ta),
                    mx.xy, mx.yy,
                    mx.x0, mx.y0);
   NS_ADDREF(*_retval = new DOMSVGMatrix(skewMx));
   return NS_OK;
 }
--- a/content/svg/content/src/DOMSVGStringList.cpp
+++ b/content/svg/content/src/DOMSVGStringList.cpp
@@ -108,17 +108,17 @@ DOMSVGStringList::GetItem(PRUint32 index
 }
 
 NS_IMETHODIMP
 DOMSVGStringList::InsertItemBefore(const nsAString & newItem,
                                    PRUint32 index,
                                    nsAString & _retval)
 {
   if (newItem.IsEmpty()) { // takes care of DOMStringIsNull too
-    return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
+    return NS_ERROR_DOM_SYNTAX_ERR;
   }
   index = NS_MIN(index, InternalList().Length());
 
   // Ensure we have enough memory so we can avoid complex error handling below:
   if (!InternalList().SetCapacity(InternalList().Length() + 1)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
@@ -134,17 +134,17 @@ DOMSVGStringList::InsertItemBefore(const
 }
 
 NS_IMETHODIMP
 DOMSVGStringList::ReplaceItem(const nsAString & newItem,
                               PRUint32 index,
                               nsAString & _retval)
 {
   if (newItem.IsEmpty()) { // takes care of DOMStringIsNull too
-    return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
+    return NS_ERROR_DOM_SYNTAX_ERR;
   }
   if (index >= InternalList().Length()) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   }
 
   _retval = InternalList()[index];
   nsAttrValue emptyOrOldValue =
     mElement->WillChangeStringList(mIsConditionalProcessingAttribute,
--- a/content/svg/content/src/SVGTransform.cpp
+++ b/content/svg/content/src/SVGTransform.cpp
@@ -120,32 +120,32 @@ SVGTransform::SetRotate(float aAngle, fl
   mOriginX = aCx;
   mOriginY = aCy;
 }
 
 nsresult
 SVGTransform::SetSkewX(float aAngle)
 {
   double ta = tan(aAngle*radPerDegree);
-  NS_ENSURE_FINITE(ta, NS_ERROR_DOM_SVG_INVALID_VALUE_ERR);
+  NS_ENSURE_FINITE(ta, NS_ERROR_RANGE_ERR);
 
   mType    = nsIDOMSVGTransform::SVG_TRANSFORM_SKEWX;
   mMatrix.Reset();
   mMatrix.xy = ta;
   mAngle   = aAngle;
   mOriginX = 0.f;
   mOriginY = 0.f;
   return NS_OK;
 }
 
 nsresult
 SVGTransform::SetSkewY(float aAngle)
 {
   double ta = tan(aAngle*radPerDegree);
-  NS_ENSURE_FINITE(ta, NS_ERROR_DOM_SVG_INVALID_VALUE_ERR);
+  NS_ENSURE_FINITE(ta, NS_ERROR_RANGE_ERR);
 
   mType    = nsIDOMSVGTransform::SVG_TRANSFORM_SKEWY;
   mMatrix.Reset();
   mMatrix.yx = ta;
   mAngle   = aAngle;
   mOriginX = 0.f;
   mOriginY = 0.f;
   return NS_OK;
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -728,17 +728,17 @@ NS_IMETHODIMP
 nsSVGSVGElement::SetZoomAndPan(PRUint16 aZoomAndPan)
 {
   if (aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE ||
       aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
     mEnumAttributes[ZOOMANDPAN].SetBaseValue(aZoomAndPan, this);
     return NS_OK;
   }
 
-  return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
+  return NS_ERROR_RANGE_ERR;
 }
 
 //----------------------------------------------------------------------
 // helper methods for implementing SVGZoomEvent:
 
 NS_IMETHODIMP
 nsSVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y)
 {
--- a/content/svg/content/src/nsSVGViewElement.cpp
+++ b/content/svg/content/src/nsSVGViewElement.cpp
@@ -73,17 +73,17 @@ NS_IMETHODIMP
 nsSVGViewElement::SetZoomAndPan(PRUint16 aZoomAndPan)
 {
   if (aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE ||
       aZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
     mEnumAttributes[ZOOMANDPAN].SetBaseValue(aZoomAndPan, this);
     return NS_OK;
   }
 
-  return NS_ERROR_DOM_SVG_INVALID_VALUE_ERR;
+  return NS_ERROR_RANGE_ERR;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGFitToViewBox methods
 
 /* readonly attribute nsIDOMSVGAnimatedRect viewBox; */
 NS_IMETHODIMP
 nsSVGViewElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
--- a/content/svg/content/test/test_SVGMatrix.xhtml
+++ b/content/svg/content/test/test_SVGMatrix.xhtml
@@ -82,18 +82,18 @@ function testInverse()
     "Unexpected result after inverting matrix");
 
   // Test non-invertable
   m = createMatrix(0, 0, 1, 0, 0, 0);
   try {
     m.inverse();
     ok(false, "Failed to throw exception when inverting singular matrix");
   } catch (e) {
-    is(e.code, SVGException.SVG_MATRIX_NOT_INVERTABLE,
-      "Got unexpected exception " + e + ", expected SVG_MATRIX_NOT_INVERTABLE");
+    is(e.name, "InvalidStateError",
+      "Got unexpected exception " + e + ", expected InvalidStateError");
   }
 }
 
 // SVGMatrix translate(in float x, in float y);
 function testTranslate()
 {
   var m = createMatrix(2, 0, 0, 1, 120, 100);
   roughCmpMatrix(m.translate(100, -50), [2, 0, 0, 1, 320, 50],
@@ -139,18 +139,18 @@ function testRotateFromVector()
                   120, 100],
                  "Unexpected result after rotateFromVector");
 
   // Test bad input (1)
   try {
     m.rotateFromVector(1, 0);
     ok(false, "Failed to throw exception with zero coord for rotateFromVector");
   } catch (e) {
-    is(e.code, SVGException.SVG_INVALID_VALUE_ERR,
-      "Got unexpected exception " + e + ", expected SVG_INVALID_VALUE_ERR");
+    is(e.name, "RangeError",
+      "Got unexpected exception " + e + ", expected TypeError");
   }
 
   // Test bad input (2)
   try {
     m.rotateFromVector(0, 1);
     ok(false, "Failed to throw exception with zero coord for rotateFromVector");
   } catch (e) { }
 }