зеркало из https://github.com/mozilla/gecko-dev.git
Bug 791777 - Replaced NS_finite() with mozilla::IsFinite. r=froydnj
This commit is contained in:
Родитель
fbfcc287e9
Коммит
b7608857c2
|
@ -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); \
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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<const char16_t>& aIter,
|
|||
return false;
|
||||
}
|
||||
floatType floatValue = floatType(value);
|
||||
if (!NS_finite(floatValue)) {
|
||||
if (!IsFinite(floatValue)) {
|
||||
return false;
|
||||
}
|
||||
aValue = floatValue;
|
||||
|
|
|
@ -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<float>::quiet_NaN();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "nsSMILValue.h"
|
||||
#include "SVGLengthList.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "nsError.h"
|
||||
#include <math.h>
|
||||
#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>
|
|||
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>
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "nsSMILValue.h"
|
||||
#include "SVGNumberList.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include <math.h>
|
||||
|
||||
/* 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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "nsSMILValue.h"
|
||||
#include "SVGPointList.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include <math.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "prlog.h"
|
||||
#include <algorithm>
|
||||
#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();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче