Bug 792980. Don't force consumers to list descriptors for interfaces that are using all teh defaults. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 01 Oct 2012 08:56:31 -0400
changeset 108754 86cc9c289960e869d047a72372f060c919879c66
parent 108753 b16fb4f4ad481335da9d58e233dffc8f4ae35918
child 108755 94526a90222e6c46c25723cda44d04625e8c4c2e
push id23589
push userryanvm@gmail.com
push dateTue, 02 Oct 2012 01:31:11 +0000
treeherdermozilla-central@fb076a446870 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs792980
milestone18.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 792980. Don't force consumers to list descriptors for interfaces that are using all teh defaults. r=peterv The new setup is: * Consequential interfaces with no explicit descriptor are still skipped. * If no information is provided about an interface, an empty descriptor is assumed. * If a list is provided and the only entry is a worker descriptor, an empty main-thread descriptor is assumed.
dom/bindings/Bindings.conf
dom/bindings/Configuration.py
dom/bindings/parser/WebIDL.py
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -78,38 +78,29 @@
 #
 #   * implicitJSContext - attributes and methods specified in the .webidl file
 #                         that require a JSContext as the first argument
 #   * resultNotAddRefed - attributes and methods specified in the .webidl file
 #                         that do not AddRef the return value
 
 DOMInterfaces = {
 
-'AudioBuffer' : {
-},
-
 'mozAudioContext': {
     'nativeType': 'AudioContext',
     'implicitJSContext': [ 'createBuffer' ],
 },
 
 'AudioNode' : {
     'concrete': False,
 },
 
 'AudioSourceNode': {
     'concrete': False,
 },
 
-'AudioBufferSourceNode': {
-},
-
-'AudioDestinationNode': {
-},
-
 'Blob': [
 {
     'headerFile': 'nsIDOMFile.h',
 },
 {
     'workers': True,
 }],
 
@@ -171,25 +162,21 @@ DOMInterfaces = {
     'prefable': True,
     'binaryNames': {
         '__stringifier': 'Stringify'
     }
 }],
 
 'Event': [
 {
-},
-{
     'workers': True,
 }],
 
 'EventListener': [
 {
-},
-{
     'workers': True,
 }],
 
 'EventTarget': [
 {
     'nativeType': 'nsDOMEventTargetHelper',
     'hasInstanceInterface': 'nsIDOMEventTarget',
     'concrete': False,
@@ -203,25 +190,22 @@ DOMInterfaces = {
 'FileList': [
 {
     'nativeType': 'nsDOMFileList',
     'headerFile': 'nsDOMFile.h',
     'prefable': True,
     'resultNotAddRefed': [ 'item' ]
 }],
 
-'FileReaderSync': [
-{
+'FileReaderSync': {
     'workers': True,
-}],
+},
 
 'FormData': [
 {
-},
-{
     'workers': True,
 }],
 
 'HTMLCollection': [
 {
     'nativeType': 'nsIHTMLCollection',
     'prefable': True,
     'resultNotAddRefed': [ 'item' ]
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -1,12 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
+from WebIDL import IDLInterface, IDLExternalInterface
+
 autogenerated_comment = "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
 
 class Configuration:
     """
     Represents global configuration state based on IDL parse data and
     the configuration file.
     """
     def __init__(self, filename, parseData):
@@ -18,24 +20,41 @@ class Configuration:
 
         # Build descriptors for all the interfaces we have in the parse data.
         # This allows callers to specify a subset of interfaces by filtering
         # |parseData|.
         self.descriptors = []
         self.interfaces = {}
         self.maxProtoChainLength = 0;
         for thing in parseData:
-            if not thing.isInterface(): continue
+            # Some toplevel things are sadly types, and those have an
+            # isInterface that doesn't mean the same thing as IDLObject's
+            # isInterface()...
+            if (not isinstance(thing, IDLInterface) and
+                not isinstance(thing, IDLExternalInterface)):
+                continue
             iface = thing
-            if iface.identifier.name not in config: continue
             self.interfaces[iface.identifier.name] = iface
-            entry = config[iface.identifier.name]
+            if iface.identifier.name not in config:
+                # Completely skip consequential interfaces with no descriptor
+                # because chances are we don't need to do anything interesting
+                # with them.
+                if iface.isConsequential():
+                    continue
+                entry = {}
+            else:
+                entry = config[iface.identifier.name]
             if not isinstance(entry, list):
                 assert isinstance(entry, dict)
                 entry = [entry]
+            elif len(entry) == 1 and entry[0].get("workers", False):
+                # List with only a workers descriptor means we should
+                # infer a mainthread descriptor.  If you want only
+                # workers bindings, don't use a list here.
+                entry.append({})
             self.descriptors.extend([Descriptor(self, iface, x) for x in entry])
 
         # Mark the descriptors for which only a single nativeType implements
         # an interface.
         for descriptor in self.descriptors:
             intefaceName = descriptor.interface.identifier.name
             otherDescriptors = [d for d in self.descriptors
                                 if d.interface.identifier.name == intefaceName]
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -1428,17 +1428,19 @@ class IDLTypedefType(IDLType, IDLObjectW
     def complete(self, parentScope):
         if not self.inner.isComplete():
             self.inner = self.inner.complete(parentScope)
         assert self.inner.isComplete()
         return self.inner
 
     def finish(self, parentScope):
         # Maybe the IDLObjectWithIdentifier for the typedef should be
-        # a separate thing from the type?
+        # a separate thing from the type?  If that happens, we can
+        # remove some hackery around avoiding isInterface() in
+        # Configuration.py.
         self.complete(parentScope)
 
     def validate(self):
         pass
 
     # Do we need a resolveType impl?  I don't think it's particularly useful....
 
     def tag(self):