Bug 658909 - Remove GWNOJO from nsXPConnect. r=mrbkap

This commit is contained in:
Bobby Holley 2013-03-16 22:58:16 -07:00
parent 621e6b8496
commit 2491e8030a
2 changed files with 21 additions and 20 deletions

View File

@ -1332,15 +1332,18 @@ nsXPConnect::GetNativeOfWrapper(JSContext * aJSContext,
return nullptr;
}
JSObject* obj2 = nullptr;
nsIXPConnectWrappedNative* wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(aJSContext, aJSObj, nullptr,
&obj2);
if (wrapper)
return wrapper->Native();
if (obj2)
return (nsISupports*)xpc_GetJSPrivate(obj2);
aJSObj = js::UnwrapObjectChecked(aJSObj, /* stopAtOuter = */ false);
if (!aJSObj) {
JS_ReportError(aJSContext, "Permission denied to get native of security wrapper");
return nullptr;
}
if (IS_WRAPPER_CLASS(js::GetObjectClass(aJSObj))) {
if (IS_SLIM_WRAPPER_OBJECT(aJSObj))
return (nsISupports*)xpc_GetJSPrivate(aJSObj);
else if (XPCWrappedNative *wn = XPCWrappedNative::Get(aJSObj))
return wn->Native();
return nullptr;
}
JSObject* unsafeObj =
XPCWrapper::Unwrap(aJSContext, aJSObj, /* stopAtOuter = */ false);

View File

@ -2763,18 +2763,16 @@ public:
static XPCWrappedNative*
GetAndMorphWrappedNativeOfJSObject(JSContext* cx, JSObject* obj)
{
JSObject *obj2 = nullptr;
XPCWrappedNative* wrapper =
GetWrappedNativeOfJSObject(cx, obj, nullptr, &obj2);
if (wrapper || !obj2)
return wrapper;
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
if (!obj)
return nullptr;
if (!IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
return nullptr;
NS_ASSERTION(IS_SLIM_WRAPPER(obj2),
"Hmm, someone changed GetWrappedNativeOfJSObject?");
SLIM_LOG_WILL_MORPH(cx, obj2);
return MorphSlimWrapper(cx, obj2) ?
(XPCWrappedNative*)xpc_GetJSPrivate(obj2) :
nullptr;
if (IS_SLIM_WRAPPER_OBJECT(obj) && !MorphSlimWrapper(cx, obj))
return nullptr;
MOZ_ASSERT(IS_WN_WRAPPER(obj));
return XPCWrappedNative::Get(obj);
}
static nsresult