Bug 1257037 part 13. Get rid of the concept of worker vs non-worker descriptors. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 08 Jul 2016 00:37:55 -0400
changeset 304152 762c289ada581c1cef856ab16b241355c2d6c7bc
parent 304151 5014c7d22f2fa4e01822949e7c54467a08c16d0a
child 304153 4082fdfd16fb2e87556f948bb09e3c3edfdd9fb1
push id79254
push userbzbarsky@mozilla.com
push dateFri, 08 Jul 2016 04:38:07 +0000
treeherdermozilla-inbound@a92d0eec5c91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1257037
milestone50.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 1257037 part 13. Get rid of the concept of worker vs non-worker descriptors. r=khuey
dom/bindings/Bindings.conf
dom/bindings/Codegen.py
dom/bindings/Configuration.py
dom/webidl/XMLHttpRequestEventTarget.webidl
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -3,82 +3,62 @@
 # 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/.
 
 # DOM Bindings Configuration.
 #
 # The WebIDL interfaces are defined in dom/webidl. For interfaces requiring
 # special handling, there are corresponding entries in the configuration table
-# below. The configuration table maps each interface name to a |descriptor| or
-# list of |descriptor|s.
+# below. The configuration table maps each interface name to a |descriptor|.
 #
 # Valid fields for all descriptors:
 #   * nativeType - The native type (concrete class or XPCOM interface) that
 #                  instances of this interface will unwrap to.  If not
 #                  specified, defaults to 'nsIDOM' followed by the interface
-#                  name for external interfaces,
-#                  'mozilla::dom::workers::InterfaceName' for worker
-#                  non-callback interfaces, and 'mozilla::dom::InterfaceName'
-#                  for everything else.
+#                  name for external interfaces and
+#                  'mozilla::dom::InterfaceName' for everything else.
 #   * headerFile - The file in which the nativeType is declared (defaults
 #                  to an educated guess).
 #   * concrete - Indicates whether there exist JS objects with this interface as
 #                their primary interface (and hence whose prototype is this
 #                interface's prototype object).  Always False for callback
 #                interfaces.  Defaults to True otherwise.
-#   * workers - Indicates whether the descriptor is intended to be used solely
-#               for worker threads (defaults to false). If true the interface
-#               will not be made available on the main thread.
 #   * notflattened - The native type does not have nsIClassInfo, so when
 #                    wrapping it the right IID needs to be passed in.
 #                    Only relevant for callback interfaces.
 #   * register - True if this binding should be registered.  Defaults to true.
 #   * binaryNames - Dict for mapping method and attribute names to different
 #                   names when calling the native methods (defaults to an empty
 #                   dict). The keys are the property names as they appear in the
 #                   .webidl file and the values are the names as they should be
 #                   in the WebIDL.
 #   * wrapperCache: True if this object is a wrapper cache.  Objects that are
 #                   not can only be returned from a limited set of methods,
 #                   cannot be prefable, and must ensure that they disallow
 #                   XPConnect wrapping.  Always false for callback interfaces.
-#                   Always true for worker descriptors for non-callback
-#                   interfaces.  Defaults to true for non-worker non-callback
-#                   descriptors.
+#                   Defaults to true for non-callback descriptors.
 #
-# A non-worker descriptor can have 'wantsXrays': False specified if it
+# A descriptor can have 'wantsXrays': False specified if it
 # should not have Xray hooks generated.  Make sure to have someone
 # familiar with Xrays review any use of this!
 #
 # The following fields are either a string, an array (defaults to an empty
 # array) or a dictionary with three possible keys (all, getterOnly and
 # setterOnly) each having such an array as the value
 #
 #   * implicitJSContext - attributes and methods specified in the .webidl file
 #                         that require a JSContext as the first argument
 #
 # A descriptor can also have 'skipGen': True specified if it should be skipped
 # when deciding what header includes to generate and should never have an
