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; return nullptr;
} }
JSObject* obj2 = nullptr; aJSObj = js::UnwrapObjectChecked(aJSObj, /* stopAtOuter = */ false);
nsIXPConnectWrappedNative* wrapper = if (!aJSObj) {
XPCWrappedNative::GetWrappedNativeOfJSObject(aJSContext, aJSObj, nullptr, JS_ReportError(aJSContext, "Permission denied to get native of security wrapper");
&obj2); return nullptr;
if (wrapper) }
return wrapper->Native(); if (IS_WRAPPER_CLASS(js::GetObjectClass(aJSObj))) {
if (IS_SLIM_WRAPPER_OBJECT(aJSObj))
if (obj2) return (nsISupports*)xpc_GetJSPrivate(aJSObj);
return (nsISupports*)xpc_GetJSPrivate(obj2); else if (XPCWrappedNative *wn = XPCWrappedNative::Get(aJSObj))
return wn->Native();
return nullptr;
}
JSObject* unsafeObj = JSObject* unsafeObj =
XPCWrapper::Unwrap(aJSContext, aJSObj, /* stopAtOuter = */ false); XPCWrapper::Unwrap(aJSContext, aJSObj, /* stopAtOuter = */ false);

View File

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