Bug 887533: Remove even more includes from dom/bindings. r=bz
authorKyle Huey <khuey@kylehuey.com>
Thu, 22 Aug 2013 22:17:11 -0700
changeset 157034 15380522db960ea53f302e21699adc6fedac4c17
parent 157033 d84b8ecb416c7838ff7cb0412461d611aa755fbf
child 157035 c61fe8e1f887481651c67e45823d2244fa387075
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs887533
milestone26.0a1
Bug 887533: Remove even more includes from dom/bindings. r=bz
content/base/public/nsINodeList.h
content/base/src/nsDOMAttributeMap.h
content/base/src/nsXMLHttpRequest.h
content/html/content/src/HTMLPropertiesCollection.h
content/svg/content/src/SVGAnimatedRect.h
content/svg/content/src/SVGPreserveAspectRatio.h
dom/base/BarProps.h
dom/base/Crypto.h
dom/base/DOMError.h
dom/base/nsMimeTypeArray.h
dom/base/nsPerformance.h
dom/bindings/Codegen.py
dom/camera/DOMCameraManager.h
dom/promise/Promise.h
dom/src/geolocation/nsGeolocation.h
layout/style/nsICSSDeclaration.h
--- a/content/base/public/nsINodeList.h
+++ b/content/base/public/nsINodeList.h
@@ -3,19 +3,17 @@
  * 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/. */
 
 #ifndef nsINodeList_h___
 #define nsINodeList_h___
 
 #include "nsIDOMNodeList.h"
 #include "nsWrapperCache.h"
-
-class nsINode;
-class nsIContent;
+#include "nsIContent.h"
 
 // IID for the nsINodeList interface
 #define NS_INODELIST_IID \
 { 0xadb5e54c, 0x6e96, 0x4102, \
  { 0x8d, 0x40, 0xe0, 0x12, 0x3d, 0xcf, 0x48, 0x7a } }
 
 /**
  * An internal interface for a reasonably fast indexOf.
--- a/content/base/src/nsDOMAttributeMap.h
+++ b/content/base/src/nsDOMAttributeMap.h
@@ -18,22 +18,16 @@
 #include "nsRefPtrHashtable.h"
 #include "nsStringGlue.h"
 #include "nsWrapperCache.h"
 
 class nsIAtom;
 class nsINodeInfo;
 class nsIDocument;
 
-namespace mozilla {
-namespace dom {
-class Element;
-} // namespace dom
-} // namespace mozilla
-
 /**
  * Structure used as a key for caching Attrs in nsDOMAttributeMap's mAttributeCache.
  */
 class nsAttrKey
 {
 public:
   /**
    * The namespace of the attribute
@@ -206,10 +200,14 @@ private:
   Attr* GetAttribute(nsINodeInfo* aNodeInfo, bool aNsAware);
 
   /**
    * Remove an attribute, returns the removed node.
    */
   already_AddRefed<Attr> RemoveAttribute(nsINodeInfo* aNodeInfo);
 };
 
+// XXX khuey yes this is crazy.  The bindings code needs to see this include,
+// but if we pull it in at the top of the file we get a circular include
+// problem.
+#include "mozilla/dom/Element.h"
 
 #endif /* nsDOMAttributeMap_h */
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsIXMLHttpRequest.h"
 #include "nsISupportsUtils.h"
 #include "nsString.h"
 #include "nsIURI.h"
 #include "nsIHttpChannel.h"
 #include "nsIDocument.h"
+#include "nsIContent.h"
 #include "nsIStreamListener.h"
 #include "nsWeakReference.h"
 #include "jsapi.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIHttpHeaderVisitor.h"
 #include "nsIProgressEventSink.h"
--- a/content/html/content/src/HTMLPropertiesCollection.h
+++ b/content/html/content/src/HTMLPropertiesCollection.h
@@ -14,18 +14,18 @@
 #include "nsCOMArray.h"
 #include "nsIMutationObserver.h"
 #include "nsStubMutationObserver.h"
 #include "nsBaseHashtable.h"
 #include "nsINodeList.h"
 #include "nsIHTMLCollection.h"
 #include "nsHashKeys.h"
 #include "nsRefPtrHashtable.h"
+#include "nsGenericHTMLElement.h"
 
-class nsGenericHTMLElement;
 class nsIDocument;
 class nsINode;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLPropertiesCollection;
 class PropertyNodeList;
--- a/content/svg/content/src/SVGAnimatedRect.h
+++ b/content/svg/content/src/SVGAnimatedRect.h
@@ -6,18 +6,18 @@
 #ifndef mozilla_dom_SVGAnimatedRect_h
 #define mozilla_dom_SVGAnimatedRect_h
 
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/SVGRectBinding.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsWrapperCache.h"
+#include "nsSVGElement.h"
 
