Bug 845545: Part 6 - Add a switch to force no QueryInterface function and use it for ImageData. r=bz

This commit is contained in:
Kyle Huey 2013-08-03 16:55:40 -07:00
parent 1de28ca9fd
commit 3e51fcc88e
3 changed files with 26 additions and 16 deletions

View File

@ -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': [

View File

@ -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,

View File

@ -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):
"""