Bug 829252 part 3. When wrapping things with an nsISupports in XPCWrappedJS for WebIDL callback interfaces, use the aggregated version. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 29 Jan 2013 08:44:01 -0500
changeset 120208 aa85bbb41c0486ad6d407f42ec671074f8fbf443
parent 120207 0b23beab803845fc77bbf66bf222ed0954357a1b
child 120209 2b9a689ac459a8a977433b35f6cb178299372bb8
push id22091
push userbzbarsky@mozilla.com
push dateTue, 29 Jan 2013 13:44:18 +0000
treeherdermozilla-inbound@2b9a689ac459 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs829252
milestone21.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 829252 part 3. When wrapping things with an nsISupports in XPCWrappedJS for WebIDL callback interfaces, use the aggregated version. r=peterv
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1918,20 +1918,28 @@ class CallbackObjectUnwrapper:
         return checkObjectType + string.Template(
             """nsresult rv;
 XPCCallContext ccx(JS_CALLER, cx);
 if (!ccx.IsValid()) {
   rv = NS_ERROR_XPC_BAD_CONVERT_JS;
 ${codeOnFailure}
 }
 
+nsISupports* supp = nullptr;
+if (XPCConvert::GetISupportsFromJSObject(${source}, &supp)) {
+  nsCOMPtr<nsIXPConnectWrappedNative> xpcwn = do_QueryInterface(supp);
+  if (xpcwn) {
+    supp = xpcwn->Native();
+  }
+}
+
 const nsIID& iid = NS_GET_IID(${nativeType});
 nsRefPtr<nsXPCWrappedJS> wrappedJS;
 rv = nsXPCWrappedJS::GetNewOrUsed(ccx, ${source}, iid,
-                                  NULL, getter_AddRefs(wrappedJS));
+                                  supp, getter_AddRefs(wrappedJS));
 if (NS_FAILED(rv) || !wrappedJS) {
 ${codeOnFailure}
 }
 
 // Use a temp nsCOMPtr for the null-check, because ${target} might be
 // OwningNonNull, not an nsCOMPtr.
 nsCOMPtr<${nativeType}> tmp = do_QueryObject(wrappedJS.get());
 if (!tmp) {