Bug 899367 - Make GetNativeGlobal consumers call GetWindowProxy and rm the former. r=mccr8

Some of the uses of this are a bit nonsensical now, but that's a problem for
another day.
This commit is contained in:
Bobby Holley 2013-08-27 15:21:40 -07:00
parent 2c53365eee
commit 41d0a60a21
14 changed files with 18 additions and 31 deletions

View File

@ -66,7 +66,7 @@ NS_IMETHODIMP
nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext)
{
AutoJSContext cx;
JS::Rooted<JSObject*> global(cx, aScriptContext->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, aScriptContext->GetWindowProxy());
JSAutoCompartment ac(cx, global);
/*

View File

@ -908,7 +908,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
aListenerStruct->mTypeAtom,
&argCount, &argNames);
JSAutoCompartment ac(cx, context->GetNativeGlobal());
JSAutoCompartment ac(cx, context->GetWindowProxy());
JS::CompileOptions options(cx);
options.setFileAndLine(url.get(), lineNo)
.setVersion(SCRIPTVERSION_DEFAULT);

View File

@ -2362,7 +2362,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
CreateOuterObject(newInnerWindow);
mContext->DidInitializeContext();
mJSObject = mContext->GetNativeGlobal();
mJSObject = mContext->GetWindowProxy();
SetWrapper(mJSObject);
} else {
JS::Rooted<JSObject*> global(cx,

View File

@ -27,8 +27,8 @@ class nsIDOMWindow;
class nsIURI;
#define NS_ISCRIPTCONTEXT_IID \
{ 0x03c0874e, 0xcb49, 0x41c8, \
{ 0xa3, 0x0b, 0xef, 0x3e, 0xc1, 0x88, 0xb1, 0x1f } }
{ 0xf3859ce7, 0x7551, 0x4760, \
{ 0x84, 0x29, 0x64, 0x4f, 0x26, 0x1e, 0xdb, 0x91 } }
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
know what language we have is a little silly... */
@ -103,12 +103,6 @@ public:
**/
virtual JSContext* GetNativeContext() = 0;
/**
* Return the native global object for this context.
*
**/
virtual JSObject* GetNativeGlobal() = 0;
/**
* Initialize the context generally. Does not create a global object.
**/

View File

@ -1085,7 +1085,7 @@ nsIScriptGlobalObject *
nsJSContext::GetGlobalObject()
{
AutoJSContext cx;
JS::Rooted<JSObject*> global(mContext, GetNativeGlobal());
JS::Rooted<JSObject*> global(mContext, GetWindowProxy());
if (!global) {
return nullptr;
}
@ -1134,12 +1134,6 @@ nsJSContext::GetGlobalObject()
return sgo;
}
JSObject*
nsJSContext::GetNativeGlobal()
{
return GetWindowProxy();
}
JSContext*
nsJSContext::GetNativeContext()
{
@ -1183,7 +1177,7 @@ nsJSContext::SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, n
Maybe<nsRootedJSValueArray> tempStorage;
JS::Rooted<JSObject*> global(mContext, GetNativeGlobal());
JS::Rooted<JSObject*> global(mContext, GetWindowProxy());
nsresult rv =
ConvertSupportsTojsvals(aArgs, global, &argc, &argv, tempStorage);
NS_ENSURE_SUCCESS(rv, rv);
@ -1479,7 +1473,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
AutoFree iidGuard(iid); // Free iid upon destruction.
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
JS::Rooted<JSObject*> global(cx, xpc_UnmarkGrayObject(GetNativeGlobal()));
JS::Rooted<JSObject*> global(cx, GetWindowProxy());
JS::Rooted<JS::Value> v(cx);
nsresult rv = nsContentUtils::WrapNative(cx, global,
data, iid, v.address(),

View File

@ -54,7 +54,6 @@ public:
inline nsIScriptGlobalObject *GetGlobalObjectRef() { return mGlobalObjectRef; }
virtual JSContext* GetNativeContext() MOZ_OVERRIDE;
virtual JSObject* GetNativeGlobal() MOZ_OVERRIDE;
virtual nsresult InitContext() MOZ_OVERRIDE;
virtual bool IsContextInitialized() MOZ_OVERRIDE;
@ -129,7 +128,7 @@ public:
{
// Verify that we have a global so that this
// does always return a null when GetGlobalObject() is null.
JSObject* global = GetNativeGlobal();
JSObject* global = GetWindowProxy();
return global ? mGlobalObjectRef.get() : nullptr;
}
protected:

View File

@ -143,7 +143,7 @@ nsJSUtils::ReportPendingException(JSContext *aContext)
{
nsIScriptContext* scx = GetScriptContextFromJSContext(aContext);
JS::Rooted<JSObject*> scope(aContext);
scope = scx ? scx->GetNativeGlobal()
scope = scx ? scx->GetWindowProxy()
: js::DefaultObjectForContextOrNull(aContext);
JSAutoCompartment ac(aContext, scope);
JS_ReportPendingException(aContext);
@ -304,7 +304,7 @@ JSObject* GetDefaultScopeFromJSContext(JSContext *cx)
// instead.
nsIScriptContext *scx = GetScriptContextFromJSContext(cx);
if (scx) {
return scx->GetNativeGlobal();
return scx->GetWindowProxy();
}
return js::DefaultObjectForContextOrNull(cx);
}

View File

@ -68,7 +68,7 @@ public:
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, sc->GetWindowProxy());
rv = nsContentUtils::WrapNative(cx, global, adapter, aValue);
if (NS_FAILED(rv)) {
NS_WARNING("Cannot create native object!");

View File

@ -138,7 +138,7 @@ ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
AutoPushJSContext cx(sc->GetNativeContext());
NS_ASSERTION(cx, "Failed to get a context!");
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, sc->GetWindowProxy());
NS_ASSERTION(global, "Failed to get global object!");
JSAutoCompartment ac(cx, global);

View File

@ -79,7 +79,7 @@ FileRequest::NotifyHelperCompleted(FileHelper* aFileHelper)
JS::Rooted<JS::Value> result(cx);
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, sc->GetWindowProxy());
NS_ASSERTION(global, "Failed to get global object!");
JSAutoCompartment ac(cx, global);

View File

@ -56,7 +56,7 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
AutoPushJSContext cx(scriptContext->GetNativeContext());
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JS::Rooted<JSObject*> global(cx, scriptContext->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, scriptContext->GetWindowProxy());
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
JSAutoCompartment ac(cx, global);

View File

@ -67,7 +67,7 @@ MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
AutoPushJSContext cx(scriptContext->GetNativeContext());
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
JS::Rooted<JSObject*> global(cx, scriptContext->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, scriptContext->GetWindowProxy());
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
JSAutoCompartment ac(cx, global);

View File

@ -155,7 +155,7 @@ MobileMessageManager::Send(const JS::Value& aNumber_, const nsAString& aMessage,
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> global(cx, sc->GetNativeGlobal());
JS::Rooted<JSObject*> global(cx, sc->GetWindowProxy());
NS_ASSERTION(global, "Failed to get global object!");
JSAutoCompartment ac(cx, global);

View File

@ -128,7 +128,7 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
mAutoRequest.construct(cx);
// DOM JSContexts don't store their default compartment object on the cx.
JSObject *compartmentObject = mScx ? mScx->GetNativeGlobal()
JSObject *compartmentObject = mScx ? mScx->GetWindowProxy()
: js::DefaultObjectForContextOrNull(cx);
if (compartmentObject)
mAutoCompartment.construct(cx, compartmentObject);