Skip to content

Commit

Permalink
Fix for bug 814821 (Dromaeo dom-traverse regression from bug 812333) …
Browse files Browse the repository at this point in the history
…- part 3: reorder castNativeFromWrapper. r=bz.
  • Loading branch information
petervanderbeken committed Nov 27, 2012
1 parent 9f08b76 commit 5ad7086
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions js/xpconnect/src/XPCQuickStubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<nsISupports*>(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<nsISupports>(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<nsISupports*>(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<nsISupports>(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;
}

Expand Down

0 comments on commit 5ad7086

Please sign in to comment.