Fix for bug 814821 (Dromaeo dom-traverse regression from bug 812333) - part 3: reorder castNativeFromWrapper. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 27 Nov 2012 10:20:05 +0100
changeset 114343 ae93793daecd682d55996f9fe6140daf74d181c7
parent 114342 2997ef8891c41006b1ce5dc19762fd109c4ecda3
child 114344 7d678d658159f4ebe557072e1510ffc097949f80
push id18708
push userpvanderbeken@mozilla.com
push dateWed, 28 Nov 2012 09:02:49 +0000
treeherdermozilla-inbound@7d678d658159 [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,