зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1283855
part 3 - Make some callback setters take JSContext instead of JSRuntime. r=efaust
This commit is contained in:
Родитель
df019b3519
Коммит
c1ed92b71b
|
@ -11152,15 +11152,14 @@ nsGlobalWindow::ShowSlowScriptDialog()
|
|||
buttonFlags += nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_2;
|
||||
|
||||
// Null out the operation callback while we're re-entering JS here.
|
||||
JSRuntime* rt = JS_GetRuntime(cx);
|
||||
JSInterruptCallback old = JS_SetInterruptCallback(rt, nullptr);
|
||||
JSInterruptCallback old = JS_SetInterruptCallback(cx, nullptr);
|
||||
|
||||
// Open the dialog.
|
||||
rv = prompt->ConfirmEx(title, msg, buttonFlags, waitButton, stopButton,
|
||||
debugButton, neverShowDlg, &neverShowDlgChk,
|
||||
&buttonPressed);
|
||||
|
||||
JS_SetInterruptCallback(rt, old);
|
||||
JS_SetInterruptCallback(cx, old);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (buttonPressed == 0)) {
|
||||
return neverShowDlgChk ? AlwaysContinueSlowScript : ContinueSlowScript;
|
||||
|
|
|
@ -793,7 +793,7 @@ InitJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
JS_SetInterruptCallback(aRuntime, InterruptCallback);
|
||||
JS_SetInterruptCallback(workerCx, InterruptCallback);
|
||||
|
||||
js::SetCTypesActivityCallback(aRuntime, CTypesActivityCallback);
|
||||
|
||||
|
|
|
@ -4625,17 +4625,17 @@ JS_CheckForInterrupt(JSContext* cx)
|
|||
}
|
||||
|
||||
JS_PUBLIC_API(JSInterruptCallback)
|
||||
JS_SetInterruptCallback(JSRuntime* rt, JSInterruptCallback callback)
|
||||
JS_SetInterruptCallback(JSContext* cx, JSInterruptCallback callback)
|
||||
{
|
||||
JSInterruptCallback old = rt->interruptCallback;
|
||||
rt->interruptCallback = callback;
|
||||
JSInterruptCallback old = cx->interruptCallback;
|
||||
cx->interruptCallback = callback;
|
||||
return old;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSInterruptCallback)
|
||||
JS_GetInterruptCallback(JSRuntime* rt)
|
||||
JS_GetInterruptCallback(JSContext* cx)
|
||||
{
|
||||
return rt->interruptCallback;
|
||||
return cx->interruptCallback;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -4644,25 +4644,25 @@ JS_GetInterruptCallback(JSRuntime* rt)
|
|||
* Promises.
|
||||
*/
|
||||
JS_PUBLIC_API(void)
|
||||
JS::SetGetIncumbentGlobalCallback(JSRuntime* rt, JSGetIncumbentGlobalCallback callback)
|
||||
JS::SetGetIncumbentGlobalCallback(JSContext* cx, JSGetIncumbentGlobalCallback callback)
|
||||
{
|
||||
rt->getIncumbentGlobalCallback = callback;
|
||||
cx->getIncumbentGlobalCallback = callback;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::SetEnqueuePromiseJobCallback(JSRuntime* rt, JSEnqueuePromiseJobCallback callback,
|
||||
JS::SetEnqueuePromiseJobCallback(JSContext* cx, JSEnqueuePromiseJobCallback callback,
|
||||
void* data /* = nullptr */)
|
||||
{
|
||||
rt->enqueuePromiseJobCallback = callback;
|
||||
rt->enqueuePromiseJobCallbackData = data;
|
||||
cx->enqueuePromiseJobCallback = callback;
|
||||
cx->enqueuePromiseJobCallbackData = data;
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS::SetPromiseRejectionTrackerCallback(JSRuntime* rt, JSPromiseRejectionTrackerCallback callback,
|
||||
JS::SetPromiseRejectionTrackerCallback(JSContext* cx, JSPromiseRejectionTrackerCallback callback,
|
||||
void* data /* = nullptr */)
|
||||
{
|
||||
rt->promiseRejectionTrackerCallback = callback;
|
||||
rt->promiseRejectionTrackerCallbackData = data;
|
||||
cx->promiseRejectionTrackerCallback = callback;
|
||||
cx->promiseRejectionTrackerCallbackData = data;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject*)
|
||||
|
|
|
@ -4308,10 +4308,10 @@ JS_CheckForInterrupt(JSContext* cx);
|
|||
* is disconnected before attempting such re-entry.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSInterruptCallback)
|
||||
JS_SetInterruptCallback(JSRuntime* rt, JSInterruptCallback callback);
|
||||
JS_SetInterruptCallback(JSContext* cx, JSInterruptCallback callback);
|
||||
|
||||
extern JS_PUBLIC_API(JSInterruptCallback)
|
||||
JS_GetInterruptCallback(JSRuntime* rt);
|
||||
JS_GetInterruptCallback(JSContext* cx);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_RequestInterruptCallback(JSRuntime* rt);
|
||||
|
@ -4326,7 +4326,7 @@ namespace JS {
|
|||
* See dom/base/ScriptSettings.h for details.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
SetGetIncumbentGlobalCallback(JSRuntime* rt, JSGetIncumbentGlobalCallback callback);
|
||||
SetGetIncumbentGlobalCallback(JSContext* cx, JSGetIncumbentGlobalCallback callback);
|
||||
|
||||
/**
|
||||
* Sets the callback that's invoked whenever a Promise job should be enqeued.
|
||||
|
@ -4338,7 +4338,7 @@ SetGetIncumbentGlobalCallback(JSRuntime* rt, JSGetIncumbentGlobalCallback callba
|
|||
* passed here as arguments.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
SetEnqueuePromiseJobCallback(JSRuntime* rt, JSEnqueuePromiseJobCallback callback,
|
||||
SetEnqueuePromiseJobCallback(JSContext* cx, JSEnqueuePromiseJobCallback callback,
|
||||
void* data = nullptr);
|
||||
|
||||
/**
|
||||
|
@ -4347,7 +4347,7 @@ SetEnqueuePromiseJobCallback(JSRuntime* rt, JSEnqueuePromiseJobCallback callback
|
|||
* without a handler gets a handler attached.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
SetPromiseRejectionTrackerCallback(JSRuntime* rt, JSPromiseRejectionTrackerCallback callback,
|
||||
SetPromiseRejectionTrackerCallback(JSContext* cx, JSPromiseRejectionTrackerCallback callback,
|
||||
void* data = nullptr);
|
||||
|
||||
/**
|
||||
|
|
|
@ -711,8 +711,7 @@ SetPromiseRejectionTrackerCallback(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
GetShellRuntime(cx)->promiseRejectionTrackerCallback = args[0];
|
||||
JS::SetPromiseRejectionTrackerCallback(cx->runtime(),
|
||||
ForwardingPromiseRejectionTrackerCallback);
|
||||
JS::SetPromiseRejectionTrackerCallback(cx, ForwardingPromiseRejectionTrackerCallback);
|
||||
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
args.rval().setUndefined();
|
||||
|
@ -2960,8 +2959,8 @@ WorkerMain(void* arg)
|
|||
|
||||
#ifdef SPIDERMONKEY_PROMISE
|
||||
sr->jobQueue.init(cx, JobQueue(SystemAllocPolicy()));
|
||||
JS::SetEnqueuePromiseJobCallback(rt, ShellEnqueuePromiseJobCallback);
|
||||
JS::SetGetIncumbentGlobalCallback(rt, ShellGetIncumbentGlobalCallback);
|
||||
JS::SetEnqueuePromiseJobCallback(cx, ShellEnqueuePromiseJobCallback);
|
||||
JS::SetGetIncumbentGlobalCallback(cx, ShellGetIncumbentGlobalCallback);
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
||||
EnvironmentPreparer environmentPreparer(cx);
|
||||
|
@ -2994,8 +2993,8 @@ WorkerMain(void* arg)
|
|||
JS::SetLargeAllocationFailureCallback(cx, nullptr, nullptr);
|
||||
|
||||
#ifdef SPIDERMONKEY_PROMISE
|
||||
JS::SetGetIncumbentGlobalCallback(rt, nullptr);
|
||||
JS::SetEnqueuePromiseJobCallback(rt, nullptr);
|
||||
JS::SetGetIncumbentGlobalCallback(cx, nullptr);
|
||||
JS::SetEnqueuePromiseJobCallback(cx, nullptr);
|
||||
sr->jobQueue.reset();
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
||||
|
@ -7400,7 +7399,7 @@ main(int argc, char** argv, char** envp)
|
|||
JS_SetSecurityCallbacks(cx, &ShellPrincipals::securityCallbacks);
|
||||
JS_InitDestroyPrincipalsCallback(cx, ShellPrincipals::destroy);
|
||||
|
||||
JS_SetInterruptCallback(rt, ShellInterruptCallback);
|
||||
JS_SetInterruptCallback(cx, ShellInterruptCallback);
|
||||
JS::SetBuildIdOp(cx, ShellBuildId);
|
||||
JS::SetAsmJSCacheOps(cx, &asmJSCacheOps);
|
||||
|
||||
|
@ -7413,8 +7412,8 @@ main(int argc, char** argv, char** envp)
|
|||
|
||||
#ifdef SPIDERMONKEY_PROMISE
|
||||
sr->jobQueue.init(cx, JobQueue(SystemAllocPolicy()));
|
||||
JS::SetEnqueuePromiseJobCallback(rt, ShellEnqueuePromiseJobCallback);
|
||||
JS::SetGetIncumbentGlobalCallback(rt, ShellGetIncumbentGlobalCallback);
|
||||
JS::SetEnqueuePromiseJobCallback(cx, ShellEnqueuePromiseJobCallback);
|
||||
JS::SetGetIncumbentGlobalCallback(cx, ShellGetIncumbentGlobalCallback);
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
||||
EnvironmentPreparer environmentPreparer(cx);
|
||||
|
@ -7446,8 +7445,8 @@ main(int argc, char** argv, char** envp)
|
|||
JS::SetLargeAllocationFailureCallback(cx, nullptr, nullptr);
|
||||
|
||||
#ifdef SPIDERMONKEY_PROMISE
|
||||
JS::SetGetIncumbentGlobalCallback(rt, nullptr);
|
||||
JS::SetEnqueuePromiseJobCallback(rt, nullptr);
|
||||
JS::SetGetIncumbentGlobalCallback(cx, nullptr);
|
||||
JS::SetEnqueuePromiseJobCallback(cx, nullptr);
|
||||
sr->jobQueue.reset();
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
||||
|
|
|
@ -3568,7 +3568,7 @@ XPCJSRuntime::Initialize()
|
|||
#endif
|
||||
JS_SetAccumulateTelemetryCallback(cx, AccumulateTelemetryCallback);
|
||||
js::SetActivityCallback(cx, ActivityCallback, this);
|
||||
JS_SetInterruptCallback(runtime, InterruptCallback);
|
||||
JS_SetInterruptCallback(cx, InterruptCallback);
|
||||
js::SetWindowProxyClass(cx, &OuterWindowProxyClass);
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback(
|
||||
|
|
|
@ -1425,12 +1425,13 @@ XRE_XPCShellMain(int argc, char** argv, char** envp,
|
|||
// reason to bother.
|
||||
sScriptedInterruptCallback = new PersistentRootedValue;
|
||||
sScriptedInterruptCallback->init(rt, UndefinedValue());
|
||||
JS_SetInterruptCallback(rt, XPCShellInterruptCallback);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
cx = jsapi.cx();
|
||||
|
||||
JS_SetInterruptCallback(cx, XPCShellInterruptCallback);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
ProcessArgsForCompartment(cx, argv, argc);
|
||||
|
|
|
@ -547,11 +547,11 @@ CycleCollectedJSRuntime::Initialize(JSRuntime* aParentRuntime,
|
|||
SetDOMCallbacks(mJSContext, &DOMcallbacks);
|
||||
js::SetScriptEnvironmentPreparer(mJSRuntime, &mEnvironmentPreparer);
|
||||
|
||||
JS::SetGetIncumbentGlobalCallback(mJSRuntime, GetIncumbentGlobalCallback);
|
||||
JS::SetGetIncumbentGlobalCallback(mJSContext, GetIncumbentGlobalCallback);
|
||||
|
||||
#ifdef SPIDERMONKEY_PROMISE
|
||||
JS::SetEnqueuePromiseJobCallback(mJSRuntime, EnqueuePromiseJobCallback, this);
|
||||
JS::SetPromiseRejectionTrackerCallback(mJSRuntime, PromiseRejectionTrackerCallback, this);
|
||||
JS::SetEnqueuePromiseJobCallback(mJSContext, EnqueuePromiseJobCallback, this);
|
||||
JS::SetPromiseRejectionTrackerCallback(mJSContext, PromiseRejectionTrackerCallback, this);
|
||||
mUncaughtRejections.init(mJSRuntime, JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>(js::SystemAllocPolicy()));
|
||||
mConsumedRejections.init(mJSRuntime, JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>(js::SystemAllocPolicy()));
|
||||
#endif // SPIDERMONKEY_PROMISE
|
||||
|
|
Загрузка…
Ссылка в новой задаче