-# implementation generated for it.  This is only needed in special cases like
-# worker descriptors for objects that will never actually appear in workers.
+# implementation generated for it.  This is now unused and is about to go away.
 #
-# The value for an interface can be a list or a dictionary, which affects which
-# bindings are generated for that interface.
-# - If the value for the interface is just a record, then a single binding for
-#   will be generated using those settings.
-# - If it is a list with a single record which has 'workers':True, then that
-#   record will be used to generate bindings for workers, plus the default
-#   settings will be used to generate bindings for the main thread.
-# - If it is a list with two records, then one should have 'workers':True,
-#   and the other should have 'workers':False (or left unset). These will
-#   be used to generate bindings for workers and for mainthread, as you would
-#   expect.
-# Nothing else is allowed.  If you have a list with a single 'workers':False
-# entry, just make it not a list.
+# The value for an interface is a dictionary which specifies the
+# descriptor to use when generating that interface's binding.
 
 DOMInterfaces = {
 
 'AbstractWorker': {
     'concrete': False
 },
 
 'AnimationEffectReadOnly': {
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -13002,17 +13002,16 @@ class CGResolveSystemBinding(CGAbstractM
                                    Argument('JS::Handle<JSObject*>', 'aObj'),
                                    Argument('JS::Handle<jsid>', 'aId'),
                                    Argument('bool*', 'aResolvedp')])
         self.config = config
 
     def definition_body(self):
         descriptors = self.config.getDescriptors(hasInterfaceObject=True,
                                                  isExposedInSystemGlobals=True,
-                                                 workers=False,
                                                  register=True,
                                                  skipGen=False)
 
         def descNameToId(name):
             return "s%s_id" % name
         jsidNames = [descNameToId(desc.name) for desc in descriptors]
         jsidDecls = CGList(CGGeneric("static jsid %s;\n" % name)
                            for name in jsidNames)
@@ -13365,21 +13364,18 @@ class CGBindingRoot(CGThing):
                       (ctor and isChromeOnly(ctor)))) or
                     # JS-implemented interfaces with clearable cached
                     # attrs have chromeonly _clearFoo methods.
                     (desc.interface.isJSImplemented() and
                      any(clearableCachedAttrs(desc))))
 
         # XXXkhuey ugly hack but this is going away soon.
         bindingHeaders['xpcprivate.h'] = webIDLFile.endswith("EventTarget.webidl")
-        hasWorkerStuff = len(config.getDescriptors(webIDLFile=webIDLFile,
-                                                   workers=True)) != 0
-        bindingHeaders["WorkerPrivate.h"] = hasWorkerStuff
-
-        hasThreadChecks = hasWorkerStuff or any(d.hasThreadChecks() for d in descriptors)
+
+        hasThreadChecks = any(d.hasThreadChecks() for d in descriptors)
         bindingHeaders["nsThreadUtils.h"] = hasThreadChecks
 
         dictionaries = config.getDictionaries(webIDLFile)
 
         def dictionaryHasChromeOnly(dictionary):
             while dictionary:
                 if (any(isChromeOnly(m) for m in dictionary.members)):
                     return True
@@ -13487,17 +13483,17 @@ class CGBindingRoot(CGThing):
         cgthings.extend(CGCallbackFunction(c, config) for c in callbacks)
 
         cgthings.extend([CGNamespace('binding_detail', CGFastCallback(c))
                          for c in callbacks])
 
         # Do codegen for all the descriptors
         cgthings.extend([CGDescriptor(x) for x in descriptors])
 
-        # Do codegen for all the callback interfaces.  Skip worker callbacks.
+        # Do codegen for all the callback interfaces.
         cgthings.extend([CGCallbackInterface(x) for x in callbackDescriptors])
 
         cgthings.extend([CGNamespace('binding_detail',
                                      CGFastCallback(x.interface))
                          for x in callbackDescriptors])
 
         # Do codegen for JS implemented classes
         def getParentDescriptor(desc):
