Bug 1229176 - make check for ChromeOnly interfaces for header inclusion more complete; r=bz
authorNathan Froyd <froydnj@mozilla.com>
Mon, 30 Nov 2015 20:57:57 -0500
changeset 274898 14ea3aec5d8492396eac15b547f9e6efe5f18a27
parent 274897 ed2b80d144f9eaf50d68cfeb68d613671ef5eb52
child 274899 42d9f12af41a7491bfde4875ac6fc44a0c77afa1
push id68716
push usernfroyd@mozilla.com
push dateTue, 01 Dec 2015 13:58:32 +0000
treeherdermozilla-inbound@14ea3aec5d84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1229176
milestone45.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 1229176 - make check for ChromeOnly interfaces for header inclusion more complete; r=bz If an interface has a {Chrome,}Constructor(), it doesn't show up as a normal member. If the interface has a ChromeConstructor, we need to include nsContentUtils.h in the generated file for a ThreadsafeIsCallerChrome check. There is an existing check for a descriptor's ChromeOnly-ness in CGBindingRoot; this check is used to determine whether nsContentUtils.h is included in the generated file. But the check in descriptorHasChromeOnly doesn't detect this (ChromeOnly) constructor, and so nsContentUtils.h won't be included if there are no other ChromeOnly members, or if the interface itself is not ChromeOnly. Therefore, we need to take the constructor of the interface (if any) into account when checking for ChromeOnly-ness.
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -13094,22 +13094,26 @@ class CGBindingRoot(CGThing):
         bindingHeaders["nsIDocument.h"] = any(
             descriptorDeprecated(d) for d in descriptors)
         bindingHeaders["mozilla/Preferences.h"] = any(
             descriptorRequiresPreferences(d) for d in descriptors)
         bindingHeaders["mozilla/dom/DOMJSProxyHandler.h"] = any(
             d.concrete and d.proxy for d in descriptors)
 
         def descriptorHasChromeOnly(desc):
+            ctor = desc.interface.ctor()
+
             return (any(isChromeOnly(a) for a in desc.interface.members) or
                     desc.interface.getExtendedAttribute("ChromeOnly") is not None or
                     # JS-implemented interfaces with an interface object get a
-                    # chromeonly _create method.
-                    (desc.interface.isJSImplemented() and
-                     desc.interface.hasInterfaceObject()))
+                    # chromeonly _create method.  And interfaces with an
+                    # interface object might have a ChromeOnly constructor.
+                    (desc.interface.hasInterfaceObject() and
+                     (desc.interface.isJSImplemented() or
+                      (ctor and isChromeOnly(ctor)))))
 
         bindingHeaders["nsContentUtils.h"] = any(
             descriptorHasChromeOnly(d) for d in descriptors)
         # XXXkhuey ugly hack but this is going away soon.
         bindingHeaders['xpcprivate.h'] = webIDLFile.endswith("EventTarget.webidl")
         hasWorkerStuff = len(config.getDescriptors(webIDLFile=webIDLFile,
                                                    workers=True)) != 0
         bindingHeaders["WorkerPrivate.h"] = hasWorkerStuff