Bug 1379688 part 1. Remove some restrictions on whether an interface that implements QueryInterface can have a non-abstract ancestor. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 20 Nov 2017 13:59:20 -0500
changeset 437218 55753b766fd5a588742ac73c6b88a55c0021d2f2
parent 437215 52c26719155e2007d14380528ce092b0ebc2014b
child 437219 312db92828f8ac8af5391d5a9533821e6eb758a8
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewerssmaug
bugs1379688
milestone59.0a1
Bug 1379688 part 1. Remove some restrictions on whether an interface that implements QueryInterface can have a non-abstract ancestor. r=smaug This restriction was put in place back when we automatically added QueryInterface to all rootmost non-abstract interfaces. At the time, we needed to make sure it did NOT end up on EventTarget, because then webidl quickstubs would replace the QI impl on non-webidl EventTargets with the WebIDL one, which would not work for them. Since then, we have removed WebIDL quickstubs and we now explicitly list which interfaces get QueryInterface, so this check is no longer needed. MozReview-Commit-ID: 5B13ymdyLp3
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2376,32 +2376,21 @@ class MethodDefiner(PropertyDefiner):
                     raise TypeError("Legacy queryInterface member shouldn't be static")
                 signatures = m.signatures()
 
                 def argTypeIsIID(arg):
                     return arg.type.inner.isExternal() and arg.type.inner.identifier.name == 'IID'
                 if len(signatures) > 1 or len(signatures[0][1]) > 1 or not argTypeIsIID(signatures[0][1][0]):
                     raise TypeError("There should be only one queryInterface method with 1 argument of type IID")
 
-                # 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.descriptor.getDescriptor(iface.parent.identifier.name)
-                    if desc.concrete:
-                        return False
-                    return allAncestorsAbstract(iface.parent)
+                # Make sure to not stick QueryInterface on abstract interfaces.
                 if (not self.descriptor.interface.hasInterfacePrototypeObject() or
-                    not self.descriptor.concrete or
-                    not allAncestorsAbstract(self.descriptor.interface)):
+                    not self.descriptor.concrete):
                     raise TypeError("QueryInterface is only supported on "
-                                    "interfaces that are concrete and all "
-                                    "of whose ancestors are abstract: " +
+                                    "interfaces that are concrete: " +
                                     self.descriptor.name)
                 condition = "WantsQueryInterface<%s>::Enabled" % descriptor.nativeType
                 self.regular.append({
                     "name": 'QueryInterface',
                     "methodInfo": False,
                     "length": 1,
                     "flags": "0",
                     "condition": MemberCondition(func=condition)