Bug 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, calculate parent prototype names in one place. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 09 Sep 2014 15:19:09 +0200
changeset 207612 7f2d0c477f64
parent 207611 024db535ce4d
child 207613 d7cb38405fc2
push id49735
push userpvanderbeken@mozilla.com
push dateMon, 29 Sep 2014 07:58:28 +0000
treeherdermozilla-inbound@090b62fdfd21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs787070
milestone35.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 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, calculate parent prototype names in one place. r=bz.
dom/bindings/Codegen.py
dom/bindings/Configuration.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -293,19 +293,19 @@ class CGNativePropertyHooks(CGThing):
             constructorID += self.descriptor.name
         else:
             constructorID += "_ID_Count"
         prototypeID = "prototypes::id::"
         if self.descriptor.interface.hasInterfacePrototypeObject():
             prototypeID += self.descriptor.name
         else:
             prototypeID += "_ID_Count"
-        parent = self.descriptor.interface.parent
-        parentHooks = (toBindingNamespace(parent.identifier.name) + "::sNativePropertyHooks"
-                       if parent else 'nullptr')
+        parentProtoName = self.descriptor.parentPrototypeName
+        parentHooks = (toBindingNamespace(parentProtoName) + "::sNativePropertyHooks"
+                       if parentProtoName else 'nullptr')
 
         return fill(
             """
             const NativePropertyHooks sNativePropertyHooks[] = { {
               ${resolveOwnProperty},
               ${enumerateOwnProperties},
               { ${regular}, ${chrome} },
               ${prototypeID},
@@ -322,20 +322,17 @@ class CGNativePropertyHooks(CGThing):
             parentHooks=parentHooks)
 
 
 def NativePropertyHooks(descriptor):
     return "&sWorkerNativePropertyHooks" if descriptor.workers else "sNativePropertyHooks"
 
 
 def DOMClass(descriptor):
-    def make_name(d):
-        return "%s%s" % (d.interface.identifier.name, '_workers' if d.workers else '')
-
-    protoList = ['prototypes::id::' + make_name(descriptor.getDescriptor(proto)) for proto in descriptor.prototypeChain]
+    protoList = ['prototypes::id::' + proto for proto in descriptor.prototypeNameChain]
     # Pad out the list to the right length with _ID_Count so we
     # guarantee that all the lists are the same length.  _ID_Count
     # is never the ID of any prototype, so it's safe to use as
     # padding.
     protoList.extend(['prototypes::id::_ID_Count'] * (descriptor.config.maxProtoChainLength - len(protoList)))
 
     return fill(
         """
@@ -2577,32 +2574,29 @@ class CGCreateInterfaceObjectsMethod(CGA
         args = [Argument('JSContext*', 'aCx'),
                 Argument('JS::Handle<JSObject*>', 'aGlobal'),
                 Argument('ProtoAndIfaceCache&', 'aProtoAndIfaceCache'),
                 Argument('bool', 'aDefineOnGlobal')]
         CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', 'void', args)
         self.properties = properties
 
     def definition_body(self):
-        if len(self.descriptor.prototypeChain) == 1:
+        parentProtoName = self.descriptor.parentPrototypeName
+        if parentProtoName is None:
             parentProtoType = "Rooted"
             if self.descriptor.interface.getExtendedAttribute("ArrayClass"):
                 getParentProto = "aCx, JS_GetArrayPrototype(aCx, aGlobal)"
             elif self.descriptor.interface.getExtendedAttribute("ExceptionClass"):
                 getParentProto = "aCx, JS_GetErrorPrototype(aCx)"
             else:
                 getParentProto = "aCx, JS_GetObjectPrototype(aCx, aGlobal)"
         else:
-            parentProtoName = self.descriptor.prototypeChain[-2]
-            parentDesc = self.descriptor.getDescriptor(parentProtoName)
-            if parentDesc.workers:
-                parentProtoName += '_workers'
+            parentProtoType = "Handle"
             getParentProto = ("%s::GetProtoObject(aCx, aGlobal)" %
                               toBindingNamespace(parentProtoName))
-            parentProtoType = "Handle"
 
         parentWithInterfaceObject = self.descriptor.interface.parent
         while (parentWithInterfaceObject and
                not parentWithInterfaceObject.hasInterfaceObject()):
             parentWithInterfaceObject = parentWithInterfaceObject.parent
         if parentWithInterfaceObject:
             parentIfaceName = parentWithInterfaceObject.identifier.name
             parentDesc = self.descriptor.getDescriptor(parentIfaceName)
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -508,16 +508,26 @@ class Descriptor(DescriptorProvider):
             self.prototypeChain.insert(0, parent.identifier.name)
             parent = parent.parent
         config.maxProtoChainLength = max(config.maxProtoChainLength,
                                          len(self.prototypeChain))
 
     def binaryNameFor(self, name):
         return self._binaryNames.get(name, name)
 
+    @property
+    def prototypeNameChain(self):
+        return map(lambda p: self.getDescriptor(p).name, self.prototypeChain)
+
+    @property
+    def parentPrototypeName(self):
+        if len(self.prototypeChain) == 1:
+            return None
+        return self.getDescriptor(self.prototypeChain[-2]).name
+
     def hasInterfaceOrInterfacePrototypeObject(self):
 
         # Forward-declared interfaces don't need either interface object or
         # interface prototype object as they're going to use QI (on main thread)
         # or be passed as a JSObject (on worker threads).
         if self.interface.isExternal():
             return False