Bug 793076 (part 1) - Remove unnecessary |cx| parameters. r=jwalden.
This commit is contained in:
@@ -2005,8 +2005,8 @@ ExtractDateFromOptions(JSContext* aCx, const JS::Value& aOptions)
|
||||
nsresult rv = params.Init(aCx, &aOptions);
|
||||
if (NS_SUCCEEDED(rv) && !JSVAL_IS_VOID(params.since) && !params.since.isNull() && params.since.isObject()) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(params.since);
|
||||
if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(aCx, obj)) {
|
||||
result = js_DateGetMsecSinceEpoch(aCx, obj);
|
||||
if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(obj)) {
|
||||
result = js_DateGetMsecSinceEpoch(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,10 +170,10 @@ Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
|
||||
}
|
||||
|
||||
if (JS_ObjectIsDate(aCx, obj)) {
|
||||
if (!js_DateIsValid(aCx, obj)) {
|
||||
if (!js_DateIsValid(obj)) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
EncodeNumber(js_DateGetMsecSinceEpoch(aCx, obj), eDate + aTypeOffset);
|
||||
EncodeNumber(js_DateGetMsecSinceEpoch(obj), eDate + aTypeOffset);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ SmsFilter::SetStartDate(JSContext* aCx, const jsval& aStartDate)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mData.startDate() = js_DateGetMsecSinceEpoch(aCx, &obj);
|
||||
mData.startDate() = js_DateGetMsecSinceEpoch(&obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ SmsFilter::SetEndDate(JSContext* aCx, const jsval& aEndDate)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mData.endDate() = js_DateGetMsecSinceEpoch(aCx, &obj);
|
||||
mData.endDate() = js_DateGetMsecSinceEpoch(&obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ SmsMessage::Create(int32_t aId,
|
||||
if (!JS_ObjectIsDate(aCx, &obj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
data.timestamp() = js_DateGetMsecSinceEpoch(aCx, &obj);
|
||||
data.timestamp() = js_DateGetMsecSinceEpoch(&obj);
|
||||
} else {
|
||||
if (!aTimestamp.isNumber()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
@@ -29,12 +29,12 @@ TimeManager::Set(const JS::Value& date, JSContext* ctx) {
|
||||
if (date.isObject()) {
|
||||
JSObject* dateObj = JSVAL_TO_OBJECT(date);
|
||||
|
||||
if (JS_ObjectIsDate(ctx, dateObj) && js_DateIsValid(ctx, dateObj)) {
|
||||
dateMSec = js_DateGetMsecSinceEpoch(ctx, dateObj);
|
||||
if (JS_ObjectIsDate(ctx, dateObj) && js_DateIsValid(dateObj)) {
|
||||
dateMSec = js_DateGetMsecSinceEpoch(dateObj);
|
||||
}
|
||||
else {
|
||||
NS_WARN_IF_FALSE(JS_ObjectIsDate(ctx, dateObj), "This is not a Date object");
|
||||
NS_WARN_IF_FALSE(js_DateIsValid(ctx, dateObj), "Date is not valid");
|
||||
NS_WARN_IF_FALSE(js_DateIsValid(dateObj), "Date is not valid");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
} else if (date.isNumber()) {
|
||||
|
||||
@@ -686,7 +686,7 @@ JSStructuredCloneWriter::startWrite(const Value &v)
|
||||
return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) &&
|
||||
writeString(SCTAG_STRING, reobj.getSource());
|
||||
} else if (obj->isDate()) {
|
||||
double d = js_DateGetMsecSinceEpoch(context(), obj);
|
||||
double d = js_DateGetMsecSinceEpoch(obj);
|
||||
return out.writePair(SCTAG_DATE_OBJECT, 0) && out.writeDouble(d);
|
||||
} else if (obj->isTypedArray()) {
|
||||
return writeTypedArray(obj);
|
||||
|
||||
@@ -437,7 +437,7 @@ DaylightSavingTA(double t, JSContext *cx)
|
||||
}
|
||||
|
||||
int64_t timeMilliseconds = static_cast<int64_t>(t);
|
||||
int64_t offsetMilliseconds = cx->dstOffsetCache.getDSTOffsetMilliseconds(timeMilliseconds, cx);
|
||||
int64_t offsetMilliseconds = cx->dstOffsetCache.getDSTOffsetMilliseconds(timeMilliseconds);
|
||||
return static_cast<double>(offsetMilliseconds);
|
||||
}
|
||||
|
||||
@@ -1265,7 +1265,7 @@ date_now(JSContext *cx, unsigned argc, Value *vp)
|
||||
* Set UTC time to a given time and invalidate cached local time.
|
||||
*/
|
||||
static JSBool
|
||||
SetUTCTime(JSContext *cx, JSObject *obj, double t, Value *vp = NULL)
|
||||
SetUTCTime(JSObject *obj, double t, Value *vp = NULL)
|
||||
{
|
||||
JS_ASSERT(obj->isDate());
|
||||
|
||||
@@ -1282,10 +1282,9 @@ SetUTCTime(JSContext *cx, JSObject *obj, double t, Value *vp = NULL)
|
||||
}
|
||||
|
||||
static void
|
||||
SetDateToNaN(JSContext *cx, JSObject *obj, Value *vp = NULL)
|
||||
SetDateToNaN(JSObject *obj, Value *vp = NULL)
|
||||
{
|
||||
double NaN = cx->runtime->NaNValue.getDoubleRef();
|
||||
SetUTCTime(cx, obj, NaN, vp);
|
||||
SetUTCTime(obj, js_NaN, vp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1809,7 +1808,7 @@ date_setTime_impl(JSContext *cx, CallArgs args)
|
||||
|
||||
Rooted<JSObject*> thisObj(cx, &args.thisv().toObject());
|
||||
if (args.length() == 0) {
|
||||
SetDateToNaN(cx, thisObj, args.rval().address());
|
||||
SetDateToNaN(thisObj, args.rval().address());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1817,7 +1816,7 @@ date_setTime_impl(JSContext *cx, CallArgs args)
|
||||
if (!ToNumber(cx, args[0], &result))
|
||||
return false;
|
||||
|
||||
return SetUTCTime(cx, thisObj, TimeClip(result), args.rval().address());
|
||||
return SetUTCTime(thisObj, TimeClip(result), args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -1878,7 +1877,7 @@ date_setMilliseconds_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(MakeDate(Day(t), time), cx));
|
||||
|
||||
/* Steps 4-5. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -1909,7 +1908,7 @@ date_setUTCMilliseconds_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(MakeDate(Day(t), time));
|
||||
|
||||
/* Steps 4-5. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -1947,7 +1946,7 @@ date_setSeconds_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(date, cx));
|
||||
|
||||
/* Steps 6-7. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.31. */
|
||||
@@ -1985,7 +1984,7 @@ date_setUTCSeconds_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(date);
|
||||
|
||||
/* Steps 6-7. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.32. */
|
||||
@@ -2028,7 +2027,7 @@ date_setMinutes_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(date, cx));
|
||||
|
||||
/* Steps 7-8. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.33. */
|
||||
@@ -2071,7 +2070,7 @@ date_setUTCMinutes_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(date);
|
||||
|
||||
/* Steps 7-8. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.34. */
|
||||
@@ -2119,7 +2118,7 @@ date_setHours_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(date, cx));
|
||||
|
||||
/* Steps 7-8. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.35. */
|
||||
@@ -2167,7 +2166,7 @@ date_setUTCHours_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(newDate);
|
||||
|
||||
/* Steps 8-9. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.36. */
|
||||
@@ -2200,7 +2199,7 @@ date_setDate_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(newDate, cx));
|
||||
|
||||
/* Steps 5-6. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
/* ES5 15.9.5.37. */
|
||||
@@ -2233,7 +2232,7 @@ date_setUTCDate_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(newDate);
|
||||
|
||||
/* Steps 5-6. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -2291,7 +2290,7 @@ date_setMonth_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(newDate, cx));
|
||||
|
||||
/* Steps 6-7. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -2329,7 +2328,7 @@ date_setUTCMonth_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(newDate);
|
||||
|
||||
/* Steps 6-7. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -2388,7 +2387,7 @@ date_setFullYear_impl(JSContext *cx, CallArgs args)
|
||||
double u = TimeClip(UTC(newDate, cx));
|
||||
|
||||
/* Steps 7-8. */
|
||||
return SetUTCTime(cx, thisObj, u, args.rval().address());
|
||||
return SetUTCTime(thisObj, u, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -2431,7 +2430,7 @@ date_setUTCFullYear_impl(JSContext *cx, CallArgs args)
|
||||
double v = TimeClip(newDate);
|
||||
|
||||
/* Steps 7-8. */
|
||||
return SetUTCTime(cx, thisObj, v, args.rval().address());
|
||||
return SetUTCTime(thisObj, v, args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -2459,7 +2458,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
|
||||
|
||||
/* Step 3. */
|
||||
if (MOZ_DOUBLE_IS_NaN(y)) {
|
||||
SetDateToNaN(cx, thisObj, args.rval().address());
|
||||
SetDateToNaN(thisObj, args.rval().address());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2475,7 +2474,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
|
||||
double u = UTC(MakeDate(day, TimeWithinDay(t)), cx);
|
||||
|
||||
/* Steps 7-8. */
|
||||
return SetUTCTime(cx, thisObj, TimeClip(u), args.rval().address());
|
||||
return SetUTCTime(thisObj, TimeClip(u), args.rval().address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -3158,7 +3157,7 @@ js_InitDateClass(JSContext *cx, HandleObject obj)
|
||||
RootedObject dateProto(cx, global->createBlankPrototype(cx, &DateClass));
|
||||
if (!dateProto)
|
||||
return NULL;
|
||||
SetDateToNaN(cx, dateProto);
|
||||
SetDateToNaN(dateProto);
|
||||
|
||||
RootedFunction ctor(cx);
|
||||
ctor = global->createConstructor(cx, js_Date, cx->names().Date, MAXARGS);
|
||||
@@ -3200,7 +3199,7 @@ js_NewDateObjectMsec(JSContext *cx, double msec_time)
|
||||
JSObject *obj = NewBuiltinClassInstance(cx, &DateClass);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
if (!SetUTCTime(cx, obj, msec_time))
|
||||
if (!SetUTCTime(obj, msec_time))
|
||||
return NULL;
|
||||
return obj;
|
||||
}
|
||||
@@ -3225,7 +3224,7 @@ js_ClearDateCaches()
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_DateIsValid(JSContext *cx, JSObject* obj)
|
||||
js_DateIsValid(JSObject* obj)
|
||||
{
|
||||
return obj->isDate() && !MOZ_DOUBLE_IS_NaN(obj->getDateUTCTime().toNumber());
|
||||
}
|
||||
@@ -3287,7 +3286,7 @@ js_DateGetMinutes(JSContext *cx, JSObject* obj)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(int)
|
||||
js_DateGetSeconds(JSContext *cx, JSObject* obj)
|
||||
js_DateGetSeconds(JSObject* obj)
|
||||
{
|
||||
if (!obj->isDate())
|
||||
return 0;
|
||||
@@ -3299,7 +3298,7 @@ js_DateGetSeconds(JSContext *cx, JSObject* obj)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(double)
|
||||
js_DateGetMsecSinceEpoch(JSContext *cx, RawObject obj)
|
||||
js_DateGetMsecSinceEpoch(RawObject obj)
|
||||
{
|
||||
return obj->isDate() ? obj->getDateUTCTime().toNumber() : 0;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ extern JS_FRIEND_API(int)
|
||||
js_DateGetMinutes(JSContext *cx, JSObject* obj);
|
||||
|
||||
extern JS_FRIEND_API(int)
|
||||
js_DateGetSeconds(JSContext *cx, JSObject* obj);
|
||||
js_DateGetSeconds(JSObject* obj);
|
||||
|
||||
/* Date constructor native. Exposed only so the JIT can know its address. */
|
||||
JSBool
|
||||
|
||||
@@ -973,10 +973,10 @@ uint32_t GetListBaseExpandoSlot();
|
||||
* out-of-band for js_DateGet*)
|
||||
*/
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_DateIsValid(JSContext *cx, JSObject* obj);
|
||||
js_DateIsValid(JSObject* obj);
|
||||
|
||||
extern JS_FRIEND_API(double)
|
||||
js_DateGetMsecSinceEpoch(JSContext *cx, JSRawObject obj);
|
||||
js_DateGetMsecSinceEpoch(JSRawObject obj);
|
||||
|
||||
/* Implemented in jscntxt.cpp. */
|
||||
|
||||
|
||||
@@ -638,7 +638,7 @@ DSTOffsetCache::computeDSTOffsetMilliseconds(int64_t localTimeSeconds)
|
||||
}
|
||||
|
||||
int64_t
|
||||
DSTOffsetCache::getDSTOffsetMilliseconds(int64_t localTimeMilliseconds, JSContext *cx)
|
||||
DSTOffsetCache::getDSTOffsetMilliseconds(int64_t localTimeMilliseconds)
|
||||
{
|
||||
sanityCheck();
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ struct JSContext;
|
||||
class DSTOffsetCache {
|
||||
public:
|
||||
inline DSTOffsetCache();
|
||||
int64_t getDSTOffsetMilliseconds(int64_t localTimeMilliseconds, JSContext *cx);
|
||||
int64_t getDSTOffsetMilliseconds(int64_t localTimeMilliseconds);
|
||||
|
||||
inline void purge();
|
||||
|
||||
|
||||
@@ -137,10 +137,10 @@ convertJSValToVariant(
|
||||
if (aValue.isObject()) {
|
||||
JSObject* obj = &aValue.toObject();
|
||||
// We only support Date instances, all others fail.
|
||||
if (!::js_DateIsValid(aCtx, obj))
|
||||
if (!::js_DateIsValid(obj))
|
||||
return nullptr;
|
||||
|
||||
double msecd = ::js_DateGetMsecSinceEpoch(aCtx, obj);
|
||||
double msecd = ::js_DateGetMsecSinceEpoch(obj);
|
||||
msecd *= 1000.0;
|
||||
int64_t msec;
|
||||
LL_D2L(msec, msecd);
|
||||
|
||||
Reference in New Issue
Block a user