Bug 658909 - Remove GWNOJO from PreserveWrapper. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Thu, 21 Mar 2013 08:20:45 -0700
changeset 125818 bebb8e1a11b4c9c9173548c13a6a660559e8ec2b
parent 125817 d1ced1c166d9ff59f468ebb2b652042071c07904
child 125819 bffc0252a6279df802f523fa48f2f03bac13900f
push id25109
push userryanvm@gmail.com
push dateThu, 21 Mar 2013 19:52:05 +0000
treeherdermozilla-inbound@a83cbe4e0576 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs658909
milestone22.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
Bug 658909 - Remove GWNOJO from PreserveWrapper. r=mrbkap
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2462,37 +2462,31 @@ PreserveWrapper(JSContext *cx, JSObject 
     MOZ_ASSERT(obj);
     MOZ_ASSERT(js::GetObjectClass(obj)->ext.isWrappedNative ||
                mozilla::dom::IsDOMObject(obj));
 
     XPCCallContext ccx(NATIVE_CALLER, cx);
     if (!ccx.IsValid())
         return false;
 
-    JSObject *obj2 = nullptr;
-    nsIXPConnectWrappedNative *wrapper =
-        XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj, nullptr, &obj2);
+    if (!IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
+        return mozilla::dom::TryPreserveWrapper(obj);
+
     nsISupports *supports = nullptr;
-
-    if (wrapper) {
-        supports = wrapper->Native();
-    } else if (obj2) {
-        supports = static_cast<nsISupports*>(xpc_GetJSPrivate(obj2));
+    if (IS_WN_WRAPPER_OBJECT(obj))
+        supports = XPCWrappedNative::Get(obj)->Native();
+    else
+        supports = static_cast<nsISupports*>(xpc_GetJSPrivate(obj));
+
+    // For pre-Paris DOM bindings objects, we only support Node.
+    if (nsCOMPtr<nsINode> node = do_QueryInterface(supports)) {
+        nsContentUtils::PreserveWrapper(supports, node);
+        return true;
     }
-
-    if (supports) {
-        // For pre-Paris DOM bindings objects, we only support Node.
-        if (nsCOMPtr<nsINode> node = do_QueryInterface(supports)) {
-            nsContentUtils::PreserveWrapper(supports, node);
-            return true;
-        }
-        return false;
-    }
-
-    return mozilla::dom::TryPreserveWrapper(obj);
+    return false;
 }
 
 static nsresult
 ReadSourceFromFilename(JSContext *cx, const char *filename, jschar **src, uint32_t *len)
 {
   nsresult rv;
 
   // mozJSSubScriptLoader prefixes the filenames of the scripts it loads with