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:
Ms2ger 2014-06-20 12:32:50 +02:00
Родитель 9fb7f507f0
Коммит 3796687d26
1 изменённых файлов: 5 добавлений и 44 удалений

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

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