@@ -16257,23 +16253,21 @@ class GlobalGenRoots():
         # Wrap all of that in our namespaces.
         curr = CGNamespace.build(['mozilla', 'dom'],
                                  CGWrapper(curr, post='\n'))
         curr = CGWrapper(curr, post='\n')
 
         # Add the includes
         defineIncludes = [CGHeaders.getDeclarationFilename(desc.interface)
                           for desc in config.getDescriptors(hasInterfaceObject=True,
-                                                            workers=False,
                                                             isExposedInWindow=True,
                                                             register=True)]
         defineIncludes.append('mozilla/dom/WebIDLGlobalNameHash.h')
         defineIncludes.extend([CGHeaders.getDeclarationFilename(desc.interface)
                                for desc in config.getDescriptors(isNavigatorProperty=True,
-                                                                 workers=False,
                                                                  register=True)])
         curr = CGHeaders([], [], [], [], [], defineIncludes, 'RegisterBindings',
                          curr)
 
         # Add include guards.
         curr = CGIncludeGuard('RegisterBindings', curr)
 
         # Done.
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -272,47 +272,36 @@ def MemberIsUnforgeable(member, descript
 
 class Descriptor(DescriptorProvider):
     """
     Represents a single descriptor for an interface. See Bindings.conf.
     """
     def __init__(self, config, interface, desc):
         DescriptorProvider.__init__(self)
         self.config = config
-        self.workers = desc.get('workers', False)
         self.interface = interface
 
-        if self.workers:
-            assert 'wantsXrays' not in desc
-            self.wantsXrays = False
-        else:
-            self.wantsXrays = desc.get('wantsXrays', True)
+        self.wantsXrays = desc.get('wantsXrays', True)
 
         # Read the desc, and fill in the relevant defaults.
         ifaceName = self.interface.identifier.name
         # For generated iterator interfaces for other iterable interfaces, we
         # just use IterableIterator as the native type, templated on the
         # nativeType of the iterable interface. That way we can have a
         # templated implementation for all the duplicated iterator
         # functionality.
         if self.interface.isIteratorInterface():
             itrName = self.interface.iterableInterface.identifier.name
             itrDesc = self.getDescriptor(itrName)
             nativeTypeDefault = iteratorNativeType(itrDesc)
 
         elif self.interface.isExternal():
-            assert not self.workers
             nativeTypeDefault = "nsIDOM" + ifaceName
-        elif self.interface.isCallback():
-            nativeTypeDefault = "mozilla::dom::" + ifaceName
         else:
-            if self.workers:
-                nativeTypeDefault = "mozilla::dom::workers::" + ifaceName
-            else:
-                nativeTypeDefault = "mozilla::dom::" + ifaceName
+            nativeTypeDefault = "mozilla::dom::" + ifaceName
 
         self.nativeType = desc.get('nativeType', nativeTypeDefault)
         # Now create a version of nativeType that doesn't have extra
         # mozilla::dom:: at the beginning.
         prettyNativeType = self.nativeType.split("::")
         if prettyNativeType[0] == "mozilla":
             prettyNativeType.pop(0)
             if prettyNativeType[0] == "dom":
@@ -327,19 +316,17 @@ class Descriptor(DescriptorProvider):
         elif self.interface.isCallback() or self.interface.isJSImplemented():
             # A copy of CGHeaders.getDeclarationFilename; we can't
             # import it here, sadly.
             # Use our local version of the header, not the exported one, so that
             # test bindings, which don't export, will work correctly.
             basename = os.path.basename(self.interface.filename())
             headerDefault = basename.replace('.webidl', 'Binding.h')
         else:
-            if self.workers:
-                headerDefault = "mozilla/dom/workers/bindings/%s.h" % ifaceName
-            elif not self.interface.isExternal() and self.interface.getExtendedAttribute("HeaderFile"):
+            if not self.interface.isExternal() and self.interface.getExtendedAttribute("HeaderFile"):
                 headerDefault = self.interface.getExtendedAttribute("HeaderFile")[0]
             elif self.interface.isIteratorInterface():
                 headerDefault = "mozilla/dom/IterableIterator.h"
             else:
                 headerDefault = self.nativeType
                 headerDefault = headerDefault.replace("::", "/") + ".h"
         self.headerFile = desc.get('headerFile', headerDefault)
         self.headerIsDefault = self.headerFile == headerDefault
@@ -473,19 +460,17 @@ class Descriptor(DescriptorProvider):
         # Nasty temporary hack for supporting both DOM and SpiderMonkey promises
         # without too much pain
         if self.interface.identifier.name == "Promise":
             assert self.wrapperCache
             # But really, we're only wrappercached if we have an interface
             # object (that is, when we're not using SpiderMonkey promises).
             self.wrapperCache = self.interface.hasInterfaceObject()
 
-        def make_name(name):
-            return name + "_workers" if self.workers else name
-        self.name = make_name(interface.identifier.name)
+        self.name = interface.identifier.name
 
         # self.extendedAttributes is a dict of dicts, keyed on
         # all/getterOnly/setterOnly and then on member name. Values are an
         # array of extended attributes.
         self.extendedAttributes = {'all': {}, 'getterOnly': {}, 'setterOnly': {}}
 
         def addExtendedAttribute(attribute, config):
             def add(key, members, attribute):
@@ -613,43 +598,37 @@ class Descriptor(DescriptorProvider):
     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).
