diff --git a/accessible/src/generic/Accessible.cpp b/accessible/src/generic/Accessible.cpp index 25bbae43777e..a9a35c44a3c9 100644 --- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -1680,7 +1680,7 @@ Accessible::MinValue() const double Accessible::Step() const { - return UnspecifiedNaN(); // no mimimum increment (step) in ARIA. + return UnspecifiedNaN(); // no mimimum increment (step) in ARIA. } double @@ -3084,15 +3084,15 @@ double Accessible::AttrNumericValue(nsIAtom* aAttr) const { if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue) - return UnspecifiedNaN(); + return UnspecifiedNaN(); nsAutoString attrValue; if (!mContent->GetAttr(kNameSpaceID_None, aAttr, attrValue)) - return UnspecifiedNaN(); + return UnspecifiedNaN(); nsresult error = NS_OK; double value = attrValue.ToDouble(&error); - return NS_FAILED(error) ? UnspecifiedNaN() : value; + return NS_FAILED(error) ? UnspecifiedNaN() : value; } uint32_t diff --git a/accessible/src/generic/FormControlAccessible.cpp b/accessible/src/generic/FormControlAccessible.cpp index 435d898391bf..245d8600dd79 100644 --- a/accessible/src/generic/FormControlAccessible.cpp +++ b/accessible/src/generic/FormControlAccessible.cpp @@ -144,11 +144,11 @@ ProgressMeterAccessible::CurValue() const nsAutoString attrValue; if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue)) - return UnspecifiedNaN(); + return UnspecifiedNaN(); nsresult error = NS_OK; value = attrValue.ToDouble(&error); - return NS_FAILED(error) ? UnspecifiedNaN() : value; + return NS_FAILED(error) ? UnspecifiedNaN() : value; } template diff --git a/accessible/src/xul/XULSliderAccessible.cpp b/accessible/src/xul/XULSliderAccessible.cpp index ba1f052343e0..e6f49bd9cfe6 100644 --- a/accessible/src/xul/XULSliderAccessible.cpp +++ b/accessible/src/xul/XULSliderAccessible.cpp @@ -78,7 +78,7 @@ XULSliderAccessible::GetActionName(uint8_t aIndex, nsAString& aName) NS_ENSURE_ARG(aIndex == 0); - aName.AssignLiteral("activate"); + aName.AssignLiteral("activate"); return NS_OK; } @@ -187,11 +187,11 @@ XULSliderAccessible::GetSliderAttr(nsIAtom* aName) const nsAutoString attrValue; nsresult rv = GetSliderAttr(aName, attrValue); if (NS_FAILED(rv)) - return UnspecifiedNaN(); + return UnspecifiedNaN(); nsresult error = NS_OK; double value = attrValue.ToDouble(&error); - return NS_FAILED(error) ? UnspecifiedNaN() : value; + return NS_FAILED(error) ? UnspecifiedNaN() : value; } bool diff --git a/content/html/content/src/HTMLInputElement.h b/content/html/content/src/HTMLInputElement.h index ad7f6897b069..6393c1359f18 100644 --- a/content/html/content/src/HTMLInputElement.h +++ b/content/html/content/src/HTMLInputElement.h @@ -611,7 +611,7 @@ public: double ValueAsNumber() const { return DoesValueAsNumberApply() ? GetValueAsDecimal().toDouble() - : UnspecifiedNaN(); + : UnspecifiedNaN(); } void SetValueAsNumber(double aValue, ErrorResult& aRv); diff --git a/content/media/mediasource/MediaSource.cpp b/content/media/mediasource/MediaSource.cpp index 56d9f227258c..c19430f7eef5 100644 --- a/content/media/mediasource/MediaSource.cpp +++ b/content/media/mediasource/MediaSource.cpp @@ -80,7 +80,7 @@ double MediaSource::Duration() { if (mReadyState == MediaSourceReadyState::Closed) { - return UnspecifiedNaN(); + return UnspecifiedNaN(); } return mDuration; } @@ -197,7 +197,7 @@ MediaSource::Detach() MOZ_ASSERT(mDecoder); mDecoder->DetachMediaSource(); mDecoder = nullptr; - mDuration = UnspecifiedNaN(); + mDuration = UnspecifiedNaN(); mActiveSourceBuffers->Clear(); mSourceBuffers->Clear(); SetReadyState(MediaSourceReadyState::Closed); @@ -205,7 +205,7 @@ MediaSource::Detach() MediaSource::MediaSource(nsPIDOMWindow* aWindow) : nsDOMEventTargetHelper(aWindow) - , mDuration(UnspecifiedNaN()) + , mDuration(UnspecifiedNaN()) , mDecoder(nullptr) , mReadyState(MediaSourceReadyState::Closed) { diff --git a/content/media/mediasource/SourceBuffer.cpp b/content/media/mediasource/SourceBuffer.cpp index 8c6b01986695..b0d90105dfca 100644 --- a/content/media/mediasource/SourceBuffer.cpp +++ b/content/media/mediasource/SourceBuffer.cpp @@ -200,7 +200,7 @@ SourceBuffer::Abort(ErrorResult& aRv) } // TODO: Run reset parser algorithm. mAppendWindowStart = 0; - mAppendWindowEnd = PositiveInfinity(); + mAppendWindowEnd = PositiveInfinity(); } void @@ -239,7 +239,7 @@ SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType) : nsDOMEventTargetHelper(aMediaSource->GetParentObject()) , mMediaSource(aMediaSource) , mAppendWindowStart(0) - , mAppendWindowEnd(PositiveInfinity()) + , mAppendWindowEnd(PositiveInfinity()) , mTimestampOffset(0) , mAppendMode(SourceBufferAppendMode::Segments) , mUpdating(false) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 41c356bec6d0..b817c3a341da 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2630,12 +2630,13 @@ numericSuffixes = { def numericValue(t, v): if (t == IDLType.Tags.unrestricted_double or t == IDLType.Tags.unrestricted_float): + typeName = builtinNames[t] if v == float("inf"): - return "mozilla::PositiveInfinity()" + return "mozilla::PositiveInfinity<%s>()" % typeName if v == float("-inf"): - return "mozilla::NegativeInfinity()" + return "mozilla::NegativeInfinity<%s>()" % typeName if math.isnan(v): - return "mozilla::UnspecifiedNaN()" + return "mozilla::UnspecifiedNaN<%s>()" % typeName return "%s%s" % (v, numericSuffixes[t]) class CastableObjectUnwrapper(): diff --git a/dom/bindings/Date.cpp b/dom/bindings/Date.cpp index 6707d38596f6..115c155373b5 100644 --- a/dom/bindings/Date.cpp +++ b/dom/bindings/Date.cpp @@ -17,7 +17,7 @@ namespace mozilla { namespace dom { Date::Date() - : mMsecSinceEpoch(UnspecifiedNaN()) + : mMsecSinceEpoch(UnspecifiedNaN()) { } diff --git a/dom/xslt/base/txDouble.cpp b/dom/xslt/base/txDouble.cpp index 42847618505d..1153a12a2f78 100644 --- a/dom/xslt/base/txDouble.cpp +++ b/dom/xslt/base/txDouble.cpp @@ -105,7 +105,7 @@ public: { if (mState == eIllegal || mBuffer.IsEmpty() || (mBuffer.Length() == 1 && mBuffer[0] == '.')) { - return mozilla::UnspecifiedNaN(); + return mozilla::UnspecifiedNaN(); } return mSign*PR_strtod(mBuffer.get(), 0); } diff --git a/dom/xslt/xpath/txNumberExpr.cpp b/dom/xslt/xpath/txNumberExpr.cpp index b8986109655c..d0e427c644f3 100644 --- a/dom/xslt/xpath/txNumberExpr.cpp +++ b/dom/xslt/xpath/txNumberExpr.cpp @@ -40,15 +40,15 @@ txNumberExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult) #if defined(XP_WIN) /* XXX MSVC miscompiles such that (NaN == 0) */ if (mozilla::IsNaN(rightDbl)) - result = mozilla::UnspecifiedNaN(); + result = mozilla::UnspecifiedNaN(); else #endif if (leftDbl == 0 || mozilla::IsNaN(leftDbl)) - result = mozilla::UnspecifiedNaN(); + result = mozilla::UnspecifiedNaN(); else if (mozilla::IsNegative(leftDbl) != mozilla::IsNegative(rightDbl)) - result = mozilla::NegativeInfinity(); + result = mozilla::NegativeInfinity(); else - result = mozilla::PositiveInfinity(); + result = mozilla::PositiveInfinity(); } else result = leftDbl / rightDbl; @@ -56,7 +56,7 @@ txNumberExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult) case MODULUS: if (rightDbl == 0) { - result = mozilla::UnspecifiedNaN(); + result = mozilla::UnspecifiedNaN(); } else { #if defined(XP_WIN) diff --git a/dom/xslt/xpath/txUnionNodeTest.cpp b/dom/xslt/xpath/txUnionNodeTest.cpp index 60044e97e608..59a7832b6444 100644 --- a/dom/xslt/xpath/txUnionNodeTest.cpp +++ b/dom/xslt/xpath/txUnionNodeTest.cpp @@ -28,7 +28,7 @@ double txUnionNodeTest::getDefaultPriority() { NS_ERROR("Don't call getDefaultPriority on txUnionPattern"); - return mozilla::UnspecifiedNaN(); + return mozilla::UnspecifiedNaN(); } bool diff --git a/dom/xslt/xslt/txEXSLTFunctions.cpp b/dom/xslt/xslt/txEXSLTFunctions.cpp index dbc3c9cc01ae..825953a91b2b 100644 --- a/dom/xslt/xslt/txEXSLTFunctions.cpp +++ b/dom/xslt/xslt/txEXSLTFunctions.cpp @@ -567,20 +567,20 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext, if (nodes->isEmpty()) { return aContext->recycler()-> - getNumberResult(UnspecifiedNaN(), aResult); + getNumberResult(UnspecifiedNaN(), aResult); } bool findMax = mType == MAX; - double res = findMax ? mozilla::NegativeInfinity() : - mozilla::PositiveInfinity(); + double res = findMax ? mozilla::NegativeInfinity() : + mozilla::PositiveInfinity(); int32_t i, len = nodes->size(); for (i = 0; i < len; ++i) { nsAutoString str; txXPathNodeUtils::appendNodeValue(nodes->get(i), str); double val = txDouble::toDouble(str); if (mozilla::IsNaN(val)) { - res = UnspecifiedNaN(); + res = UnspecifiedNaN(); break; } @@ -610,8 +610,8 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext, NS_ENSURE_SUCCESS(rv, rv); bool findMax = mType == HIGHEST; - double res = findMax ? mozilla::NegativeInfinity() : - mozilla::PositiveInfinity(); + double res = findMax ? mozilla::NegativeInfinity() : + mozilla::PositiveInfinity(); int32_t i, len = nodes->size(); for (i = 0; i < len; ++i) { nsAutoString str; diff --git a/dom/xslt/xslt/txFormatNumberFunctionCall.cpp b/dom/xslt/xslt/txFormatNumberFunctionCall.cpp index ccb16848aeb2..c41b81ab1849 100644 --- a/dom/xslt/xslt/txFormatNumberFunctionCall.cpp +++ b/dom/xslt/xslt/txFormatNumberFunctionCall.cpp @@ -85,18 +85,18 @@ txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext, return aContext->recycler()->getStringResult(format->mNaN, aResult); } - if (value == mozilla::PositiveInfinity()) { + if (value == mozilla::PositiveInfinity()) { return aContext->recycler()->getStringResult(format->mInfinity, aResult); } - if (value == mozilla::NegativeInfinity()) { + if (value == mozilla::NegativeInfinity()) { nsAutoString res; res.Append(format->mMinusSign); res.Append(format->mInfinity); return aContext->recycler()->getStringResult(res, aResult); } - + // Value is a normal finite number nsAutoString prefix; nsAutoString suffix; @@ -362,7 +362,7 @@ txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext, } res.Insert((char16_t)(1 + format->mZeroDigit), resPos + 1); } - + if (!hasFraction && !intDigits && !carry) { // If we havn't added any characters we add a '0' // This can only happen for formats like '##.##' diff --git a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp index 8de4de52e326..dc97bd6b2238 100644 --- a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp +++ b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp @@ -271,7 +271,7 @@ getNumberAttr(txStylesheetAttr* aAttributes, txStylesheetCompilerState& aState, double& aNumber) { - aNumber = UnspecifiedNaN(); + aNumber = UnspecifiedNaN(); txStylesheetAttr* attr = nullptr; nsresult rv = getStyleAttr(aAttributes, aAttrCount, kNameSpaceID_None, aName, aRequired, &attr); @@ -520,7 +520,7 @@ txFnStartLREStylesheet(int32_t aNamespaceID, NS_ENSURE_SUCCESS(rv, rv); txExpandedName nullExpr; - double prio = UnspecifiedNaN(); + double prio = UnspecifiedNaN(); nsAutoPtr match(new txRootPattern()); NS_ENSURE_TRUE(match, NS_ERROR_OUT_OF_MEMORY); @@ -1113,7 +1113,7 @@ txFnStartTemplate(int32_t aNamespaceID, aState, mode); NS_ENSURE_SUCCESS(rv, rv); - double prio = UnspecifiedNaN(); + double prio = UnspecifiedNaN(); rv = getNumberAttr(aAttributes, aAttrCount, nsGkAtoms::priority, false, aState, prio); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/xslt/xslt/txXSLTPatterns.cpp b/dom/xslt/xslt/txXSLTPatterns.cpp index d4beec9979a7..2074c1bf3bde 100644 --- a/dom/xslt/xslt/txXSLTPatterns.cpp +++ b/dom/xslt/xslt/txXSLTPatterns.cpp @@ -23,7 +23,7 @@ double txUnionPattern::getDefaultPriority() { NS_ERROR("Don't call getDefaultPriority on txUnionPattern"); - return mozilla::UnspecifiedNaN(); + return mozilla::UnspecifiedNaN(); } /* diff --git a/gfx/2d/BaseRect.h b/gfx/2d/BaseRect.h index 08094a4fbda0..1ca895118c2f 100644 --- a/gfx/2d/BaseRect.h +++ b/gfx/2d/BaseRect.h @@ -6,10 +6,12 @@ #ifndef MOZILLA_GFX_BASERECT_H_ #define MOZILLA_GFX_BASERECT_H_ -#include -#include -#include #include +#include + +#include "mozilla/Assertions.h" +#include "mozilla/FloatingPoint.h" +#include "mozilla/TypeTraits.h" namespace mozilla { namespace gfx { @@ -60,10 +62,11 @@ struct BaseRect { // "Finite" means not inf and not NaN bool IsFinite() const { - return (mozilla::IsFinite(x) && - mozilla::IsFinite(y) && - mozilla::IsFinite(width) && - mozilla::IsFinite(height)); + typedef typename mozilla::Conditional::value, float, double>::Type FloatType; + return (mozilla::IsFinite(FloatType(x)) && + mozilla::IsFinite(FloatType(y)) && + mozilla::IsFinite(FloatType(width)) && + mozilla::IsFinite(FloatType(height))); } // Returns true if this rectangle contains the interior of aRect. Always diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 1ad1ac2f5e75..a88a3ea81012 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -1976,7 +1976,7 @@ void AsyncPanZoomController::TimeoutContentResponse() { void AsyncPanZoomController::UpdateZoomConstraints(const ZoomConstraints& aConstraints) { APZC_LOG("%p updating zoom constraints to %d %d %f %f\n", this, aConstraints.mAllowZoom, aConstraints.mAllowDoubleTapZoom, aConstraints.mMinZoom.scale, aConstraints.mMaxZoom.scale); - if (IsFloatNaN(aConstraints.mMinZoom.scale) || IsFloatNaN(aConstraints.mMaxZoom.scale)) { + if (IsNaN(aConstraints.mMinZoom.scale) || IsNaN(aConstraints.mMaxZoom.scale)) { NS_WARNING("APZC received zoom constraints with NaN values; dropping...\n"); return; } diff --git a/js/xpconnect/src/dictionary_helper_gen.py b/js/xpconnect/src/dictionary_helper_gen.py index e71e11fb453b..1dae0d158a66 100644 --- a/js/xpconnect/src/dictionary_helper_gen.py +++ b/js/xpconnect/src/dictionary_helper_gen.py @@ -234,9 +234,9 @@ def init_value(attribute): return "0" else: if realtype.count("double") and attribute.defvalue == "Infinity": - return "mozilla::PositiveInfinity()" + return "mozilla::PositiveInfinity()" if realtype.count("double") and attribute.defvalue == "-Infinity": - return "mozilla::NegativeInfinity()" + return "mozilla::NegativeInfinity()" if realtype.count("nsAString"): return "NS_LITERAL_STRING(\"%s\")" % attribute.defvalue if realtype.count("nsACString"):