diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index bcfb9dca43b4..07f953c5874f 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -42,8 +42,12 @@ #ifndef nsContentUtils_h___ #define nsContentUtils_h___ +#include +#if defined(XP_WIN) || defined(XP_OS2) +#include +#endif + #include "jsprvtd.h" -#include "jsnum.h" #include "nsAString.h" #include "nsIStatefulFrame.h" #include "nsINodeInfo.h" @@ -1711,20 +1715,14 @@ private: /* * Check whether a floating point number is finite (not +/-infinity and not a - * NaN value). We wrap JSDOUBLE_IS_FINITE in a function because it expects to - * take the address of its argument, and because the argument must be of type - * jsdouble to have the right size and layout of bits. - * - * Note: we could try to exploit the fact that |infinity - infinity == NaN| - * instead of using JSDOUBLE_IS_FINITE. This would produce more compact code - * and perform better by avoiding type conversions and bit twiddling. - * Unfortunately, some architectures don't guarantee that |f == f| evaluates - * to true (where f is any *finite* floating point number). See - * https://bugzilla.mozilla.org/show_bug.cgi?id=369418#c63 . To play it safe - * for gecko 1.9, we just reuse JSDOUBLE_IS_FINITE. + * NaN value). */ inline NS_HIDDEN_(PRBool) NS_FloatIsFinite(jsdouble f) { - return JSDOUBLE_IS_FINITE(f); +#ifdef WIN32 + return _finite(f); +#else + return finite(f); +#endif } /* diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index 5bc97e02ed94..e29c95913de2 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -41,6 +41,9 @@ #define _USE_MATH_DEFINES #endif #include +#if defined(XP_WIN) || defined(XP_OS2) +#include +#endif #include "prmem.h" @@ -87,7 +90,6 @@ #include "nsIDocShellTreeNode.h" #include "nsIXPConnect.h" #include "jsapi.h" -#include "jsnum.h" #include "nsTArray.h" @@ -116,7 +118,17 @@ using namespace mozilla; /* Float validation stuff */ -#define VALIDATE(_f) if (!JSDOUBLE_IS_FINITE(_f)) return PR_FALSE +static inline bool +DoubleIsFinite(double d) +{ +#ifdef WIN32 + return _finite(d); +#else + return finite(d); +#endif +} + +#define VALIDATE(_f) if (!DoubleIsFinite(_f)) return PR_FALSE /* These must take doubles as args, because JSDOUBLE_IS_FINITE expects * to take the address of its argument; we can't cast/convert in the diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index d22126de19c1..0f5889722281 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -67,7 +67,6 @@ #include "jsprvtd.h" // we are using private JS typedefs... #include "jscntxt.h" #include "jsdbgapi.h" -#include "jsnum.h" // General helper includes #include "nsGlobalWindow.h" @@ -3825,7 +3824,7 @@ nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, jsval id, PRBool *aIsNumber) jsint i = -1; - if (!JSDOUBLE_IS_INT(array_index, i)) { + if (!::JS_DoubleIsInt32(array_index, &i)) { return -1; } diff --git a/dom/src/json/nsJSON.cpp b/dom/src/json/nsJSON.cpp index 6cb362774204..b4963f88ac29 100644 --- a/dom/src/json/nsJSON.cpp +++ b/dom/src/json/nsJSON.cpp @@ -40,7 +40,6 @@ #include "jsapi.h" #include "jsdtoa.h" #include "jsprvtd.h" -#include "jsnum.h" #include "jsbool.h" #include "jsarena.h" #include "jscntxt.h" diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 50b079ec5ce9..ca475544f0b6 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -193,7 +193,6 @@ INSTALLED_HEADERS = \ jslock.h \ jslong.h \ jsmath.h \ - jsnum.h \ jsobj.h \ jsobjinlines.h \ json.h \ diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 17f69069cb0e..300b4b69c177 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -443,6 +443,12 @@ JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp) return !JSVAL_IS_NULL(tvr.value()); } +JS_PUBLIC_API(JSBool) +JS_DoubleIsInt32(jsdouble d, jsint *ip) +{ + return JSDOUBLE_IS_INT(d, *ip); +} + JS_PUBLIC_API(JSBool) JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 6e0fdbd12e41..818be2610920 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -467,6 +467,9 @@ JS_ValueToSource(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSBool) JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp); +extern JS_PUBLIC_API(JSBool) +JS_DoubleIsInt32(jsdouble d, jsint *ip); + /* * Convert a value to a number, then to an int32, according to the ECMA rules * for ToInt32.