Bug 1048699 - Patch 2 - Indentation and proper include. r=bz
authorNikhil Marathe <nsm.nikhil@gmail.com>
Thu, 28 Aug 2014 13:33:39 -0700
changeset 202283 58c44d7982aff91f0ed210a1c4f4a3cd1f646620
parent 202282 53d33674eb30ef1a3cd6c36722569c404e07ca03
child 202284 af568e909c625ca3c098ee2426fe51b6905b96fb
push id27395
push usercbook@mozilla.com
push dateFri, 29 Aug 2014 12:55:06 +0000
treeherdermozilla-central@5f66dd3d63f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1048699
milestone34.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 1048699 - Patch 2 - Indentation and proper include. r=bz
dom/bindings/Codegen.py
dom/bindings/Configuration.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2860,36 +2860,36 @@ class CGConstructorEnabled(CGAbstractMet
     def definition_body(self):
         body = CGList([], "\n")
 
         conditions = []
         iface = self.descriptor.interface
 
         if not iface.isExposedInWindow():
             exposedInWindowCheck = dedent(
-              """
-              if (NS_IsMainThread()) {
-                return false;
-              }
-              """)
+                """
+                if (NS_IsMainThread()) {
+                  return false;
+                }
+                """)
             body.append(CGGeneric(exposedInWindowCheck))
 
         if iface.isExposedInAnyWorker() and iface.isExposedOnlyInSomeWorkers():
             workerGlobals = sorted(iface.getWorkerExposureSet())
-            workerCondition = CGList((CGGeneric('strcmp(name, "%s")'% workerGlobal)
-                                        for workerGlobal in workerGlobals), " && ")
+            workerCondition = CGList((CGGeneric('strcmp(name, "%s")' % workerGlobal)
+                                      for workerGlobal in workerGlobals), " && ")
             exposedInWorkerCheck = fill(
-              """
-              if (!NS_IsMainThread()) {
-                const char* name = js::GetObjectClass(aObj)->name;
-                if (${workerCondition}) {
-                  return false;
+                """
+                if (!NS_IsMainThread()) {
+                  const char* name = js::GetObjectClass(aObj)->name;
+                  if (${workerCondition}) {
+                    return false;
+                  }
                 }
-              }
-              """, workerCondition=workerCondition.define())
+                """, workerCondition=workerCondition.define())
             body.append(CGGeneric(exposedInWorkerCheck))
 
         pref = iface.getExtendedAttribute("Pref")
         if pref:
             assert isinstance(pref, list) and len(pref) == 1
             conditions.append('Preferences::GetBool("%s")' % pref[0])
         if iface.getExtendedAttribute("ChromeOnly"):
             conditions.append("nsContentUtils::ThreadsafeIsCallerChrome()")
@@ -2904,17 +2904,17 @@ class CGConstructorEnabled(CGAbstractMet
         if checkPermissions is not None:
             conditions.append("CheckPermissions(aCx, aObj, permissions_%i)" % checkPermissions)
         # We should really have some conditions
         assert len(body) or len(conditions)
 
         conditionsWrapper = ""
         if len(conditions):
           conditionsWrapper = CGWrapper(CGList((CGGeneric(cond) for cond in conditions),
-                                        " &&\n"),
+                                               " &&\n"),
                                         pre="return ", post=";\n", reindent=True)
         else:
           conditionsWrapper = CGGeneric("return true;\n")
 
         body.append(conditionsWrapper)
         return body.define()
 
 
@@ -11677,17 +11677,16 @@ class CGRegisterWorkerBindings(CGAbstrac
         conditions = []
         for desc in descriptors:
             bindingNS = toBindingNamespace(desc.name)
             condition = "!%s::GetConstructorObject(aCx, aObj)" % bindingNS
             if desc.isExposedConditionally():
                 condition = (
                     "%s::ConstructorEnabled(aCx, aObj) && " % bindingNS
                     + condition)
-
             conditions.append(condition)
         lines = [CGIfWrapper(CGGeneric("return false;\n"), condition) for
                  condition in conditions]
         lines.append(CGGeneric("return true;\n"))
         return CGList(lines, "\n").define()
 
 
 class CGRegisterProtos(CGAbstractMethod):
@@ -11967,17 +11966,23 @@ class CGBindingRoot(CGThing):
 
         bindingHeaders["nsContentUtils.h"] = any(
             descriptorHasChromeOnly(d) for d in descriptors)
         # 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
-        bindingHeaders["nsThreadUtils.h"] = hasWorkerStuff
+
+        def descriptorHasThreadChecks(desc):
+            return ((not desc.workers and not desc.interface.isExposedInWindow()) or
+                    (desc.interface.isExposedInAnyWorker() and desc.interface.isExposedOnlyInSomeWorkers()))
+
+        hasThreadChecks = hasWorkerStuff or any(d.hasThreadChecks() for d in descriptors)
+        bindingHeaders["nsThreadUtils.h"] = hasThreadChecks
 
         dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
         hasNonEmptyDictionaries = any(
             len(dict.members) > 0 for dict in dictionaries)
         mainCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
                                             workers=False)
         workerCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
                                               workers=True)
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -540,25 +540,28 @@ class Descriptor(DescriptorProvider):
         not pref-controlled, has no prototype object, and has no
         static methods or attributes.
         """
         return (self.interface.isExternal() or self.concrete or
             self.interface.hasInterfacePrototypeObject() or
             any((m.isAttr() or m.isMethod()) and m.isStatic() for m
                 in self.interface.members))
 
+    def hasThreadChecks(self):
+        return ((not self.workers and not self.interface.isExposedInWindow()) or
+                (self.interface.isExposedInAnyWorker() and
+                 self.interface.isExposedOnlyInSomeWorkers()))
+
     def isExposedConditionally(self):
         return (self.interface.getExtendedAttribute("Pref") or
                 self.interface.getExtendedAttribute("ChromeOnly") or
                 self.interface.getExtendedAttribute("Func") or
                 self.interface.getExtendedAttribute("AvailableIn") or
                 self.interface.getExtendedAttribute("CheckPermissions") or
-                (not self.workers and not self.interface.isExposedInWindow()) or
-                (self.interface.isExposedInAnyWorker() and
-                 self.interface.isExposedOnlyInSomeWorkers()))
+                self.hasThreadChecks())
 
     def needsXrayResolveHooks(self):
         """
         Generally, any interface with NeedNewResolve needs Xray
         resolveOwnProperty and enumerateOwnProperties hooks.  But for
         the special case of plugin-loading elements, we do NOT want
         those, because we don't want to instantiate plug-ins simply
         due to chrome touching them and that's all those hooks do on