зеркало из https://github.com/mozilla/gecko-dev.git
Bug 658909 - Remove GWNOJO from XPCVariant. r=mrbkap
The old code seems to be deciding whether we have a double-wrapped object by checking _either_ the rv of GWNOJO _or_ the potential slim wrapper. This is nonsensical, because double-wrapped objects are never slim wrappers. Furthermore, that variable here is named 'proto', which further suggests that this code is nonsensical. So let's just check for WNs. Also, it seems pretty wack to be innerizing here before storing the jsval, but I'm going to leave that for now.
This commit is contained in:
Родитель
c190c23a80
Коммит
6727e6bedc
|
@ -28,21 +28,20 @@ XPCVariant::XPCVariant(JSContext* cx, jsval aJSVal)
|
|||
{
|
||||
nsVariant::Initialize(&mData);
|
||||
if (!JSVAL_IS_PRIMITIVE(mJSVal)) {
|
||||
// XXXbholley - The innerization here was from bug 638026. Blake says
|
||||
// the basic problem was that we were storing the C++ inner but the JS
|
||||
// outer, which meant that, after navigation, the JS inner could be
|
||||
// collected, which would cause us to try to recreate the JS inner at
|
||||
// some later point after teardown, which would crash. This is shouldn't
|
||||
// be a problem anymore because SetParentToWindow will do the right
|
||||
// thing, but I'm saving the cleanup here for another day. Blake thinks
|
||||
// that we should just not store the WN if we're creating a variant for
|
||||
// an outer window.
|
||||
JSObject *obj = JS_ObjectToInnerObject(cx, JSVAL_TO_OBJECT(mJSVal));
|
||||
|
||||
mJSVal = OBJECT_TO_JSVAL(obj);
|
||||
|
||||
// If the incoming object is an XPCWrappedNative, then it could be a
|
||||
// double-wrapped object, and we should return the double-wrapped
|
||||
// object back out to script.
|
||||
|
||||
JSObject* proto;
|
||||
XPCWrappedNative* wn =
|
||||
XPCWrappedNative::GetWrappedNativeOfJSObject(cx,
|
||||
JSVAL_TO_OBJECT(mJSVal),
|
||||
nullptr,
|
||||
&proto);
|
||||
mReturnRawObject = !wn && !proto;
|
||||
JSObject *unwrapped = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
|
||||
mReturnRawObject = !(unwrapped && IS_WN_WRAPPER(unwrapped));
|
||||
} else
|
||||
mReturnRawObject = false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче