mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 797821 - Simplify the call signature for XPC::CreateGlobalObject. r=mrbkap
This commit is contained in:
parent
78e479ed30
commit
3b50be121c
@ -281,12 +281,10 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment()
|
||||
// why - see bug 339647)
|
||||
JS_SetErrorReporter(cx, XBL_ProtoErrorReporter);
|
||||
|
||||
nsIPrincipal *principal = GetPrincipal();
|
||||
JSCompartment *compartment;
|
||||
|
||||
rv = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, principal, false,
|
||||
&mJSObject, &compartment);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
mJSObject = xpc::CreateGlobalObject(cx, &gSharedGlobalClass,
|
||||
GetPrincipal(), false);
|
||||
if (!mJSObject)
|
||||
return NS_OK;
|
||||
|
||||
// Set the location information for the new global, so that tools like
|
||||
// about:memory may use that information
|
||||
|
@ -752,13 +752,10 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
|
||||
JSContext *cx = ctxNew->GetNativeContext();
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
nsIPrincipal *principal = GetPrincipal();
|
||||
JSObject *newGlob;
|
||||
JSCompartment *compartment;
|
||||
|
||||
rv = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, principal, false,
|
||||
&newGlob, &compartment);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
JSObject *newGlob = xpc::CreateGlobalObject(cx, &gSharedGlobalClass,
|
||||
GetPrincipal(), false);
|
||||
if (!newGlob)
|
||||
return NS_OK;;
|
||||
|
||||
::JS_SetGlobalObject(cx, newGlob);
|
||||
|
||||
|
@ -3256,11 +3256,11 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo
|
||||
|
||||
nsIPrincipal *principal = sop->GetPrincipal();
|
||||
|
||||
JSCompartment *compartment;
|
||||
JSObject *sandbox;
|
||||
|
||||
rv = xpc::CreateGlobalObject(cx, &SandboxClass, principal,
|
||||
options.wantXrays, &sandbox, &compartment);
|
||||
sandbox = xpc::CreateGlobalObject(cx, &SandboxClass, principal, options.wantXrays);
|
||||
if (!sandbox)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::AutoObjectRooter tvr(cx, sandbox);
|
||||
|
@ -181,12 +181,8 @@ XPCJSContextStack::GetSafeJSContext()
|
||||
|
||||
JS_SetErrorReporter(mSafeJSContext, mozJSLoaderErrorReporter);
|
||||
|
||||
JSCompartment *compartment;
|
||||
nsresult rv = xpc::CreateGlobalObject(mSafeJSContext, &global_class,
|
||||
principal, false, &glob,
|
||||
&compartment);
|
||||
if (NS_FAILED(rv))
|
||||
glob = nullptr;
|
||||
glob = xpc::CreateGlobalObject(mSafeJSContext, &global_class,
|
||||
principal, false);
|
||||
|
||||
if (glob) {
|
||||
// Make sure the context is associated with a proper compartment
|
||||
|
@ -312,11 +312,9 @@ XPCWrappedNative::WrapNewGlobal(XPCCallContext &ccx, xpcObjectHelper &nativeHelp
|
||||
MOZ_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL);
|
||||
|
||||
// Create the global.
|
||||
JSObject *global;
|
||||
JSCompartment *compartment;
|
||||
nsresult rv = xpc::CreateGlobalObject(ccx, clasp, principal, false, &global,
|
||||
&compartment);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
JSObject *global = xpc::CreateGlobalObject(ccx, clasp, principal, false);
|
||||
if (!global)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Immediately enter the global's compartment, so that everything else we
|
||||
// create ends up there.
|
||||
|
@ -1075,9 +1075,9 @@ CheckTypeInference(JSContext *cx, JSClass *clasp, nsIPrincipal *principal)
|
||||
|
||||
namespace xpc {
|
||||
|
||||
nsresult
|
||||
JSObject*
|
||||
CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
|
||||
bool wantXrays, JSObject **global, JSCompartment **compartment)
|
||||
bool wantXrays)
|
||||
{
|
||||
// Make sure that Type Inference is enabled for everything non-chrome.
|
||||
// Sandboxes and compilation scopes are exceptions. See bug 744034.
|
||||
@ -1085,15 +1085,15 @@ CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
|
||||
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "using a principal off the main thread?");
|
||||
|
||||
*global = JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal));
|
||||
if (!*global)
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
*compartment = js::GetObjectCompartment(*global);
|
||||
JS_SetCompartmentPrivate(*compartment, new xpc::CompartmentPrivate(wantXrays));
|
||||
JSObject *global = JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal));
|
||||
if (!global)
|
||||
return nullptr;
|
||||
JSCompartment *compartment = js::GetObjectCompartment(global);
|
||||
JS_SetCompartmentPrivate(compartment, new xpc::CompartmentPrivate(wantXrays));
|
||||
|
||||
XPCCompartmentSet& set = nsXPConnect::GetRuntimeInstance()->GetCompartmentSet();
|
||||
if (!set.put(*compartment))
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
if (!set.put(compartment))
|
||||
return nullptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Verify that the right trace hook is called. Note that this doesn't
|
||||
@ -1105,16 +1105,16 @@ CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
|
||||
VerifyTraceXPCGlobalCalledTracer trc;
|
||||
JS_TracerInit(&trc.base, JS_GetRuntime(cx), VerifyTraceXPCGlobalCalled);
|
||||
trc.ok = false;
|
||||
JS_TraceChildren(&trc.base, *global, JSTRACE_OBJECT);
|
||||
JS_TraceChildren(&trc.base, global, JSTRACE_OBJECT);
|
||||
NS_ABORT_IF_FALSE(trc.ok, "Trace hook needs to call TraceXPCGlobal if JSCLASS_XPCONNECT_GLOBAL is set.");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (clasp->flags & JSCLASS_DOM_GLOBAL) {
|
||||
AllocateProtoOrIfaceCache(*global);
|
||||
AllocateProtoOrIfaceCache(global);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return global;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
@ -41,10 +41,9 @@ TransplantObjectWithWrapper(JSContext *cx,
|
||||
JSObject *origobj, JSObject *origwrapper,
|
||||
JSObject *targetobj, JSObject *targetwrapper);
|
||||
|
||||
nsresult
|
||||
JSObject *
|
||||
CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
|
||||
bool wantXrays, JSObject **global,
|
||||
JSCompartment **compartment);
|
||||
bool wantXrays);
|
||||
} /* namespace xpc */
|
||||
|
||||
#define XPCONNECT_GLOBAL_FLAGS \
|
||||
|
Loading…
Reference in New Issue
Block a user