зеркало из https://github.com/mozilla/gecko-dev.git
Bug 974327 - Cleanup nsJSContext::GetGlobalObject(); r=bholley
The removed code is never reached, as GetWindowProxy() returns a JSObject with OuterWindowProxyClass as its JSClass, and this will test false for IsDOMClass and (~c->flags) & (JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS).
This commit is contained in:
Родитель
9fb7f507f0
Коммит
3796687d26
|
@ -906,53 +906,14 @@ AtomIsEventHandlerName(nsIAtom *aName)
|
||||||
nsIScriptGlobalObject *
|
nsIScriptGlobalObject *
|
||||||
nsJSContext::GetGlobalObject()
|
nsJSContext::GetGlobalObject()
|
||||||
{
|
{
|
||||||
AutoJSContext cx;
|
// Note: this could probably be simplified somewhat more; see bug 974327
|
||||||
JS::Rooted<JSObject*> global(mContext, GetWindowProxy());
|
// comments 1 and 3.
|
||||||
if (!global) {
|
if (!mWindowProxy) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGlobalObjectRef)
|
MOZ_ASSERT(mGlobalObjectRef);
|
||||||
return mGlobalObjectRef;
|
return mGlobalObjectRef;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
{
|
|
||||||
JSObject *inner = JS_ObjectToInnerObject(cx, global);
|
|
||||||
|
|
||||||
// If this assertion hits then it means that we have a window object as
|
|
||||||
// our global, but we never called CreateOuterObject.
|
|
||||||
NS_ASSERTION(inner == global, "Shouldn't be able to innerize here");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const JSClass *c = JS_GetClass(global);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
|
||||||
if (IsDOMClass(c)) {
|
|
||||||
sgo = do_QueryInterface(UnwrapDOMObjectToISupports(global));
|
|
||||||
} else {
|
|
||||||
if ((~c->flags) & (JSCLASS_HAS_PRIVATE |
|
|
||||||
JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsISupports *priv = static_cast<nsISupports*>(js::GetObjectPrivate(global));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapped_native =
|
|
||||||
do_QueryInterface(priv);
|
|
||||||
if (wrapped_native) {
|
|
||||||
// The global object is a XPConnect wrapped native, the native in
|
|
||||||
// the wrapper might be the nsIScriptGlobalObject
|
|
||||||
|
|
||||||
sgo = do_QueryWrappedNative(wrapped_native);
|
|
||||||
} else {
|
|
||||||
sgo = do_QueryInterface(priv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This'll return a pointer to something we're about to release, but
|
|
||||||
// that's ok, the JS object will hold it alive long enough.
|
|
||||||
return sgo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSContext*
|
JSContext*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче