diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 1b8277a0dcd..a5ed8728e2b 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -29,6 +29,8 @@ # true for workers, false otherwise). # * customFinalize - The native class will use a custom finalize hook # (defaults to true for workers, false otherwise). +# * wantsQI - Indicates whether the interface should have a QueryInterface +# method available to chrome. # * notflattened - The native type does not have nsIClassInfo, so when # wrapping it the right IID needs to be passed in. # * register - True if this binding should be registered. Defaults to true. @@ -608,6 +610,7 @@ DOMInterfaces = { 'ImageData': [ { 'wrapperCache': False, + 'wantsQI': False, }], 'InputStream': [ diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index cb36f0009ea..72b9e61301c 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1369,21 +1369,6 @@ def overloadLength(arguments): def methodLength(method): signatures = method.signatures() return min(overloadLength(arguments) for (retType, arguments) in signatures) -def requiresQueryInterfaceMethod(descriptor): - # Make sure to not stick QueryInterface on abstract interfaces that - # have hasXPConnectImpls (like EventTarget). So only put it on - # interfaces that are concrete and all of whose ancestors are abstract. - def allAncestorsAbstract(iface): - if not iface.parent: - return True - desc = descriptor.getDescriptor(iface.parent.identifier.name) - if desc.concrete: - return False - return allAncestorsAbstract(iface.parent) - return (not descriptor.workers and - descriptor.interface.hasInterfacePrototypeObject() and - descriptor.concrete and - allAncestorsAbstract(descriptor.interface)) class MethodDefiner(PropertyDefiner): """ @@ -1425,7 +1410,7 @@ class MethodDefiner(PropertyDefiner): "flags": "JSPROP_ENUMERATE", "condition": MemberCondition(None, None) }) - if not static and requiresQueryInterfaceMethod(descriptor): + if not static and descriptor.wantsQI(): condition = "WantsQueryInterface<%s>::Enabled" % descriptor.nativeType self.regular.append({"name": 'QueryInterface', "methodInfo": False, diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index 1120c35a48b..c63ce0fbf8b 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -368,6 +368,8 @@ class Descriptor(DescriptorProvider): (self.interface.identifier.name, self.nativeOwnership)) self.customTrace = desc.get('customTrace', self.workers) self.customFinalize = desc.get('customFinalize', self.workers) + if desc.get('wantsQI', None) != None: + self._wantsQI = desc.get('wantsQI', None) self.wrapperCache = (not self.interface.isCallback() and (self.nativeOwnership == 'worker' or (self.nativeOwnership != 'owned' and @@ -484,6 +486,26 @@ class Descriptor(DescriptorProvider): self.interface.getExtendedAttribute("PrefControlled") or self.interface.hasInterfacePrototypeObject()) + def wantsQI(self): + # If it was specified explicitly use that. + if hasattr(self, '_wantsQI'): + return self._wantsQI + + # Make sure to not stick QueryInterface on abstract interfaces that + # have hasXPConnectImpls (like EventTarget). So only put it on + # interfaces that are concrete and all of whose ancestors are abstract. + def allAncestorsAbstract(iface): + if not iface.parent: + return True + desc = self.getDescriptor(iface.parent.identifier.name) + if desc.concrete: + return False + return allAncestorsAbstract(iface.parent) + return (not self.workers and + self.interface.hasInterfacePrototypeObject() and + self.concrete and + allAncestorsAbstract(self.interface)) + # Some utility methods def getTypesFromDescriptor(descriptor): """