From 4fb2f0f09c6c159b34f20855d7bbf957b859c633 Mon Sep 17 00:00:00 2001 From: Anuj Agarwal Date: Wed, 1 Oct 2014 11:26:00 +0200 Subject: [PATCH] Bug 791777 - Replaced NS_finite() with mozilla::IsFinite. r=froydnj --- content/base/public/nsContentUtils.h | 13 +++++++------ content/svg/content/src/DOMSVGLength.cpp | 15 ++++++++------- content/svg/content/src/DOMSVGPoint.h | 3 ++- content/svg/content/src/SVGContentUtils.cpp | 3 ++- content/svg/content/src/SVGLength.cpp | 6 +++--- content/svg/content/src/SVGLength.h | 3 ++- content/svg/content/src/SVGLengthListSMILType.cpp | 3 ++- content/svg/content/src/SVGMarkerElement.cpp | 3 ++- content/svg/content/src/SVGMatrix.cpp | 5 +++-- content/svg/content/src/SVGNumberListSMILType.cpp | 3 ++- content/svg/content/src/SVGPoint.h | 3 ++- content/svg/content/src/SVGPointListSMILType.cpp | 3 ++- content/svg/content/src/SVGTransform.cpp | 5 +++-- content/svg/content/src/nsSVGNumber2.h | 3 ++- content/svg/content/src/nsSVGNumberPair.h | 4 +++- dom/canvas/CanvasRenderingContext2D.cpp | 5 +++-- dom/canvas/CanvasUtils.h | 3 ++- layout/forms/nsNumberControlFrame.cpp | 3 ++- layout/generic/nsFlexContainerFrame.cpp | 5 +++-- 19 files changed, 55 insertions(+), 36 deletions(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index b8f77b15a2f..86860aee6df 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -29,6 +29,7 @@ #include "Units.h" #include "mozilla/dom/AutocompleteInfoBinding.h" #include "mozilla/dom/ScriptSettings.h" +#include "mozilla/FloatingPoint.h" #if defined(XP_WIN) // Undefine LoadImage to prevent naming conflict with Windows. @@ -2351,7 +2352,7 @@ public: if (aIID.Equals(NS_GET_IID(_interface))) { \ foundInterface = static_cast<_interface *>(_allocator); \ if (!foundInterface) { \ - *aInstancePtr = nullptr; \ + *aInstancePtr = nullptr; \ return NS_ERROR_OUT_OF_MEMORY; \ } \ } else @@ -2362,27 +2363,27 @@ public: * series is not finite. */ #define NS_ENSURE_FINITE(f, rv) \ - if (!NS_finite(f)) { \ + if (!mozilla::IsFinite(f)) { \ return (rv); \ } #define NS_ENSURE_FINITE2(f1, f2, rv) \ - if (!NS_finite((f1)+(f2))) { \ + if (!mozilla::IsFinite((f1)+(f2))) { \ return (rv); \ } #define NS_ENSURE_FINITE4(f1, f2, f3, f4, rv) \ - if (!NS_finite((f1)+(f2)+(f3)+(f4))) { \ + if (!mozilla::IsFinite((f1)+(f2)+(f3)+(f4))) { \ return (rv); \ } #define NS_ENSURE_FINITE5(f1, f2, f3, f4, f5, rv) \ - if (!NS_finite((f1)+(f2)+(f3)+(f4)+(f5))) { \ + if (!mozilla::IsFinite((f1)+(f2)+(f3)+(f4)+(f5))) { \ return (rv); \ } #define NS_ENSURE_FINITE6(f1, f2, f3, f4, f5, f6, rv) \ - if (!NS_finite((f1)+(f2)+(f3)+(f4)+(f5)+(f6))) { \ + if (!mozilla::IsFinite((f1)+(f2)+(f3)+(f4)+(f5)+(f6))) { \ return (rv); \ } diff --git a/content/svg/content/src/DOMSVGLength.cpp b/content/svg/content/src/DOMSVGLength.cpp index e87d38aecda..af92b017bc4 100644 --- a/content/svg/content/src/DOMSVGLength.cpp +++ b/content/svg/content/src/DOMSVGLength.cpp @@ -14,6 +14,7 @@ #include "nsError.h" #include "nsMathUtils.h" #include "mozilla/dom/SVGLengthBinding.h" +#include "mozilla/FloatingPoint.h" #include "nsSVGAttrTearoffTable.h" // See the architecture comment in DOMSVGAnimatedLengthList.h. @@ -228,7 +229,7 @@ DOMSVGLength::GetValue(ErrorResult& aRv) } if (HasOwner()) { float value = InternalItem().GetValueInUserUnits(Element(), Axis()); - if (!NS_finite(value)) { + if (!IsFinite(value)) { aRv.Throw(NS_ERROR_FAILURE); } return value; @@ -276,7 +277,7 @@ DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv) float uuPerUnit = InternalItem().GetUserUnitsPerUnit(Element(), Axis()); if (uuPerUnit > 0) { float newValue = aUserUnitValue / uuPerUnit; - if (NS_finite(newValue)) { + if (IsFinite(newValue)) { AutoChangeLengthNotifier notifier(this); InternalItem().SetValueAndUnit(newValue, InternalItem().GetUnit()); return; @@ -295,7 +296,7 @@ DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv) NS_IMETHODIMP DOMSVGLength::SetValue(float aUserUnitValue) { - if (!NS_finite(aUserUnitValue)) { + if (!IsFinite(aUserUnitValue)) { return NS_ERROR_ILLEGAL_VALUE; } @@ -355,7 +356,7 @@ DOMSVGLength::SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv) NS_IMETHODIMP DOMSVGLength::SetValueInSpecifiedUnits(float aValue) { - if (!NS_finite(aValue)) { + if (!IsFinite(aValue)) { return NS_ERROR_ILLEGAL_VALUE; } @@ -460,7 +461,7 @@ DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue, NS_IMETHODIMP DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue) { - if (!NS_finite(aValue)) { + if (!IsFinite(aValue)) { return NS_ERROR_ILLEGAL_VALUE; } @@ -492,7 +493,7 @@ DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv) } float val = InternalItem().GetValueInSpecifiedUnit( aUnit, Element(), Axis()); - if (NS_finite(val)) { + if (IsFinite(val)) { AutoChangeLengthNotifier notifier(this); InternalItem().SetValueAndUnit(val, aUnit); return; @@ -500,7 +501,7 @@ DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv) } else { SVGLength len(mValue, mUnit); float val = len.GetValueInSpecifiedUnit(aUnit, nullptr, 0); - if (NS_finite(val)) { + if (IsFinite(val)) { mValue = val; mUnit = aUnit; return; diff --git a/content/svg/content/src/DOMSVGPoint.h b/content/svg/content/src/DOMSVGPoint.h index edf1b607c39..6e67e6f30ff 100644 --- a/content/svg/content/src/DOMSVGPoint.h +++ b/content/svg/content/src/DOMSVGPoint.h @@ -13,6 +13,7 @@ #include "nsISVGPoint.h" #include "SVGPoint.h" #include "mozilla/Attributes.h" +#include "mozilla/FloatingPoint.h" class nsSVGElement; @@ -82,7 +83,7 @@ public: { mPt.mX = aPt.x; mPt.mY = aPt.y; - NS_ASSERTION(NS_finite(mPt.mX) && NS_finite(mPt.mX), + NS_ASSERTION(IsFinite(mPt.mX) && IsFinite(mPt.mX), "DOMSVGPoint coords are not finite"); } diff --git a/content/svg/content/src/SVGContentUtils.cpp b/content/svg/content/src/SVGContentUtils.cpp index 665e8e1fac8..d894bc6f14a 100644 --- a/content/svg/content/src/SVGContentUtils.cpp +++ b/content/svg/content/src/SVGContentUtils.cpp @@ -25,6 +25,7 @@ #include "nsContentUtils.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/Types.h" +#include "mozilla/FloatingPoint.h" #include "nsStyleContext.h" #include "nsSVGPathDataParser.h" #include "SVGPathData.h" @@ -664,7 +665,7 @@ SVGContentUtils::ParseNumber(RangedPtr& aIter, return false; } floatType floatValue = floatType(value); - if (!NS_finite(floatValue)) { + if (!IsFinite(floatValue)) { return false; } aValue = floatValue; diff --git a/content/svg/content/src/SVGLength.cpp b/content/svg/content/src/SVGLength.cpp index 076aae7f4e5..08a340d2037 100644 --- a/content/svg/content/src/SVGLength.cpp +++ b/content/svg/content/src/SVGLength.cpp @@ -124,17 +124,17 @@ SVGLength::GetValueInSpecifiedUnit(uint8_t aUnit, SVGLength(0.0f, aUnit).GetUserUnitsPerUnit(aElement, aAxis); NS_ASSERTION(userUnitsPerCurrentUnit >= 0 || - !NS_finite(userUnitsPerCurrentUnit), + !IsFinite(userUnitsPerCurrentUnit), "bad userUnitsPerCurrentUnit"); NS_ASSERTION(userUnitsPerNewUnit >= 0 || - !NS_finite(userUnitsPerNewUnit), + !IsFinite(userUnitsPerNewUnit), "bad userUnitsPerNewUnit"); float value = mValue * userUnitsPerCurrentUnit / userUnitsPerNewUnit; // userUnitsPerCurrentUnit could be infinity, or userUnitsPerNewUnit could // be zero. - if (NS_finite(value)) { + if (IsFinite(value)) { return value; } return std::numeric_limits::quiet_NaN(); diff --git a/content/svg/content/src/SVGLength.h b/content/svg/content/src/SVGLength.h index 02d1cca8edc..57b03e99258 100644 --- a/content/svg/content/src/SVGLength.h +++ b/content/svg/content/src/SVGLength.h @@ -9,6 +9,7 @@ #include "nsDebug.h" #include "nsIDOMSVGLength.h" #include "nsMathUtils.h" +#include "mozilla/FloatingPoint.h" class nsSVGElement; @@ -139,7 +140,7 @@ private: #ifdef DEBUG bool IsValid() const { - return NS_finite(mValue) && IsValidUnitType(mUnit); + return IsFinite(mValue) && IsValidUnitType(mUnit); } #endif diff --git a/content/svg/content/src/SVGLengthListSMILType.cpp b/content/svg/content/src/SVGLengthListSMILType.cpp index 64f8dbec28c..7c8718c12e6 100644 --- a/content/svg/content/src/SVGLengthListSMILType.cpp +++ b/content/svg/content/src/SVGLengthListSMILType.cpp @@ -7,6 +7,7 @@ #include "nsSMILValue.h" #include "SVGLengthList.h" #include "nsMathUtils.h" +#include "mozilla/FloatingPoint.h" #include #include @@ -216,7 +217,7 @@ SVGLengthListSMILType::ComputeDistance(const nsSMILValue& aFrom, } float distance = sqrt(total); - if (!NS_finite(distance)) { + if (!IsFinite(distance)) { return NS_ERROR_FAILURE; } aDistance = distance; diff --git a/content/svg/content/src/SVGMarkerElement.cpp b/content/svg/content/src/SVGMarkerElement.cpp index 620af71f288..012e9ed9196 100644 --- a/content/svg/content/src/SVGMarkerElement.cpp +++ b/content/svg/content/src/SVGMarkerElement.cpp @@ -14,6 +14,7 @@ #include "mozilla/dom/SVGMarkerElementBinding.h" #include "mozilla/Preferences.h" #include "mozilla/gfx/Matrix.h" +#include "mozilla/FloatingPoint.h" #include "SVGContentUtils.h" using namespace mozilla::gfx; @@ -173,7 +174,7 @@ void SVGMarkerElement::SetOrientToAngle(SVGAngle& angle, ErrorResult& rv) { float f = angle.Value(); - if (!NS_finite(f)) { + if (!IsFinite(f)) { rv.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR); return; } diff --git a/content/svg/content/src/SVGMatrix.cpp b/content/svg/content/src/SVGMatrix.cpp index 9ea9ea1e265..f48e2517d20 100644 --- a/content/svg/content/src/SVGMatrix.cpp +++ b/content/svg/content/src/SVGMatrix.cpp @@ -8,6 +8,7 @@ #include "nsError.h" #include #include "mozilla/dom/SVGMatrixBinding.h" +#include "mozilla/FloatingPoint.h" const double radPerDegree = 2.0 * M_PI / 360.0; @@ -194,7 +195,7 @@ already_AddRefed SVGMatrix::SkewX(float angle, ErrorResult& rv) { double ta = tan( angle*radPerDegree ); - if (!NS_finite(ta)) { + if (!IsFinite(ta)) { rv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return nullptr; } @@ -211,7 +212,7 @@ already_AddRefed SVGMatrix::SkewY(float angle, ErrorResult& rv) { double ta = tan( angle*radPerDegree ); - if (!NS_finite(ta)) { + if (!IsFinite(ta)) { rv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); return nullptr; } diff --git a/content/svg/content/src/SVGNumberListSMILType.cpp b/content/svg/content/src/SVGNumberListSMILType.cpp index 17b1bdc4b0e..86a738500f8 100644 --- a/content/svg/content/src/SVGNumberListSMILType.cpp +++ b/content/svg/content/src/SVGNumberListSMILType.cpp @@ -7,6 +7,7 @@ #include "nsSMILValue.h" #include "SVGNumberList.h" #include "nsMathUtils.h" +#include "mozilla/FloatingPoint.h" #include /* The "identity" number list for a given number list attribute (the effective @@ -155,7 +156,7 @@ SVGNumberListSMILType::ComputeDistance(const nsSMILValue& aFrom, total += delta * delta; } double distance = sqrt(total); - if (!NS_finite(distance)) { + if (!IsFinite(distance)) { return NS_ERROR_FAILURE; } aDistance = distance; diff --git a/content/svg/content/src/SVGPoint.h b/content/svg/content/src/SVGPoint.h index bbe23b077f1..700945f0f80 100644 --- a/content/svg/content/src/SVGPoint.h +++ b/content/svg/content/src/SVGPoint.h @@ -9,6 +9,7 @@ #include "nsDebug.h" #include "gfxPoint.h" #include "mozilla/gfx/Point.h" +#include "mozilla/FloatingPoint.h" namespace mozilla { @@ -66,7 +67,7 @@ public: #ifdef DEBUG bool IsValid() const { - return NS_finite(mX) && NS_finite(mY); + return IsFinite(mX) && IsFinite(mY); } #endif diff --git a/content/svg/content/src/SVGPointListSMILType.cpp b/content/svg/content/src/SVGPointListSMILType.cpp index 25d812b36e2..14d4d69c6c2 100644 --- a/content/svg/content/src/SVGPointListSMILType.cpp +++ b/content/svg/content/src/SVGPointListSMILType.cpp @@ -7,6 +7,7 @@ #include "nsSMILValue.h" #include "SVGPointList.h" #include "nsMathUtils.h" +#include "mozilla/FloatingPoint.h" #include namespace mozilla { @@ -135,7 +136,7 @@ SVGPointListSMILType::ComputeDistance(const nsSMILValue& aFrom, total += dx * dx + dy * dy; } double distance = sqrt(total); - if (!NS_finite(distance)) { + if (!IsFinite(distance)) { return NS_ERROR_FAILURE; } aDistance = distance; diff --git a/content/svg/content/src/SVGTransform.cpp b/content/svg/content/src/SVGTransform.cpp index 780c07eada3..da84ed97085 100644 --- a/content/svg/content/src/SVGTransform.cpp +++ b/content/svg/content/src/SVGTransform.cpp @@ -13,6 +13,7 @@ #include "nsSVGAnimatedTransformList.h" #include "nsSVGAttrTearoffTable.h" #include "mozilla/DebugOnly.h" +#include "mozilla/FloatingPoint.h" namespace { const double kRadPerDegree = 2.0 * M_PI / 360.0; @@ -263,7 +264,7 @@ SVGTransform::SetSkewX(float angle, ErrorResult& rv) return; } - if (!NS_finite(tan(angle * kRadPerDegree))) { + if (!IsFinite(tan(angle * kRadPerDegree))) { rv.Throw(NS_ERROR_RANGE_ERR); return; } @@ -286,7 +287,7 @@ SVGTransform::SetSkewY(float angle, ErrorResult& rv) return; } - if (!NS_finite(tan(angle * kRadPerDegree))) { + if (!IsFinite(tan(angle * kRadPerDegree))) { rv.Throw(NS_ERROR_RANGE_ERR); return; } diff --git a/content/svg/content/src/nsSVGNumber2.h b/content/svg/content/src/nsSVGNumber2.h index 4e951a899bb..9d7b54627cb 100644 --- a/content/svg/content/src/nsSVGNumber2.h +++ b/content/svg/content/src/nsSVGNumber2.h @@ -13,6 +13,7 @@ #include "nsMathUtils.h" #include "nsSVGElement.h" #include "mozilla/Attributes.h" +#include "mozilla/FloatingPoint.h" #include "mozilla/dom/SVGAnimatedNumber.h" class nsSMILValue; @@ -83,7 +84,7 @@ public: } virtual void SetBaseVal(float aValue) MOZ_OVERRIDE { - MOZ_ASSERT(NS_finite(aValue)); + MOZ_ASSERT(mozilla::IsFinite(aValue)); mVal->SetBaseValue(aValue, mSVGElement); } diff --git a/content/svg/content/src/nsSVGNumberPair.h b/content/svg/content/src/nsSVGNumberPair.h index 9861841db2b..b76ffd8b244 100644 --- a/content/svg/content/src/nsSVGNumberPair.h +++ b/content/svg/content/src/nsSVGNumberPair.h @@ -14,6 +14,8 @@ #include "nsSVGElement.h" #include "mozilla/Attributes.h" #include "mozilla/dom/SVGAnimatedNumber.h" +#include "mozilla/FloatingPoint.h" + class nsSMILValue; @@ -93,7 +95,7 @@ public: } virtual void SetBaseVal(float aValue) MOZ_OVERRIDE { - MOZ_ASSERT(NS_finite(aValue)); + MOZ_ASSERT(mozilla::IsFinite(aValue)); mVal->SetBaseValue(aValue, mIndex, mSVGElement); } diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index ab3ada588fc..9789aa31577 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -100,6 +100,7 @@ #include "mozilla/dom/TextMetrics.h" #include "mozilla/dom/UnionTypes.h" #include "mozilla/dom/SVGMatrix.h" +#include "mozilla/FloatingPoint.h" #include "nsGlobalWindow.h" #include "GLContext.h" #include "GLContextProvider.h" @@ -4354,8 +4355,8 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx, return nullptr; } - if (!NS_finite(aSx) || !NS_finite(aSy) || - !NS_finite(aSw) || !NS_finite(aSh)) { + if (!IsFinite(aSx) || !IsFinite(aSy) || + !IsFinite(aSw) || !IsFinite(aSh)) { error.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return nullptr; } diff --git a/dom/canvas/CanvasUtils.h b/dom/canvas/CanvasUtils.h index ba72c0da8ec..31347ee651d 100644 --- a/dom/canvas/CanvasUtils.h +++ b/dom/canvas/CanvasUtils.h @@ -9,6 +9,7 @@ #include "mozilla/CheckedInt.h" #include "mozilla/dom/ToJSValue.h" #include "jsapi.h" +#include "mozilla/FloatingPoint.h" class nsIPrincipal; @@ -53,7 +54,7 @@ void DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement, bool CoerceDouble(JS::Value v, double* d); /* Float validation stuff */ -#define VALIDATE(_f) if (!NS_finite(_f)) return false +#define VALIDATE(_f) if (!IsFinite(_f)) return false inline bool FloatValidate (double f1) { VALIDATE(f1); diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index 06fa69d80eb..a2e1d686bfc 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -23,6 +23,7 @@ #include "nsStyleSet.h" #include "nsIDOMMutationEvent.h" #include "nsThreadUtils.h" +#include "mozilla/FloatingPoint.h" #ifdef ACCESSIBILITY #include "mozilla/a11y/AccTypes.h" @@ -772,7 +773,7 @@ nsNumberControlFrame::GetValueOfAnonTextControl(nsAString& aValue) // serialization. ICUUtils::LanguageTagIterForContent langTagIter(mContent); double value = ICUUtils::ParseNumber(aValue, langTagIter); - if (NS_finite(value) && + if (IsFinite(value) && value != HTMLInputElement::StringToDecimal(aValue).toDouble()) { aValue.Truncate(); aValue.AppendFloat(value); diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index b3f449f60ac..9bb54cd0663 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -21,6 +21,7 @@ #include "prlog.h" #include #include "mozilla/LinkedList.h" +#include "mozilla/FloatingPoint.h" using namespace mozilla; using namespace mozilla::layout; @@ -2128,7 +2129,7 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) weightSum += curWeight; flexFactorSum += curFlexFactor; - if (NS_finite(weightSum)) { + if (IsFinite(weightSum)) { if (curWeight == 0.0f) { item->SetShareOfWeightSoFar(0.0f); } else { @@ -2199,7 +2200,7 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize) // To avoid rounding issues, we compute the change in size for this // item, and then subtract it from the remaining available space. nscoord sizeDelta = 0; - if (NS_finite(weightSum)) { + if (IsFinite(weightSum)) { float myShareOfRemainingSpace = item->GetShareOfWeightSoFar();