mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
530bc74c8d
commit
3c8082c257
@ -906,53 +906,14 @@ AtomIsEventHandlerName(nsIAtom *aName)
|
||||
nsIScriptGlobalObject *
|
||||
nsJSContext::GetGlobalObject()
|
||||
{
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JSObject*> global(mContext, GetWindowProxy());
|
||||
if (!global) {
|
||||
// Note: this could probably be simplified somewhat more; see bug 974327
|
||||
// comments 1 and 3.
|
||||
if (!mWindowProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (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;
|
||||
MOZ_ASSERT(mGlobalObjectRef);
|
||||
return mGlobalObjectRef;
|
||||
}
|
||||
|
||||
JSContext*
|
||||
|
Loading…
Reference in New Issue
Block a user