mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 899245 - Rename JS_SetGlobalObject and move it into jsfriendapi. r=luke
This commit is contained in:
parent
488031ac4d
commit
9dbd7cffb9
@ -16,6 +16,7 @@
|
||||
#include "nsIScriptRuntime.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
@ -297,7 +298,7 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment()
|
||||
nsIURI *ownerURI = mGlobalObjectOwner->DocumentURI();
|
||||
xpc::SetLocationForGlobal(mJSObject, ownerURI);
|
||||
|
||||
::JS_SetGlobalObject(cx, mJSObject);
|
||||
js::SetDefaultObjectForContext(cx, mJSObject);
|
||||
|
||||
// Add an owning reference from JS back to us. This'll be
|
||||
// released when the JSObject is finalized.
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "nsIArray.h"
|
||||
#include "nsIURI.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
@ -765,7 +766,7 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
|
||||
if (!newGlob)
|
||||
return NS_OK;
|
||||
|
||||
::JS_SetGlobalObject(cx, newGlob);
|
||||
js::SetDefaultObjectForContext(cx, newGlob);
|
||||
|
||||
// Add an owning reference from JS back to us. This'll be
|
||||
// released when the JSObject is finalized.
|
||||
|
@ -2070,7 +2070,7 @@ nsGlobalWindow::SetOuterObject(JSContext* aCx, JS::Handle<JSObject*> aOuterObjec
|
||||
JSAutoCompartment ac(aCx, aOuterObject);
|
||||
|
||||
// Indicate the default compartment object associated with this cx.
|
||||
JS_SetGlobalObject(aCx, aOuterObject);
|
||||
js::SetDefaultObjectForContext(aCx, aOuterObject);
|
||||
|
||||
// Set up the prototype for the outer object.
|
||||
JSObject* inner = JS_GetParent(aOuterObject);
|
||||
@ -2474,7 +2474,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
// we must have transplanted it. The JS engine tries to maintain
|
||||
// the global object's compartment as its default compartment,
|
||||
// so update that now since it might have changed.
|
||||
JS_SetGlobalObject(cx, mJSObject);
|
||||
js::SetDefaultObjectForContext(cx, mJSObject);
|
||||
#ifdef DEBUG
|
||||
JSObject *proto1, *proto2;
|
||||
JS_GetPrototype(cx, mJSObject, &proto1);
|
||||
|
@ -1195,7 +1195,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext)
|
||||
tmp->mGCOnDestruction = false;
|
||||
if (tmp->mContext) {
|
||||
JSAutoRequest ar(tmp->mContext);
|
||||
JS_SetGlobalObject(tmp->mContext, nullptr);
|
||||
js::SetDefaultObjectForContext(tmp->mContext, nullptr);
|
||||
}
|
||||
tmp->DestroyJSContext();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobalObjectRef)
|
||||
|
@ -537,7 +537,7 @@ class ThreadLocalJSRuntime
|
||||
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, NULL);
|
||||
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS_SetGlobalObject(mContext, mGlobal);
|
||||
js::SetDefaultObjectForContext(mContext, mGlobal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gdb-tests.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
using namespace JS;
|
||||
|
||||
@ -70,7 +71,7 @@ main (int argc, const char **argv)
|
||||
JS::CompartmentOptions options;
|
||||
options.setVersion(JSVERSION_LATEST);
|
||||
RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class, NULL, options)));
|
||||
JS_SetGlobalObject(cx, global);
|
||||
js::SetDefaultObjectForContext(cx, global);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
|
@ -1333,15 +1333,6 @@ JS_RefreshCrossCompartmentWrappers(JSContext *cx, JSObject *objArg)
|
||||
return RemapAllWrappersForObject(cx, obj, obj);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetGlobalObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
cx->setDefaultCompartmentObject(obj);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_InitStandardClasses(JSContext *cx, JSObject *objArg)
|
||||
{
|
||||
|
@ -2154,9 +2154,6 @@ extern JS_PUBLIC_API(void)
|
||||
JS_IterateCompartments(JSRuntime *rt, void *data,
|
||||
JSIterateCompartmentCallback compartmentCallback);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetGlobalObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
/*
|
||||
* Initialize standard JS class constructors, prototypes, and any top-level
|
||||
* functions and constants associated with the standard classes (e.g. isNaN
|
||||
|
@ -375,6 +375,12 @@ js::DefaultObjectForContextOrNull(JSContext *cx)
|
||||
return cx->maybeDefaultCompartmentObject();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::SetDefaultObjectForContext(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
cx->setDefaultCompartmentObject(obj);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::NotifyAnimationActivity(JSObject *obj)
|
||||
{
|
||||
|
@ -442,6 +442,9 @@ GetGlobalForObjectCrossCompartment(JSObject *obj);
|
||||
JS_FRIEND_API(JSObject *)
|
||||
DefaultObjectForContextOrNull(JSContext *cx);
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
SetDefaultObjectForContext(JSContext *cx, JSObject *obj);
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
NotifyAnimationActivity(JSObject *obj);
|
||||
|
||||
|
@ -849,7 +849,7 @@ class AutoNewContext
|
||||
if (!newcx)
|
||||
return false;
|
||||
JS_SetOptions(newcx, JS_GetOptions(newcx) | JSOPTION_DONT_REPORT_UNCAUGHT);
|
||||
JS_SetGlobalObject(newcx, JS_GetGlobalForScopeChain(cx));
|
||||
js::SetDefaultObjectForContext(newcx, JS_GetGlobalForScopeChain(cx));
|
||||
|
||||
newRequest.construct(newcx);
|
||||
newCompartment.construct(newcx, JS_GetGlobalForScopeChain(cx));
|
||||
@ -5210,7 +5210,7 @@ Shell(JSContext *cx, OptionParser *op, char **envp)
|
||||
return 1;
|
||||
|
||||
JSAutoCompartment ac(cx, glob);
|
||||
JS_SetGlobalObject(cx, glob);
|
||||
js::SetDefaultObjectForContext(cx, glob);
|
||||
|
||||
JSObject *envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
|
||||
if (!envobj)
|
||||
|
@ -691,7 +691,7 @@ JSRuntime::initSelfHosting(JSContext *cx)
|
||||
if (!(selfHostingGlobal_ = JS_NewGlobalObject(cx, &self_hosting_global_class, NULL)))
|
||||
return false;
|
||||
JSAutoCompartment ac(cx, selfHostingGlobal_);
|
||||
JS_SetGlobalObject(cx, selfHostingGlobal_);
|
||||
js::SetDefaultObjectForContext(cx, selfHostingGlobal_);
|
||||
Rooted<GlobalObject*> shg(cx, &selfHostingGlobal_->as<GlobalObject>());
|
||||
/*
|
||||
* During initialization of standard classes for the self-hosting global,
|
||||
@ -758,7 +758,7 @@ JSRuntime::initSelfHosting(JSContext *cx)
|
||||
ok = Evaluate(cx, shg, options, src, srcLen, &rv);
|
||||
}
|
||||
JS_SetErrorReporter(cx, oldReporter);
|
||||
JS_SetGlobalObject(cx, savedGlobal);
|
||||
js::SetDefaultObjectForContext(cx, savedGlobal);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -3761,7 +3761,7 @@ ContextHolder::ContextHolder(JSContext *aOuterCx,
|
||||
JS_GetOptions(mJSContext) |
|
||||
JSOPTION_DONT_REPORT_UNCAUGHT |
|
||||
JSOPTION_PRIVATE_IS_NSISUPPORTS);
|
||||
JS_SetGlobalObject(mJSContext, aSandbox);
|
||||
js::SetDefaultObjectForContext(mJSContext, aSandbox);
|
||||
JS_SetContextPrivate(mJSContext, this);
|
||||
JS_SetOperationCallback(mJSContext, ContextHolderOperationCallback);
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ XPCJSContextStack::GetSafeJSContext()
|
||||
|
||||
// Make sure the context is associated with a proper compartment
|
||||
// and not the default compartment.
|
||||
JS_SetGlobalObject(mSafeJSContext, glob);
|
||||
js::SetDefaultObjectForContext(mSafeJSContext, glob);
|
||||
|
||||
// Note: make sure to set the private before calling
|
||||
// InitClasses
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "prnetdb.h"
|
||||
#include "nsITimer.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
@ -543,7 +544,7 @@ private:
|
||||
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JSAutoCompartment ac(mContext, mGlobal);
|
||||
JS_SetGlobalObject(mContext, mGlobal);
|
||||
js::SetDefaultObjectForContext(mContext, mGlobal);
|
||||
JS_InitStandardClasses(mContext, mGlobal);
|
||||
|
||||
JS_SetErrorReporter(mContext, PACErrorReporter);
|
||||
|
Loading…
Reference in New Issue
Block a user