-class nsSVGElement;
 class nsSVGViewBox;
 
 namespace mozilla {
 namespace dom {
 
 class SVGAnimatedRect MOZ_FINAL : public nsWrapperCache
 {
 public:
--- a/content/svg/content/src/SVGPreserveAspectRatio.h
+++ b/content/svg/content/src/SVGPreserveAspectRatio.h
@@ -6,18 +6,17 @@
 #pragma once
 
 #include "mozilla/TypedEnum.h"
 
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/ErrorResult.h"
-
-class nsSVGElement;
+#include "nsSVGElement.h"
 
 namespace mozilla {
 // Alignment Types
 enum SVGAlign MOZ_ENUM_TYPE(uint8_t) {
   SVG_PRESERVEASPECTRATIO_UNKNOWN = 0,
   SVG_PRESERVEASPECTRATIO_NONE = 1,
   SVG_PRESERVEASPECTRATIO_XMINYMIN = 2,
   SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3,
--- a/dom/base/BarProps.h
+++ b/dom/base/BarProps.h
@@ -11,20 +11,20 @@
 
 #ifndef mozilla_dom_BarProps_h
 #define mozilla_dom_BarProps_h
 
 #include "mozilla/Attributes.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
+#include "nsPIDOMWindow.h"
 
 class nsGlobalWindow;
 class nsIWebBrowserChrome;
-class nsPIDOMWindow;
 
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 
 // Script "BarProp" object
--- a/dom/base/Crypto.h
+++ b/dom/base/Crypto.h
@@ -6,23 +6,23 @@
 
 #ifdef MOZ_DISABLE_CRYPTOLEGACY
 #include "nsIDOMCrypto.h"
 #else
 #include "nsIDOMCryptoLegacy.h"
 class nsIDOMCRMFObject;
 #endif
 
+#include "nsPIDOMWindow.h"
+
 #include "nsWrapperCache.h"
 #include "mozilla/dom/TypedArray.h"
 #define NS_DOMCRYPTO_CID \
   {0x929d9320, 0x251e, 0x11d4, { 0x8a, 0x7c, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} }
 
-class nsPIDOMWindow;
-
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 
 class Crypto : public nsIDOMCrypto,
                public nsWrapperCache
--- a/dom/base/DOMError.h
+++ b/dom/base/DOMError.h
@@ -6,18 +6,17 @@
 
 #ifndef mozilla_dom_domerror_h__
 #define mozilla_dom_domerror_h__
 
 #include "mozilla/Attributes.h"
 #include "nsWrapperCache.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
-
-class nsPIDOMWindow;
+#include "nsPIDOMWindow.h"
 
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 
 class GlobalObject;
--- a/dom/base/nsMimeTypeArray.h
+++ b/dom/base/nsMimeTypeArray.h
@@ -7,18 +7,18 @@
 #ifndef nsMimeTypeArray_h___
 #define nsMimeTypeArray_h___
 
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsAutoPtr.h"
+#include "nsPIDOMWindow.h"
 
-class nsPIDOMWindow;
 class nsMimeType;
 class nsPluginElement;
 
 class nsMimeTypeArray MOZ_FINAL : public nsISupports,
                                   public nsWrapperCache
 {
 public:
   nsMimeTypeArray(nsWeakPtr aWindow);
--- a/dom/base/nsPerformance.h
+++ b/dom/base/nsPerformance.h
@@ -6,19 +6,19 @@
 #define nsPerformance_h___
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "nsWrapperCache.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsContentUtils.h"
+#include "nsIDOMWindow.h"
 
 class nsITimedChannel;
-class nsIDOMWindow;
 class nsPerformance;
 class JSObject;
 struct JSContext;
 
 // Script "performance.timing" object
 class nsPerformanceTiming MOZ_FINAL : public nsWrapperCache
 {
 public:
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -8613,16 +8613,36 @@ class CGBindingRoot(CGThing):
                                             workers=False)
         workerCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
                                               workers=True)
         callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
                                                     isCallback=True)
         jsImplemented = config.getDescriptors(webIDLFile=webIDLFile,
                                               isJSImplemented=True)
 
+        # Python can't modify closed-over variables directly, so sneak
+        # our mutable value in as an entry in a dictionary.
+        needsDOMQS = { "value": any(d.hasXPConnectImpls for d in descriptors) }
+        # Only mainthread things can have hasXPConnectImpls
+        provider = config.getDescriptorProvider(False)
+        def checkForXPConnectImpls(type, descriptor=None, dictionary=None):
+            if needsDOMQS["value"]:
+                return
+            type = type.unroll()
+            if not type.isInterface() or not type.isGeckoInterface():
+                return
+            try:
+                typeDesc = provider.getDescriptor(type.inner.identifier.name)
+            except NoSuchDescriptorError:
+                return
+            needsDOMQS["value"] = typeDesc.hasXPConnectImpls
+
+        callForEachType(descriptors + callbackDescriptors, dictionaries,
+                        mainCallbacks, checkForXPConnectImpls)
+
         descriptorsWithPrototype = filter(lambda d: d.interface.hasInterfacePrototypeObject(),
                                           descriptors)
         traitsClasses = [CGPrototypeTraitsClass(d) for d in descriptorsWithPrototype]
 
         # We must have a 1:1 mapping here, skip for prototypes which
         # share an implementation with other prototypes.
         traitsClasses.extend([CGPrototypeIDMapClass(d) for d in descriptorsWithPrototype
                               if d.unsharedImplementation])
@@ -8698,27 +8718,26 @@ class CGBindingRoot(CGThing):
                          ['mozilla/dom/BindingDeclarations.h',
                           'mozilla/ErrorResult.h',
                           'mozilla/dom/DOMJSClass.h',
                           'mozilla/dom/DOMJSProxyHandler.h'],
                          ['mozilla/dom/BindingUtils.h',
                           'mozilla/dom/Nullable.h',
                           'PrimitiveConversions.h',
                           'WrapperFactory.h',
-                          # Have to include nsDOMQS.h to get fast arg unwrapping
-                          # for old-binding things with castability.
-                          'nsDOMQS.h'
                           ] + (['WorkerPrivate.h',
                                 'nsThreadUtils.h'] if hasWorkerStuff else [])
                             + (['mozilla/Preferences.h'] if requiresPreferences else [])
                             + (['mozilla/dom/NonRefcountedDOMObject.h'] if hasOwnedDescriptors else [])
                             + (['nsContentUtils.h'] if requiresContentUtils else [])
                             + (['nsCxPusher.h'] if dictionaries else [])
                             + (['AccessCheck.h'] if hasChromeOnly else [])
                             + (['xpcprivate.h'] if isEventTarget else [])
+                            + (['nsPIDOMWindow.h'] if len(jsImplemented) != 0 else [])
+                            + (['nsDOMQS.h'] if needsDOMQS["value"] else [])
                             + (['AtomList.h'] if requiresAtoms else []),
                          prefix,
                          curr,
                          config,
                          jsImplemented)
 
         # Add include guards.
         curr = CGIncludeGuard(prefix, curr)
--- a/dom/camera/DOMCameraManager.h
+++ b/dom/camera/DOMCameraManager.h
@@ -15,18 +15,17 @@
 #include "nsThreadUtils.h"
 #include "nsHashKeys.h"
 #include "nsWrapperCache.h"
 #include "nsWeakReference.h"
 #include "nsClassHashtable.h"
 #include "nsIDOMCameraManager.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
-
-class nsPIDOMWindow;
+#include "nsPIDOMWindow.h"
 
 namespace mozilla {
   class ErrorResult;
 class nsDOMCameraControl;
 namespace dom {
 class CameraSelector;
 }
 }
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -9,19 +9,19 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
+#include "nsPIDOMWindow.h"
 
 struct JSContext;
-class nsPIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 
 class PromiseInit;
 class PromiseCallback;
 class AnyCallback;
 class PromiseResolver;
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -26,22 +26,22 @@
 #include "nsIDOMGeoPositionCallback.h"
 #include "nsIDOMGeoPositionErrorCallback.h"
 #include "mozilla/dom/GeolocationBinding.h"
 #include "mozilla/dom/PositionErrorBinding.h"
 #include "mozilla/dom/CallbackObject.h"
 
 #include "nsIGeolocationProvider.h"
 #include "nsIContentPermissionPrompt.h"
+#include "nsIDOMWindow.h"
 #include "DictionaryHelpers.h"
 #include "PCOMContentPermissionRequestChild.h"
 #include "mozilla/Attributes.h"
 
 class nsGeolocationService;
-class nsIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 class Geolocation;
 typedef CallbackObjectHolder<PositionCallback, nsIDOMGeoPositionCallback> GeoPositionCallback;
 typedef CallbackObjectHolder<PositionErrorCallback, nsIDOMGeoPositionErrorCallback> GeoPositionErrorCallback;
 }
 }
--- a/layout/style/nsICSSDeclaration.h
+++ b/layout/style/nsICSSDeclaration.h
@@ -25,24 +25,23 @@
 #include "CSSValue.h"
 #include "nsWrapperCache.h"
 #include "nsString.h"
 #include "nsIDOMCSSRule.h"
 #include "nsIDOMCSSValue.h"
 #include "mozilla/ErrorResult.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
+#include "nsINode.h"
 
 // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f
 #define NS_ICSSDECLARATION_IID \
 { 0xdbeabbfa, 0x6cb3, 0x4f5c, \
  { 0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f } }
 
-class nsINode;
-
 class nsICSSDeclaration : public nsIDOMCSSStyleDeclaration,
                           public nsWrapperCache
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSDECLARATION_IID)
 
   /**
    * Method analogous to nsIDOMCSSStyleDeclaration::GetPropertyValue,