Bug 1432526 - Replace simple uses of NativeInterface2JSObject with ToJSValue. r=bz draft
authorAndrew McCreight <continuation@gmail.com>
Thu, 18 Jan 2018 14:23:28 -0800
changeset 723645 b60674cec383962e3c787848976250c597c51a96
parent 723473 e2bb11b88bd45bdb2e055042e1624b74d414e73c
child 723801 80962d3a6068e4a5d4d444021bff12acb60a6f66
child 723845 1d3f2fb8a8945879ab7c70dcea56108adbe84e19
push id96491
push userbmo:continuation@gmail.com
push dateTue, 23 Jan 2018 17:17:50 +0000
reviewersbz
bugs1432526
milestone60.0a1
Bug 1432526 - Replace simple uses of NativeInterface2JSObject with ToJSValue. r=bz ToJSValue is easier to understand. MozReview-Commit-ID: rpV5aiUTM9
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1157,23 +1157,18 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
                             nsCOMPtr<nsISupports> newThis;
                             if (NS_FAILED(translator->
                                           TranslateThis((nsISupports*)nativeParams[0].val.p,
                                                         getter_AddRefs(newThis)))) {
                                 goto pre_call_clean_up;
                             }
                             if (newThis) {
                                 RootedValue v(cx);
-                                xpcObjectHelper helper(newThis);
-                                bool ok =
-                                  XPCConvert::NativeInterface2JSObject(
-                                      &v, helper, nullptr, false, nullptr);
-                                if (!ok) {
+                                if (!ToJSValue(cx, newThis, &v))
                                     goto pre_call_clean_up;
-                                }
                                 thisObj = v.toObjectOrNull();
                                 if (!JS_WrapObject(cx, &thisObj))
                                     goto pre_call_clean_up;
                             }
                         }
                     }
                 }
             }
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -194,20 +194,17 @@ XPCWrappedNativeScope::GetComponentsJSOb
     if (!mComponents) {
         nsIPrincipal* p = GetPrincipal();
         bool system = nsXPConnect::SecurityManager()->IsSystemPrincipal(p);
         mComponents = system ? new nsXPCComponents(this)
                              : new nsXPCComponentsBase(this);
     }
 
     RootedValue val(cx);
-    xpcObjectHelper helper(mComponents);
-    bool ok = XPCConvert::NativeInterface2JSObject(&val, helper, nullptr,
-                                                   false, nullptr);
-    if (NS_WARN_IF(!ok))
+    if (!ToJSValue(cx, mComponents, &val))
         return false;
 
     if (NS_WARN_IF(!val.isObject()))
         return false;
 
     // The call to wrap() here is necessary even though the object is same-
     // compartment, because it applies our security wrapper.
     obj.set(&val.toObject());