+        # interface prototype object as they're going to use QI.
         if self.interface.isExternal():
             return False
 
         return self.interface.hasInterfaceObject() or self.interface.hasInterfacePrototypeObject()
 
     @property
     def hasNamedPropertiesObject(self):
         if self.interface.isExternal():
             return False
 
         return self.isGlobal() and self.supportsNamedProperties()
 
     def getExtendedAttributes(self, member, getter=False, setter=False):
         def ensureValidThrowsExtendedAttribute(attr):
-            assert(attr is None or attr is True or len(attr) == 1)
-            if (attr is not None and attr is not True and
-                'Workers' not in attr and 'MainThread' not in attr):
+            if (attr is not None and attr is not True):
                 raise TypeError("Unknown value for 'Throws': " + attr[0])
 
         def maybeAppendInfallibleToAttrs(attrs, throws):
             ensureValidThrowsExtendedAttribute(throws)
-            if (throws is None or
-                (throws is not True and
-                 ('Workers' not in throws or not self.workers) and
-                 ('MainThread' not in throws or self.workers))):
+            if throws is None:
                 attrs.append("infallible")
 
         name = member.identifier.name
         throws = self.interface.isJSImplemented() or member.getExtendedAttribute("Throws")
         if member.isMethod():
             # JSObject-returning [NewObject] methods must be fallible,
             # since they have to (fallibly) allocate the new JSObject.
             if (member.getExtendedAttribute("NewObject") and
@@ -754,17 +733,16 @@ class Descriptor(DescriptorProvider):
                 return False
             iface = iface.parent
         return True
 
     @property
     def registersGlobalNamesOnWindow(self):
         return (not self.interface.isExternal() and
                 self.interface.hasInterfaceObject() and
-                not self.workers and
                 self.interface.isExposedInWindow() and
                 self.register)
 
     def getDescriptor(self, interfaceName):
         """
         Gets the appropriate descriptor for the given interface name.
         """
         return self.config.getDescriptor(interfaceName)
--- a/dom/webidl/XMLHttpRequestEventTarget.webidl
+++ b/dom/webidl/XMLHttpRequestEventTarget.webidl
@@ -8,29 +8,22 @@
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Exposed=(Window,DedicatedWorker,SharedWorker)]
 interface XMLHttpRequestEventTarget : EventTarget {
   // event handlers
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler onloadstart;
 
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler onprogress;
 
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler onabort;
 
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler onerror;
 
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler onload;
 
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler ontimeout;
 
-  [SetterThrows=Workers, GetterThrows=Workers]
   attribute EventHandler onloadend;
 };