Fix for bug 814821 (Dromaeo dom-traverse regression from bug 812333) - part 3: reorder castNativeFromWrapper. r=bz.
☠☠ backed out by 5de5d3950328 ☠ ☠
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 27 Nov 2012 10:20:05 +0100
changeset 114278 e73366b088d7ed68e1f395df42519d73dc5003db
parent 114277 49fc6d535c417224d59eb2f2a3302f4e164ac668
child 114279 bf8746658a7203bda1fb0019f6631d4df9c6cb37
push id23913
push useremorley@mozilla.com
push dateWed, 28 Nov 2012 17:11:31 +0000
treeherdermozilla-central@17c267a881cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs814821, 812333
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Fix for bug 814821 (Dromaeo dom-traverse regression from bug 812333) - part 3: reorder castNativeFromWrapper. r=bz.
js/xpconnect/src/XPCQuickStubs.h
--- a/js/xpconnect/src/XPCQuickStubs.h
+++ b/js/xpconnect/src/XPCQuickStubs.h
@@ -430,59 +430,53 @@ castNativeFromWrapper(JSContext *cx,
                   nullptr;
         tearoff = nullptr;
     } else {
         *rv = getWrapper(cx, obj, &wrapper, &cur, &tearoff);
         if (NS_FAILED(*rv))
             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;
 }
 
 JSBool
 xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx,
                             const nsIID &iid,
                             void **ppThis,
                             nsISupports **pThisRef,