diff --git a/js/xpconnect/src/XPCQuickStubs.h b/js/xpconnect/src/XPCQuickStubs.h index ab9dc61bcec8..2c3b7317c6b1 100644 --- a/js/xpconnect/src/XPCQuickStubs.h +++ b/js/xpconnect/src/XPCQuickStubs.h @@ -435,49 +435,43 @@ castNativeFromWrapper(JSContext *cx, return nullptr; } - *rv = NS_ERROR_XPC_BAD_CONVERT_JS; - nsISupports *native; if (wrapper) { native = wrapper->GetIdentityObject(); cur = wrapper->GetFlatJSObject(); if (!native || !HasBitInInterfacesBitmap(cur, interfaceBit)) { - return nullptr; + native = nullptr; + } else if (lccx) { + lccx->SetWrapper(wrapper, tearoff); } - } else if (cur) { - if (IS_SLIM_WRAPPER(cur)) { - native = static_cast(xpc_GetJSPrivate(cur)); - if (!native || !HasBitInInterfacesBitmap(cur, interfaceBit)) { - return nullptr; - } - } else if (protoDepth >= 0) { - const mozilla::dom::DOMClass* domClass; - mozilla::dom::DOMObjectSlot slot = - mozilla::dom::GetDOMClass(cur, domClass); - native = mozilla::dom::UnwrapDOMObject(cur, slot); - if (!native || - (uint32_t)domClass->mInterfaceChain[protoDepth] != protoID) { - return nullptr; - } - } else { - return nullptr; + } else if (cur && IS_SLIM_WRAPPER(cur)) { + native = static_cast(xpc_GetJSPrivate(cur)); + if (!native || !HasBitInInterfacesBitmap(cur, interfaceBit)) { + native = nullptr; + } else if (lccx) { + lccx->SetWrapper(cur); + } + } else if (cur && protoDepth >= 0) { + const mozilla::dom::DOMClass* domClass; + mozilla::dom::DOMObjectSlot slot = + mozilla::dom::GetDOMClass(cur, domClass); + native = mozilla::dom::UnwrapDOMObject(cur, slot); + if (native && + (uint32_t)domClass->mInterfaceChain[protoDepth] != protoID) { + native = nullptr; } } else { - return nullptr; + native = nullptr; } - *pRef = nullptr; - *pVal = OBJECT_TO_JSVAL(cur); - - if (lccx) { - if (wrapper) - lccx->SetWrapper(wrapper, tearoff); - else if (IS_SLIM_WRAPPER(cur)) - lccx->SetWrapper(cur); + if (native) { + *pRef = nullptr; + *pVal = OBJECT_TO_JSVAL(cur); + *rv = NS_OK; + } else { + *rv = NS_ERROR_XPC_BAD_CONVERT_JS; } - *rv = NS_OK; - return native; }