From 831b3fcdcf9cae2a6c96cd4bce81c2132c0271b8 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 23 Aug 2013 22:42:42 -0400 Subject: [PATCH] Bug 908576 part 7. Move the various DOMProxyHandler classes into the binding implementation files. r=smaug --- content/canvas/src/CanvasUtils.h | 1 + content/html/content/src/HTMLFormElement.h | 1 + content/html/content/src/nsDOMStringMap.h | 1 + content/xbl/src/nsXBLSerialize.cpp | 1 + dom/bindings/Codegen.py | 38 ++++++++++++++++++++-- dom/ipc/Blob.cpp | 1 + dom/workers/DOMBindingInlines.h | 1 + layout/style/nsNthIndexCache.cpp | 2 +- layout/style/nsNthIndexCache.h | 10 +++++- toolkit/components/places/History.cpp | 1 + 10 files changed, 52 insertions(+), 5 deletions(-) diff --git a/content/canvas/src/CanvasUtils.h b/content/canvas/src/CanvasUtils.h index 11364277ee6e..68487aeae9e7 100644 --- a/content/canvas/src/CanvasUtils.h +++ b/content/canvas/src/CanvasUtils.h @@ -7,6 +7,7 @@ #define _CANVASUTILS_H_ #include "mozilla/CheckedInt.h" +#include "jsapi.h" class nsIPrincipal; diff --git a/content/html/content/src/HTMLFormElement.h b/content/html/content/src/HTMLFormElement.h index e5512b7bfbe4..eae6fe95f76d 100644 --- a/content/html/content/src/HTMLFormElement.h +++ b/content/html/content/src/HTMLFormElement.h @@ -21,6 +21,7 @@ #include "nsRefPtrHashtable.h" #include "nsDataHashtable.h" #include "nsAsyncDOMEvent.h" +#include "jsfriendapi.h" // For js::ExpandoAndGeneration class nsIMutableArray; class nsIURI; diff --git a/content/html/content/src/nsDOMStringMap.h b/content/html/content/src/nsDOMStringMap.h index 0ce50430d60a..7542656f9c15 100644 --- a/content/html/content/src/nsDOMStringMap.h +++ b/content/html/content/src/nsDOMStringMap.h @@ -13,6 +13,7 @@ #include "nsString.h" #include "nsWrapperCache.h" #include "nsGenericHTMLElement.h" +#include "jsfriendapi.h" // For js::ExpandoAndGeneration namespace mozilla { class ErrorResult; diff --git a/content/xbl/src/nsXBLSerialize.cpp b/content/xbl/src/nsXBLSerialize.cpp index 3736d30b212f..dab2bb313e13 100644 --- a/content/xbl/src/nsXBLSerialize.cpp +++ b/content/xbl/src/nsXBLSerialize.cpp @@ -9,6 +9,7 @@ #include "nsContentUtils.h" #include "nsCxPusher.h" #include "jsdbgapi.h" +#include "jsfriendapi.h" using namespace mozilla; diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 7016e1b727b1..a5bf94eacb6a 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -7706,6 +7706,33 @@ class CGDOMJSProxyHandler(CGClass): constructors=constructors, methods=methods) +class CGDOMJSProxyHandlerDeclarer(CGThing): + """ + A class for declaring a DOMProxyHandler. + """ + def __init__(self, handlerThing): + self.handlerThing = handlerThing + + def declare(self): + # Our class declaration should happen when we're defining + return "" + + def define(self): + return self.handlerThing.declare() + +class CGDOMJSProxyHandlerDefiner(CGThing): + """ + A class for defining a DOMProxyHandler. + """ + def __init__(self, handlerThing): + self.handlerThing = handlerThing + + def declare(self): + return "" + + def define(self): + return self.handlerThing.define() + def stripTrailingWhitespace(text): tail = '\n' if text.endswith('\n') else '' lines = text.splitlines() @@ -7873,10 +7900,12 @@ class CGDescriptor(CGThing): if not descriptor.wrapperCache: raise TypeError("We need a wrappercache to support expandos for proxy-based " "bindings (" + descriptor.name + ")") + handlerThing = CGDOMJSProxyHandler(descriptor) + cgThings.append(CGDOMJSProxyHandlerDeclarer(handlerThing)) cgThings.append(CGProxyIsProxy(descriptor)) cgThings.append(CGProxyUnwrap(descriptor)) cgThings.append(CGDOMJSProxyHandlerDOMClass(descriptor)) - cgThings.append(CGDOMJSProxyHandler(descriptor)) + cgThings.append(CGDOMJSProxyHandlerDefiner(handlerThing)) else: cgThings.append(CGDOMJSClass(descriptor)) cgThings.append(CGGetJSClassMethod(descriptor)) @@ -8161,7 +8190,6 @@ if (""", initializerCtor = ClassConstructor([], - bodyInHeader=True, visibility="public", body=( "// Safe to pass a null context if we pass a null value\n" @@ -8593,6 +8621,7 @@ class CGBindingRoot(CGThing): requiresPreferences = any(descriptorRequiresPreferences(d) for d in descriptors) hasOwnedDescriptors = any(d.nativeOwnership == 'owned' for d in descriptors) requiresContentUtils = any(d.interface.hasInterfaceObject() for d in descriptors) + hasProxies = any(d.concrete and d.proxy for d in descriptors) def descriptorHasChromeOnly(desc): return (any(isChromeOnly(a) for a in desc.interface.members) or desc.interface.getExtendedAttribute("ChromeOnly") is not None or @@ -8696,7 +8725,9 @@ class CGBindingRoot(CGThing): callbackDescriptors, ['mozilla/dom/BindingDeclarations.h', 'mozilla/ErrorResult.h', - 'mozilla/dom/DOMJSProxyHandler.h'], + 'jspubtd.h', + 'js/RootingAPI.h', + ], ['mozilla/dom/BindingUtils.h', 'mozilla/dom/Nullable.h', 'PrimitiveConversions.h', @@ -8709,6 +8740,7 @@ class CGBindingRoot(CGThing): + (['nsContentUtils.h'] if requiresContentUtils else []) + (['nsCxPusher.h'] if dictionaries else []) + (['AccessCheck.h'] if hasChromeOnly else []) + + (['mozilla/dom/DOMJSProxyHandler.h'] if hasProxies else []) + (['xpcprivate.h'] if isEventTarget else []) + (['nsPIDOMWindow.h'] if len(jsImplemented) != 0 else []) + (['nsDOMQS.h'] if needsDOMQS["value"] else []) diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index e40118927a50..e9505554e575 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -24,6 +24,7 @@ #include "nsDOMFile.h" #include "nsProxyRelease.h" #include "nsThreadUtils.h" +#include "jsapi.h" #include "ContentChild.h" #include "ContentParent.h" diff --git a/dom/workers/DOMBindingInlines.h b/dom/workers/DOMBindingInlines.h index a930ba54fe1b..e242086c3475 100644 --- a/dom/workers/DOMBindingInlines.h +++ b/dom/workers/DOMBindingInlines.h @@ -12,6 +12,7 @@ #include "mozilla/dom/XMLHttpRequestUploadBinding.h" #include "mozilla/dom/WorkerLocationBinding.h" #include "mozilla/dom/WorkerNavigatorBinding.h" +#include "jsfriendapi.h" BEGIN_WORKERS_NAMESPACE diff --git a/layout/style/nsNthIndexCache.cpp b/layout/style/nsNthIndexCache.cpp index c9a81f6d7060..63e2c8d9985d 100644 --- a/layout/style/nsNthIndexCache.cpp +++ b/layout/style/nsNthIndexCache.cpp @@ -9,7 +9,7 @@ */ #include "nsNthIndexCache.h" -#include "nsIContent.h" +#include "mozilla/dom/Element.h" nsNthIndexCache::nsNthIndexCache() { diff --git a/layout/style/nsNthIndexCache.h b/layout/style/nsNthIndexCache.h index 3c11d58b492b..06ef28a94d5b 100644 --- a/layout/style/nsNthIndexCache.h +++ b/layout/style/nsNthIndexCache.h @@ -5,7 +5,15 @@ #ifndef nsContentIndexCache_h__ #define nsContentIndexCache_h__ -#include "mozilla/dom/Element.h" +#include "js/HashTable.h" + +class nsIContent; + +namespace mozilla { +namespace dom { +class Element; +} // namespace dom +} // namespace mozilla /* * A class that computes and caches the indices used for :nth-* pseudo-class diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 1eb48751f916..bd14d4b8aa4c 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -35,6 +35,7 @@ #include "mozilla/ipc/URIUtils.h" #include "nsPrintfCString.h" #include "nsTHashtable.h" +#include "jsapi.h" // Initial size for the cache holding visited status observers. #define VISIT_OBSERVERS_INITIAL_CACHE_SIZE 128