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-09-04 14:06:57 -07:00
Родитель b2a143459c
Коммит 83c76ab760
14 изменённых файлов: 18 добавлений и 31 удалений

Просмотреть файл

@ -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);
/*

Просмотреть файл

@ -893,7 +893,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);

Просмотреть файл

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

Просмотреть файл

@ -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.
**/

Просмотреть файл

@ -1100,7 +1100,7 @@ nsIScriptGlobalObject *
nsJSContext::GetGlobalObject()
{
AutoJSContext cx;
JS::Rooted<JSObject*> global(mContext, GetNativeGlobal());
JS::Rooted<JSObject*> global(mContext, GetWindowProxy());
if (!global) {
return nullptr;
}
@ -1149,12 +1149,6 @@ nsJSContext::GetGlobalObject()
return sgo;
}
JSObject*
nsJSContext::GetNativeGlobal()
{
return GetWindowProxy();
}
JSContext*
nsJSContext::GetNativeContext()
{
@ -1198,7 +1192,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);
@ -1494,7 +1488,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(),

Просмотреть файл

@ -55,7 +55,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;
@ -131,7 +130,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:

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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!");

Просмотреть файл

@ -135,7 +135,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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);