Bug 991742 part 4. Remove the "scope" argument of WrapCallThisObject(). r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Apr 2014 18:27:15 -0400
changeset 178029 c86f1317b99ccd78c6edb9c0ee0d0a96e8592643
parent 178028 37213b9688f46b2dafd0bed3c3acc42757d4a620
child 178030 b94df89242487b3dedd881aa22bbc677911d0aa2
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersbholley
bugs991742
milestone31.0a1
Bug 991742 part 4. Remove the "scope" argument of WrapCallThisObject(). r=bholley
dom/bindings/BindingUtils.h
dom/bindings/Codegen.py
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1442,26 +1442,25 @@ JSObject* GetJSObjectFromCallback(Callba
 MOZ_ALWAYS_INLINE
 JSObject* GetJSObjectFromCallback(void* noncallback)
 {
   return nullptr;
 }
 
 template<typename T>
 static inline JSObject*
-WrapCallThisObject(JSContext* cx, JS::Handle<JSObject*> scope, const T& p)
+WrapCallThisObject(JSContext* cx, const T& p)
 {
   // Callbacks are nsISupports, so WrapNativeParent will just happily wrap them
   // up as an nsISupports XPCWrappedNative... which is not at all what we want.
   // So we need to special-case them.
   JS::Rooted<JSObject*> obj(cx, GetJSObjectFromCallback(p));
   if (!obj) {
     // WrapNativeParent is a bit of a Swiss army knife that will
     // wrap anything for us.
-    MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
     obj = WrapNativeParent(cx, p);
     if (!obj) {
       return nullptr;
     }
   }
 
   // But all that won't necessarily put things in the compartment of cx.
   if (!JS_WrapObject(cx, &obj)) {
@@ -1473,17 +1472,16 @@ WrapCallThisObject(JSContext* cx, JS::Ha
 
 /*
  * This specialized function simply wraps a JS::Rooted<> since
  * WrapNativeParent() is not applicable for JS objects.
  */
 template<>
 inline JSObject*
 WrapCallThisObject<JS::Rooted<JSObject*>>(JSContext* cx,
-                                          JS::Handle<JSObject*> scope,
                                           const JS::Rooted<JSObject*>& p)
 {
   JS::Rooted<JSObject*> obj(cx, p);
 
   if (!JS_WrapObject(cx, &obj)) {
     return nullptr;
   }
 
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11758,17 +11758,17 @@ class CGCallback(CGClass):
                      "if (!s.GetContext()) {\n"
                      "  aRv.Throw(NS_ERROR_UNEXPECTED);\n"
                      "  return${errorReturn};\n"
                      "}\n")
 
         bodyWithThis = string.Template(
             setupCall +
             "JS::Rooted<JSObject*> thisObjJS(s.GetContext(),\n"
-            "  WrapCallThisObject(s.GetContext(), CallbackPreserveColor(), thisObjPtr));\n"
+            "  WrapCallThisObject(s.GetContext(), thisObjPtr));\n"
             "if (!thisObjJS) {\n"
             "  aRv.Throw(NS_ERROR_FAILURE);\n"
             "  return${errorReturn};\n"
             "}\n"
             "JS::Rooted<JS::Value> thisValJS(s.GetContext(),\n"
             "                                JS::ObjectValue(*thisObjJS));\n"
             "return ${methodName}(${callArgs});"
         ).substitute({