Bug 666984 - Remove/substitute NS_FloatIsFinite since it does the same thing as NS_finite; r=jwatt
authorEd Morley <bmo@edmorley.co.uk>
Mon, 01 Aug 2011 13:43:23 -0400
changeset 73614 c5e091d2dd3818c80adfddef95a376dca99494bb
parent 73613 158f91502fffc61a65cc2cff7ea477caaa502bab
child 73615 293ae1bcbc12325289eff8cd396466565e5d0689
push id886
push userbzbarsky@mozilla.com
push dateMon, 01 Aug 2011 17:43:42 +0000
treeherdermozilla-inbound@293ae1bcbc12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs666984
milestone8.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 666984 - Remove/substitute NS_FloatIsFinite since it does the same thing as NS_finite; r=jwatt
content/base/public/nsContentUtils.h
content/svg/content/src/DOMSVGLength.cpp
content/svg/content/src/DOMSVGPoint.h
content/svg/content/src/SVGLength.cpp
content/svg/content/src/SVGLength.h
content/svg/content/src/SVGLengthListSMILType.cpp
content/svg/content/src/SVGNumberList.cpp
content/svg/content/src/SVGNumberListSMILType.cpp
content/svg/content/src/SVGPoint.h
content/svg/content/src/SVGPointList.cpp
content/svg/content/src/SVGPointListSMILType.cpp
content/svg/content/src/nsSVGAngle.cpp
content/svg/content/src/nsSVGDataParser.cpp
content/svg/content/src/nsSVGIntegerPair.cpp
content/svg/content/src/nsSVGLength2.cpp
content/svg/content/src/nsSVGNumber2.cpp
content/svg/content/src/nsSVGNumberPair.cpp
content/svg/content/src/nsSVGTransformSMILAttr.cpp
content/svg/content/src/nsSVGViewBox.cpp
xpcom/ds/nsMathUtils.h
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -77,16 +77,17 @@ static fp_except_t oldmask = fpsetmask(~
 #include "nsTextFragment.h"
 #include "nsReadableUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "nsINode.h"
 #include "nsHashtable.h"
 #include "nsIDOMNode.h"
 #include "nsAHtml5FragmentParser.h"
 #include "nsIFragmentContentSink.h"
+#include "nsMathUtils.h"
 
 struct nsNativeKeyEvent; // Don't include nsINativeKeyBindings.h here: it will force strange compilation error!
 
 class nsIDOMScriptObjectFactory;
 class nsIXPConnect;
 class nsIContent;
 class nsIDOMKeyEvent;
 class nsIDocument;
@@ -2030,59 +2031,47 @@ public:
 #if defined(XP_WIN)
 #define DOUBLE_COMPARE(LVAL, OP, RVAL)                                  \
     (!DOUBLE_IS_NaN(LVAL) && !DOUBLE_IS_NaN(RVAL) && (LVAL) OP (RVAL))
 #else
 #define DOUBLE_COMPARE(LVAL, OP, RVAL) ((LVAL) OP (RVAL))
 #endif
 
 /*
- * Check whether a floating point number is finite (not +/-infinity and not a
- * NaN value).
- */
-inline NS_HIDDEN_(PRBool) NS_FloatIsFinite(jsdouble f) {
-#ifdef WIN32
-  return _finite(f);
-#else
-  return finite(f);
-#endif
-}
-
-/*
  * In the following helper macros we exploit the fact that the result of a
  * series of additions will not be finite if any one of the operands in the
  * series is not finite.
  */
 #define NS_ENSURE_FINITE(f, rv)                                               \
-  if (!NS_FloatIsFinite(f)) {                                                 \
+  if (!NS_finite(f)) {                                                        \
     return (rv);                                                              \
   }
 
 #define NS_ENSURE_FINITE2(f1, f2, rv)                                         \
-  if (!NS_FloatIsFinite((f1)+(f2))) {                                         \
+  if (!NS_finite((f1)+(f2))) {                                                \
     return (rv);                                                              \
   }
 
 #define NS_ENSURE_FINITE3(f1, f2, f3, rv)                                     \
-  if (!NS_FloatIsFinite((f1)+(f2)+(f3))) {                                    \
+  if (!NS_finite((f1)+(f2)+(f3))) {                                           \
     return (rv);                                                              \
   }
 
 #define NS_ENSURE_FINITE4(f1, f2, f3, f4, rv)                                 \
-  if (!NS_FloatIsFinite((f1)+(f2)+(f3)+(f4))) {                               \
+  if (!NS_finite((f1)+(f2)+(f3)+(f4))) {                                      \
     return (rv);                                                              \
   }
 
 #define NS_ENSURE_FINITE5(f1, f2, f3, f4, f5, rv)                             \
-  if (!NS_FloatIsFinite((f1)+(f2)+(f3)+(f4)+(f5))) {                          \
+  if (!NS_finite((f1)+(f2)+(f3)+(f4)+(f5))) {                                 \
     return (rv);                                                              \
   }
 
 #define NS_ENSURE_FINITE6(f1, f2, f3, f4, f5, f6, rv)                         \
-  if (!NS_FloatIsFinite((f1)+(f2)+(f3)+(f4)+(f5)+(f6))) {                     \
+  if (!NS_finite((f1)+(f2)+(f3)+(f4)+(f5)+(f6))) {                            \
     return (rv);                                                              \
   }
 
 // Deletes a linked list iteratively to avoid blowing up the stack (bug 460444).
 #define NS_CONTENT_DELETE_LIST_MEMBER(type_, ptr_, member_)                   \
   {                                                                           \
     type_ *cur = (ptr_)->member_;                                             \
     (ptr_)->member_ = nsnull;                                                 \
--- a/content/svg/content/src/DOMSVGLength.cpp
+++ b/content/svg/content/src/DOMSVGLength.cpp
@@ -37,16 +37,17 @@
 #include "DOMSVGLength.h"
 #include "DOMSVGLengthList.h"
 #include "DOMSVGAnimatedLengthList.h"
 #include "SVGLength.h"
 #include "SVGAnimatedLengthList.h"
 #include "nsSVGElement.h"
 #include "nsIDOMSVGLength.h"
 #include "nsDOMError.h"
+#include "nsMathUtils.h"
 
 // See the architecture comment in DOMSVGAnimatedLengthList.h.
 
 namespace mozilla {
 
 // We could use NS_IMPL_CYCLE_COLLECTION_1, except that in Unlink() we need to
 // clear our list's weak ref to us to be safe. (The other option would be to
 // not unlink and rely on the breaking of the other edges in the cycle, as
@@ -124,17 +125,17 @@ DOMSVGLength::GetValue(float* aValue)
 {
 #ifdef MOZ_SMIL
   if (mIsAnimValItem && HasOwner()) {
     Element()->FlushAnimations(); // May make HasOwner() == PR_FALSE
   }
 #endif
   if (HasOwner()) {
     *aValue = InternalItem().GetValueInUserUnits(Element(), Axis());
-    if (NS_FloatIsFinite(*aValue)) {
+    if (NS_finite(*aValue)) {
       return NS_OK;
     }
   } else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER ||
              mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) {
     *aValue = mValue;
     return NS_OK;
   }
   // else [SVGWG issue] Can't convert this length's value to user units
--- a/content/svg/content/src/DOMSVGPoint.h
+++ b/content/svg/content/src/DOMSVGPoint.h
@@ -38,16 +38,17 @@
 #define MOZILLA_DOMSVGPOINT_H__
 
 #include "nsIDOMSVGPoint.h"
 #include "DOMSVGPointList.h"
 #include "SVGPoint.h"
 #include "gfxPoint.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAutoPtr.h"
+#include "nsMathUtils.h"
 
 class nsSVGElement;
 
 // We make DOMSVGPoint a pseudo-interface to allow us to QI to it in order to
 // check that the objects that scripts pass to DOMSVGPointList methods are
 // our *native* point objects.
 //
 // {d6b6c440-af8d-40ee-856b-02a317cab275}
@@ -123,17 +124,17 @@ public:
   DOMSVGPoint(const gfxPoint &aPt)
     : mList(nsnull)
     , mListIndex(0)
     , mIsReadonly(PR_FALSE)
     , mIsAnimValItem(PR_FALSE)
   {
     mPt.mX = float(aPt.x);
     mPt.mY = float(aPt.y);
-    NS_ASSERTION(NS_FloatIsFinite(mPt.mX) && NS_FloatIsFinite(mPt.mX),
+    NS_ASSERTION(NS_finite(mPt.mX) && NS_finite(mPt.mX),
                  "DOMSVGPoint coords are not finite");
   }
 
 
   ~DOMSVGPoint() {
     // Our mList's weak ref to us must be nulled out when we die. If GC has
     // unlinked us using the cycle collector code, then that has already
     // happened, and mList is null.
--- a/content/svg/content/src/SVGLength.cpp
+++ b/content/svg/content/src/SVGLength.cpp
@@ -34,19 +34,19 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SVGLength.h"
 #include "nsSVGElement.h"
 #include "nsSVGSVGElement.h"
 #include "nsString.h"
 #include "nsSVGUtils.h"
-#include "nsContentUtils.h"
 #include "nsTextFormatter.h"
 #include "prdtoa.h"
+#include "nsMathUtils.h"
 #include <limits>
 
 namespace mozilla {
 
 // Declare some helpers defined below:
 static void GetUnitString(nsAString& unit, PRUint16 unitType);
 static PRUint16 GetUnitTypeForString(const char* unitStr);
 
@@ -73,17 +73,17 @@ SVGLength::SetValueFromString(const nsAS
   NS_ConvertUTF16toUTF8 value(aValue);
   const char *str = value.get();
 
   while (*str != '\0' && IsSVGWhitespace(*str)) {
     ++str;
   }
   char *unit;
   tmpValue = float(PR_strtod(str, &unit));
-  if (unit != str && NS_FloatIsFinite(tmpValue)) {
+  if (unit != str && NS_finite(tmpValue)) {
     char *theRest = unit;
     if (*unit != '\0' && !IsSVGWhitespace(*unit)) {
       while (*theRest != '\0' && !IsSVGWhitespace(*theRest)) {
         ++theRest;
       }
       nsCAutoString unitStr(unit, theRest - unit);
       tmpUnit = GetUnitTypeForString(unitStr.get());
       if (tmpUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN) {
@@ -167,27 +167,27 @@ SVGLength::GetValueInSpecifiedUnit(PRUin
   // succeed if aElement is non-null (although that's not sufficent to
   // guarantee success).
 
   float userUnitsPerCurrentUnit = GetUserUnitsPerUnit(aElement, aAxis);
   float userUnitsPerNewUnit =
     SVGLength(0.0f, aUnit).GetUserUnitsPerUnit(aElement, aAxis);
 
   NS_ASSERTION(userUnitsPerCurrentUnit >= 0 ||
-               !NS_FloatIsFinite(userUnitsPerCurrentUnit),
+               !NS_finite(userUnitsPerCurrentUnit),
                "bad userUnitsPerCurrentUnit");
   NS_ASSERTION(userUnitsPerNewUnit >= 0 ||
-               !NS_FloatIsFinite(userUnitsPerNewUnit),
+               !NS_finite(userUnitsPerNewUnit),
                "bad userUnitsPerNewUnit");
 
   float value = mValue * userUnitsPerCurrentUnit / userUnitsPerNewUnit;
 
   // userUnitsPerCurrentUnit could be infinity, or userUnitsPerNewUnit could
   // be zero.
-  if (NS_FloatIsFinite(value)) {
+  if (NS_finite(value)) {
     return value;
   }
   return std::numeric_limits<float>::quiet_NaN();
 }
 
 #define INCHES_PER_MM_FLOAT float(0.0393700787)
 #define INCHES_PER_CM_FLOAT float(0.393700787)
 
--- a/content/svg/content/src/SVGLength.h
+++ b/content/svg/content/src/SVGLength.h
@@ -35,17 +35,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MOZILLA_SVGLENGTH_H__
 #define MOZILLA_SVGLENGTH_H__
 
 #include "nsIDOMSVGLength.h"
 #include "nsIContent.h"
 #include "nsAString.h"
-#include "nsContentUtils.h"
+#include "nsMathUtils.h"
 
 class nsSVGElement;
 
 namespace mozilla {
 
 /**
  * This SVGLength class is currently used for SVGLength *list* attributes only.
  * The class that is currently used for <length> attributes is nsSVGLength2.
@@ -147,17 +147,17 @@ public:
    * converted to this length's current unit, in which case it returns PR_FALSE
    * (and the length is left unchanged).
    */
   PRBool SetFromUserUnitValue(float aUserUnitValue,
                               nsSVGElement *aElement,
                               PRUint8 aAxis) {
     float uuPerUnit = GetUserUnitsPerUnit(aElement, aAxis);
     float value = aUserUnitValue / uuPerUnit;
-    if (uuPerUnit > 0 && NS_FloatIsFinite(value)) {
+    if (uuPerUnit > 0 && NS_finite(value)) {
       mValue = value;
       NS_ASSERTION(IsValid(), "Set invalid SVGLength");
       return PR_TRUE;
     }
     return PR_FALSE;
   }
 
   /**
@@ -174,17 +174,17 @@ public:
    * Convert this length's value to the unit specified.
    *
    * This method returns PR_TRUE, unless it isn't possible to convert the
    * length to the specified unit. In that case the length is left unchanged
    * and this method returns PR_FALSE.
    */
   PRBool ConvertToUnit(PRUint32 aUnit, nsSVGElement *aElement, PRUint8 aAxis) {
     float val = GetValueInSpecifiedUnit(aUnit, aElement, aAxis);
-    if (NS_FloatIsFinite(val)) {
+    if (NS_finite(val)) {
       mValue = val;
       mUnit = aUnit;
       NS_ASSERTION(IsValid(), "Set invalid SVGLength");
       return PR_TRUE;
     }
     return PR_FALSE;
   }
 
@@ -196,17 +196,17 @@ public:
     return unit > nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN &&
            unit <= nsIDOMSVGLength::SVG_LENGTHTYPE_PC;
   }
 
 private:
 
 #ifdef DEBUG
   PRBool IsValid() const {
-    return NS_FloatIsFinite(mValue) && IsValidUnitType(mUnit);
+    return NS_finite(mValue) && IsValidUnitType(mUnit);
   }
 #endif
 
   /**
    * Returns the number of user units per current unit.
    *
    * This method returns numeric_limits<float>::quiet_NaN() if the conversion
    * factor between the length's current unit and user units is undefined (see
--- a/content/svg/content/src/SVGLengthListSMILType.cpp
+++ b/content/svg/content/src/SVGLengthListSMILType.cpp
@@ -32,16 +32,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SVGLengthListSMILType.h"
 #include "nsSMILValue.h"
 #include "SVGLengthList.h"
+#include "nsMathUtils.h"
 #include <math.h>
 
 namespace mozilla {
 
 /*static*/ SVGLengthListSMILType SVGLengthListSMILType::sSingleton;
 
 //----------------------------------------------------------------------
 // nsISMILType implementation
@@ -247,17 +248,17 @@ SVGLengthListSMILType::ComputeDistance(c
     total += f * f;
   }
   for (; i < to.Length(); ++i) {
     double t = to[i].GetValueInUserUnits(to.Element(), to.Axis());
     total += t * t;
   }
 
   float distance = sqrt(total);
-  if (!NS_FloatIsFinite(distance)) {
+  if (!NS_finite(distance)) {
     return NS_ERROR_FAILURE;
   }
   aDistance = distance;
   return NS_OK;
 }
 
 nsresult
 SVGLengthListSMILType::Interpolate(const nsSMILValue& aStartVal,
--- a/content/svg/content/src/SVGNumberList.cpp
+++ b/content/svg/content/src/SVGNumberList.cpp
@@ -34,23 +34,23 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SVGNumberList.h"
 #include "SVGAnimatedNumberList.h"
 #include "nsSVGElement.h"
 #include "nsISVGValueUtils.h"
 #include "nsDOMError.h"
-#include "nsContentUtils.h"
 #include "nsString.h"
 #include "nsSVGUtils.h"
 #include "string.h"
 #include "prdtoa.h"
 #include "nsTextFormatter.h"
 #include "nsCharSeparatedTokenizer.h"
+#include "nsMathUtils.h"
 
 namespace mozilla {
 
 nsresult
 SVGNumberList::CopyFrom(const SVGNumberList& rhs)
 {
   if (!mNumbers.SetCapacity(rhs.Length())) {
     // Yes, we do want fallible alloc here
@@ -93,17 +93,17 @@ SVGNumberList::SetValueFromString(const 
   while (tokenizer.hasMoreTokens()) {
     CopyUTF16toUTF8(tokenizer.nextToken(), str); // NS_ConvertUTF16toUTF8
     const char *token = str.get();
     if (token == '\0') {
       return NS_ERROR_DOM_SYNTAX_ERR; // nothing between commas
     }
     char *end;
     float num = float(PR_strtod(token, &end));
-    if (*end != '\0' || !NS_FloatIsFinite(num)) {
+    if (*end != '\0' || !NS_finite(num)) {
       return NS_ERROR_DOM_SYNTAX_ERR;
     }
     temp.AppendItem(num);
   }
   if (tokenizer.lastTokenEndedWithSeparator()) {
     return NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
   }
   return CopyFrom(temp);
--- a/content/svg/content/src/SVGNumberListSMILType.cpp
+++ b/content/svg/content/src/SVGNumberListSMILType.cpp
@@ -32,16 +32,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SVGNumberListSMILType.h"
 #include "nsSMILValue.h"
 #include "SVGNumberList.h"
+#include "nsMathUtils.h"
 #include <math.h>
 
 /* The "identity" number list for a given number list attribute (the effective
  * number list that is used if an attribute value is not specified) varies
  * widely for different number list attributes, and can depend on the value of
  * other attributes on the same element:
  *
  * http://www.w3.org/TR/SVG11/filters.html#feColorMatrixValuesAttribute
@@ -180,17 +181,17 @@ SVGNumberListSMILType::ComputeDistance(c
 
   double total = 0.0;
 
   for (PRUint32 i = 0; i < to.Length(); ++i) {
     double delta = to[i] - from[i];
     total += delta * delta;
   }
   double distance = sqrt(total);
-  if (!NS_FloatIsFinite(distance)) {
+  if (!NS_finite(distance)) {
     return NS_ERROR_FAILURE;
   }
   aDistance = distance;
 
   return NS_OK;
 }
 
 nsresult
--- a/content/svg/content/src/SVGPoint.h
+++ b/content/svg/content/src/SVGPoint.h
@@ -33,18 +33,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MOZILLA_SVGPOINT_H__
 #define MOZILLA_SVGPOINT_H__
 
 #include "nsDebug.h"
-#include "nsContentUtils.h"
 #include "gfxPoint.h"
+#include "nsMathUtils.h"
 
 namespace mozilla {
 
 /**
  * This class is currently used for point list attributes.
  *
  * The DOM wrapper class for this class is DOMSVGPoint.
  */
@@ -88,17 +88,17 @@ public:
   }
 
   operator gfxPoint() const {
     return gfxPoint(mX, mY);
   }
 
 #ifdef DEBUG
   PRBool IsValid() const {
-    return NS_FloatIsFinite(mX) && NS_FloatIsFinite(mY);
+    return NS_finite(mX) && NS_finite(mY);
   }
 #endif
 
   float mX;
   float mY;
 };
 
 inline SVGPoint operator+(const SVGPoint& aP1,
--- a/content/svg/content/src/SVGPointList.cpp
+++ b/content/svg/content/src/SVGPointList.cpp
@@ -34,23 +34,23 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "SVGPointList.h"
 #include "SVGAnimatedPointList.h"
 #include "nsSVGElement.h"
 #include "nsISVGValueUtils.h"
 #include "nsDOMError.h"
-#include "nsContentUtils.h"
 #include "nsString.h"
 #include "nsSVGUtils.h"
 #include "string.h"
 #include "prdtoa.h"
 #include "nsTextFormatter.h"
 #include "nsCharSeparatedTokenizer.h"
+#include "nsMathUtils.h"
 
 namespace mozilla {
 
 nsresult
 SVGPointList::CopyFrom(const SVGPointList& rhs)
 {
   if (!SetCapacity(rhs.Length())) {
     // Yes, we do want fallible alloc here
@@ -108,17 +108,17 @@ SVGPointList::SetValueFromString(const n
     CopyUTF16toUTF8(tokenizer.nextToken(), str1);
     const char *token1 = str1.get();
     if (*token1 == '\0') {
       rv = NS_ERROR_DOM_SYNTAX_ERR;
       break;
     }
     char *end;
     float x = float(PR_strtod(token1, &end));
-    if (end == token1 || !NS_FloatIsFinite(x)) {
+    if (end == token1 || !NS_finite(x)) {
       rv = NS_ERROR_DOM_SYNTAX_ERR;
       break;
     }
     const char *token2;
     if (*end == '-') {
       // It's possible for the token to be 10-30 which has
       // no separator but needs to be parsed as 10, -30
       token2 = end;
@@ -131,17 +131,17 @@ SVGPointList::SetValueFromString(const n
       token2 = str2.get();
       if (*token2 == '\0') {
         rv = NS_ERROR_DOM_SYNTAX_ERR;
         break;
       }
     }
 
     float y = float(PR_strtod(token2, &end));
-    if (*end != '\0' || !NS_FloatIsFinite(y)) {
+    if (*end != '\0' || !NS_finite(y)) {
       rv = NS_ERROR_DOM_SYNTAX_ERR;
       break;
     }
 
     temp.AppendItem(SVGPoint(x, y));
   }
   if (tokenizer.lastTokenEndedWithSeparator()) {
     rv = NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
--- a/content/svg/content/src/SVGPointListSMILType.cpp
+++ b/content/svg/content/src/SVGPointListSMILType.cpp
@@ -165,17 +165,17 @@ SVGPointListSMILType::ComputeDistance(co
   double total = 0.0;
 
   for (PRUint32 i = 0; i < to.Length(); ++i) {
     double dx = to[i].mX - from[i].mX;
     double dy = to[i].mY - from[i].mY;
     total += dx * dx + dy * dy;
   }
   double distance = sqrt(total);
-  if (!NS_FloatIsFinite(distance)) {
+  if (!NS_finite(distance)) {
     return NS_ERROR_FAILURE;
   }
   aDistance = distance;
 
   return NS_OK;
 }
 
 nsresult
--- a/content/svg/content/src/nsSVGAngle.cpp
+++ b/content/svg/content/src/nsSVGAngle.cpp
@@ -34,16 +34,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGAngle.h"
 #include "prdtoa.h"
 #include "nsTextFormatter.h"
 #include "nsSVGUtils.h"
 #include "nsSVGMarkerElement.h"
+#include "nsMathUtils.h"
 #ifdef MOZ_SMIL
 #include "nsSMILValue.h"
 #include "SVGOrientSMILType.h"
 #endif // MOZ_SMIL
 
 using namespace mozilla;
 
 /**
@@ -220,17 +221,17 @@ GetValueFromString(const nsAString &aVal
   NS_ConvertUTF16toUTF8 value(aValueAsString);
   const char *str = value.get();
 
   if (NS_IsAsciiWhitespace(*str))
     return NS_ERROR_DOM_SYNTAX_ERR;
   
   char *rest;
   *aValue = float(PR_strtod(str, &rest));
-  if (rest != str && NS_FloatIsFinite(*aValue)) {
+  if (rest != str && NS_finite(*aValue)) {
     *aUnitType = GetUnitTypeForString(rest);
     if (IsValidUnitType(*aUnitType)) {
       return NS_OK;
     }
   }
   
   return NS_ERROR_DOM_SYNTAX_ERR;
 }
--- a/content/svg/content/src/nsSVGDataParser.cpp
+++ b/content/svg/content/src/nsSVGDataParser.cpp
@@ -44,19 +44,19 @@
   *
   *   A subclass should implement a Match method which gets invoked from the
   *   Parse method.  The Parse method can be overridden, as required.
   *
   */
 
 
 #include "nsSVGDataParser.h"
-#include "nsContentUtils.h"
 #include "prdtoa.h"
 #include "nsSVGUtils.h"
+#include "nsMathUtils.h"
 #include <stdlib.h>
 #include <math.h>
 
 //----------------------------------------------------------------------
 // public interface
 
 nsresult
 nsSVGDataParser::Parse(const nsAString &aValue)
@@ -140,17 +140,17 @@ nsresult nsSVGDataParser::MatchNonNegati
 
   if (NS_FAILED(rv)) {
     RewindTo(pos);
     ENSURE_MATCHED(MatchIntegerConst());
   }
 
   char* end;
   *aX = float(PR_strtod(pos, &end));
-  if (pos != end && NS_FloatIsFinite(*aX)) {
+  if (pos != end && NS_finite(*aX)) {
     return NS_OK;
   }
   
   return NS_ERROR_FAILURE;
 }
 
 PRBool nsSVGDataParser::IsTokenNonNegativeNumberStarter()
 {
@@ -176,17 +176,17 @@ nsresult nsSVGDataParser::MatchNumber(fl
   }
 
   char* end;
   /* PR_strtod is not particularily fast. We only need a float and not a double so
    * we could probably use something faster here if needed. The CSS parser uses
    * nsCSSScanner::ParseNumber() instead of PR_strtod. See bug 516396 for some
    * additional info. */
   *aX = float(PR_strtod(pos, &end));
-  if (pos != end && NS_FloatIsFinite(*aX)) {
+  if (pos != end && NS_finite(*aX)) {
     return NS_OK;
   }
   
   return NS_ERROR_FAILURE;
 }
 
 PRBool nsSVGDataParser::IsTokenNumberStarter()
 {
--- a/content/svg/content/src/nsSVGIntegerPair.cpp
+++ b/content/svg/content/src/nsSVGIntegerPair.cpp
@@ -33,16 +33,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGIntegerPair.h"
 #include "nsSVGUtils.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsDOMError.h"
+#include "nsMathUtils.h"
 #ifdef MOZ_SMIL
 #include "nsSMILValue.h"
 #include "SVGIntegerPairSMILType.h"
 #endif // MOZ_SMIL
 
 using namespace mozilla;
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGIntegerPair::DOMAnimatedInteger, mSVGElement)
@@ -76,17 +77,17 @@ ParseIntegerOptionalInteger(const nsAStr
     NS_ConvertUTF16toUTF8 utf8Token(tokenizer.nextToken());
     const char *token = utf8Token.get();
     if (*token == '\0') {
       return NS_ERROR_DOM_SYNTAX_ERR; // empty string (e.g. two commas in a row)
     }
 
     char *end;
     aValues[i] = strtol(token, &end, 10);
-    if (*end != '\0' || !NS_FloatIsFinite(aValues[i])) {
+    if (*end != '\0' || !NS_finite(aValues[i])) {
       return NS_ERROR_DOM_SYNTAX_ERR; // parse error
     }
   }
   if (i == 1) {
     aValues[1] = aValues[0];
   }
 
   if (i == 0                    ||                // Too few values.
--- a/content/svg/content/src/nsSVGLength2.cpp
+++ b/content/svg/content/src/nsSVGLength2.cpp
@@ -38,16 +38,17 @@
 
 #include "nsSVGLength2.h"
 #include "prdtoa.h"
 #include "nsTextFormatter.h"
 #include "nsSVGSVGElement.h"
 #include "nsIFrame.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGAttrTearoffTable.h"
+#include "nsMathUtils.h"
 #ifdef MOZ_SMIL
 #include "nsSMILValue.h"
 #include "nsSMILFloatType.h"
 #endif // MOZ_SMIL
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGLength2::DOMBaseVal, mSVGElement)
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGLength2::DOMAnimVal, mSVGElement)
@@ -170,17 +171,17 @@ GetValueFromString(const nsAString &aVal
   NS_ConvertUTF16toUTF8 value(aValueAsString);
   const char *str = value.get();
 
   if (NS_IsAsciiWhitespace(*str))
     return NS_ERROR_DOM_SYNTAX_ERR;
   
   char *rest;
   *aValue = float(PR_strtod(str, &rest));
-  if (rest != str && NS_FloatIsFinite(*aValue)) {
+  if (rest != str && NS_finite(*aValue)) {
     *aUnitType = GetUnitTypeForString(rest);
     if (IsValidUnitType(*aUnitType)) {
       return NS_OK;
     }
   }
   
   return NS_ERROR_DOM_SYNTAX_ERR;
 }
--- a/content/svg/content/src/nsSVGNumber2.cpp
+++ b/content/svg/content/src/nsSVGNumber2.cpp
@@ -33,16 +33,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGNumber2.h"
 #include "nsSVGUtils.h"
 #include "nsTextFormatter.h"
 #include "prdtoa.h"
+#include "nsMathUtils.h"
 #ifdef MOZ_SMIL
 #include "nsSMILValue.h"
 #include "nsSMILFloatType.h"
 #endif // MOZ_SMIL
 
 class DOMSVGNumber : public nsIDOMSVGNumber
 {
 public:
@@ -94,17 +95,17 @@ GetValueFromString(const nsAString &aVal
   NS_ConvertUTF16toUTF8 value(aValueAsString);
   const char *str = value.get();
 
   if (NS_IsAsciiWhitespace(*str))
     return NS_ERROR_DOM_SYNTAX_ERR;
   
   char *rest;
   *aValue = float(PR_strtod(str, &rest));
-  if (rest == str || !NS_FloatIsFinite(*aValue)) {
+  if (rest == str || !NS_finite(*aValue)) {
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
   if (*rest == '%' && aPercentagesAllowed) {
     *aValue /= 100;
     ++rest;
   }
   if (*rest == '\0') {
     return NS_OK;
--- a/content/svg/content/src/nsSVGNumberPair.cpp
+++ b/content/svg/content/src/nsSVGNumberPair.cpp
@@ -34,16 +34,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGNumberPair.h"
 #include "nsSVGUtils.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "prdtoa.h"
 #include "nsDOMError.h"
+#include "nsMathUtils.h"
 #ifdef MOZ_SMIL
 #include "nsSMILValue.h"
 #include "SVGNumberPairSMILType.h"
 #endif // MOZ_SMIL
 
 using namespace mozilla;
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGNumberPair::DOMAnimatedNumber, mSVGElement)
@@ -77,17 +78,17 @@ ParseNumberOptionalNumber(const nsAStrin
     NS_ConvertUTF16toUTF8 utf8Token(tokenizer.nextToken());
     const char *token = utf8Token.get();
     if (*token == '\0') {
       return NS_ERROR_DOM_SYNTAX_ERR; // empty string (e.g. two commas in a row)
     }
 
     char *end;
     aValues[i] = float(PR_strtod(token, &end));
-    if (*end != '\0' || !NS_FloatIsFinite(aValues[i])) {
+    if (*end != '\0' || !NS_finite(aValues[i])) {
       return NS_ERROR_DOM_SYNTAX_ERR; // parse error
     }
   }
   if (i == 1) {
     aValues[1] = aValues[0];
   }
 
   if (i == 0 ||                                   // Too few values.
--- a/content/svg/content/src/nsSVGTransformSMILAttr.cpp
+++ b/content/svg/content/src/nsSVGTransformSMILAttr.cpp
@@ -45,16 +45,17 @@
 #include "nsSVGMatrix.h"
 #include "nsSMILValue.h"
 #include "nsSMILNullType.h"
 #include "nsISMILAnimationElement.h"
 #include "nsSVGElement.h"
 #include "nsISVGValue.h"
 #include "prdtoa.h"
 #include "prlog.h"
+#include "nsMathUtils.h"
 
 nsresult
 nsSVGTransformSMILAttr::ValueFromString(const nsAString& aStr,
                                      const nsISMILAnimationElement* aSrcElement,
                                      nsSMILValue& aValue,
                                      PRBool& aPreventCachingOfSandwich) const
 {
   NS_ENSURE_TRUE(aSrcElement, NS_ERROR_FAILURE);
@@ -230,17 +231,17 @@ nsSVGTransformSMILAttr::ParseParameterLi
   SkipWsp(start, end);
 
   int numArgsFound = 0;
 
   while (start != end) {
     char const *arg = start.get();
     char *argend;
     float f = float(PR_strtod(arg, &argend));
-    if (arg == argend || argend > end.get() || !NS_FloatIsFinite(f))
+    if (arg == argend || argend > end.get() || !NS_finite(f))
       return -1;
 
     if (numArgsFound < aNVars) {
       aVars[numArgsFound] = f;
     }
 
     start.advance(argend - arg);
     numArgsFound++;
--- a/content/svg/content/src/nsSVGViewBox.cpp
+++ b/content/svg/content/src/nsSVGViewBox.cpp
@@ -36,16 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGViewBox.h"
 #include "nsSVGUtils.h"
 #include "prdtoa.h"
 #include "nsTextFormatter.h"
 #include "nsCharSeparatedTokenizer.h"
+#include "nsMathUtils.h"
 #ifdef MOZ_SMIL
 #include "nsSMILValue.h"
 #include "SVGViewBoxSMILType.h"
 #endif // MOZ_SMIL
 
 #define NUM_VIEWBOX_COMPONENTS 4
 using namespace mozilla;
 
@@ -151,17 +152,17 @@ ToSVGViewBoxRect(const nsAString& aStr, 
     NS_ConvertUTF16toUTF8 utf8Token(tokenizer.nextToken());
     const char *token = utf8Token.get();
     if (*token == '\0') {
       return NS_ERROR_DOM_SYNTAX_ERR; // empty string (e.g. two commas in a row)
     }
 
     char *end;
     vals[i] = float(PR_strtod(token, &end));
-    if (*end != '\0' || !NS_FloatIsFinite(vals[i])) {
+    if (*end != '\0' || !NS_finite(vals[i])) {
       return NS_ERROR_DOM_SYNTAX_ERR; // parse error
     }
   }
 
   if (i != NUM_VIEWBOX_COMPONENTS ||              // Too few values.
       tokenizer.hasMoreTokens() ||                // Too many values.
       tokenizer.lastTokenEndedWithSeparator()) {  // Trailing comma.
     return NS_ERROR_DOM_SYNTAX_ERR;
--- a/xpcom/ds/nsMathUtils.h
+++ b/xpcom/ds/nsMathUtils.h
@@ -140,16 +140,20 @@ inline NS_HIDDEN_(double) NS_hypot(doubl
     return __builtin_hypot(x, y);
 #elif defined _WIN32
     return _hypot(x, y);
 #else
     return hypot(x, y);
 #endif
 }
 
+/**
+ * Check whether a floating point number is finite (not +/-infinity and not a
+ * NaN value).
+ */
 inline NS_HIDDEN_(bool) NS_finite(double d)
 {
 #ifdef WIN32
     // NOTE: '!!' casts an int to bool without spamming MSVC warning C4800.
     return !!_finite(d);
 #else
     return finite(d);
 #endif