Bug 742217. Reduce the use of nested namespaces in our binding code. r=peterv,bent
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 03 May 2012 00:35:38 -0400
changeset 97422 3c35768445119d3eb1a86293e73158576c94dafc
parent 97421 82531cc259b3e90eebc526d553ddd8a97ba13de0
child 97423 5368d38c9f8fce8fe7d06e3579e2ddc7627dbd3a
push id173
push userlsblakk@mozilla.com
push dateFri, 24 Aug 2012 15:39:16 +0000
treeherdermozilla-release@bcc45eb1fb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, bent
bugs742217
milestone15.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 742217. Reduce the use of nested namespaces in our binding code. r=peterv,bent In the new setup, all per-interface DOM binding files are exported into mozilla/dom. General files not specific to an interface are also exported into mozilla/dom. In terms of namespaces, most things now live in mozilla::dom. Each interface Foo that has generated code has a mozilla::dom::FooBinding namespace for said generated code (and possibly a mozilla::bindings::FooBinding_workers if there's separate codegen for workers). IDL enums are a bit weird: since the name of the enum and the names of its entries all end up in the same namespace, we still generate a C++ namespace with the name of the IDL enum type with "Values" appended to it, with a ::valuelist inside for the actual C++ enum. We then typedef EnumFooValues::valuelist to EnumFoo. That makes it a bit more difficult to refer to the values, but means that values from different enums don't collide with each other. The enums with the proto and constructor IDs in them now live under the mozilla::dom::prototypes and mozilla::dom::constructors namespaces respectively. Again, this lets us deal sanely with the whole "enum value names are flattened into the namespace the enum is in" deal. The main benefit of this setup (and the reason "Binding" got appended to the per-interface namespaces) is that this way "using mozilla::dom" should Just Work for consumers and still allow C++ code to sanely use the IDL interface names for concrete classes, which is fairly desirable.
caps/src/nsScriptSecurityManager.cpp
content/base/src/nsXMLHttpRequest.cpp
content/base/src/nsXMLHttpRequest.h
content/xbl/src/nsXBLDocumentInfo.cpp
content/xul/document/src/nsXULPrototypeDocument.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsJSEnvironment.cpp
dom/base/nsJSUtils.cpp
dom/bindings/BindingUtils.cpp
dom/bindings/BindingUtils.h
dom/bindings/Codegen.py
dom/bindings/DOMJSClass.h
dom/bindings/GlobalGen.py
dom/bindings/Makefile.in
dom/bindings/Nullable.h
dom/bindings/Utils.cpp
dom/bindings/Utils.h
dom/interfaces/events/nsIDOMEventTarget.idl
dom/workers/DOMBindingBase.cpp
dom/workers/DOMBindingInlines.h
dom/workers/EventTarget.h
dom/workers/RuntimeService.cpp
dom/workers/Worker.cpp
dom/workers/WorkerScope.cpp
dom/workers/XMLHttpRequest.cpp
dom/workers/XMLHttpRequest.h
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCJSID.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCThreadContext.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/dombindings.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcpublic.h
js/xpconnect/wrappers/WrapperFactory.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -89,17 +89,17 @@
 #include "nsAboutProtocolUtils.h"
 #include "nsIClassInfo.h"
 #include "nsIURIFixup.h"
 #include "nsCDefaultURIFixup.h"
 #include "nsIChromeRegistry.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "mozilla/Preferences.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 #include "mozilla/StandardInteger.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
 nsIIOService    *nsScriptSecurityManager::sIOService = nsnull;
@@ -2478,18 +2478,18 @@ nsScriptSecurityManager::doGetObjectPrin
                 break;
             }
         } else {
             nsISupports *priv;
             if (!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
                                      JSCLASS_PRIVATE_IS_NSISUPPORTS))) {
                 priv = (nsISupports *) js::GetObjectPrivate(aObj);
             } else if ((jsClass->flags & JSCLASS_IS_DOMJSCLASS) &&
-                       bindings::DOMJSClass::FromJSClass(jsClass)->mDOMObjectIsISupports) {
-                priv = bindings::UnwrapDOMObject<nsISupports>(aObj, jsClass);
+                       DOMJSClass::FromJSClass(jsClass)->mDOMObjectIsISupports) {
+                priv = UnwrapDOMObject<nsISupports>(aObj, jsClass);
             } else {
                 priv = nsnull;
             }
 
 #ifdef DEBUG
             if (aAllowShortCircuit) {
                 nsCOMPtr<nsIXPConnectWrappedNative> xpcWrapper =
                     do_QueryInterface(priv);
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -100,17 +100,17 @@
 #include "nsIContentSecurityPolicy.h"
 #include "nsAsyncRedirectVerifyHelper.h"
 #include "nsStringBuffer.h"
 #include "nsDOMFile.h"
 #include "nsIFileChannel.h"
 #include "mozilla/Telemetry.h"
 #include "jsfriendapi.h"
 #include "sampler.h"
-#include "mozilla/dom/bindings/XMLHttpRequestBinding.h"
+#include "mozilla/dom/XMLHttpRequestBinding.h"
 #include "nsIDOMFormData.h"
 
 #include "nsWrapperCacheInlines.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 #define LOAD_STR "load"
@@ -1086,18 +1086,18 @@ NS_IMETHODIMP nsXMLHttpRequest::GetRespo
 }
 
 #ifdef DEBUG
 void
 nsXMLHttpRequest::StaticAssertions()
 {
 #define ASSERT_ENUM_EQUAL(_lc, _uc) \
   MOZ_STATIC_ASSERT(\
-    bindings::prototypes::XMLHttpRequestResponseType::_lc \
-      == bindings::prototypes::XMLHttpRequestResponseType::value(XML_HTTP_RESPONSE_TYPE_ ## _uc), \
+    XMLHttpRequestResponseTypeValues::_lc                \
+    == XMLHttpRequestResponseType(XML_HTTP_RESPONSE_TYPE_ ## _uc), \
     #_uc " should match")
 
   ASSERT_ENUM_EQUAL(_empty, DEFAULT);
   ASSERT_ENUM_EQUAL(arraybuffer, ARRAYBUFFER);
   ASSERT_ENUM_EQUAL(blob, BLOB);
   ASSERT_ENUM_EQUAL(document, DOCUMENT);
   ASSERT_ENUM_EQUAL(json, JSON);
   ASSERT_ENUM_EQUAL(text, TEXT);
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -64,18 +64,18 @@
 #include "nsIPrivateDOMEvent.h"
 #include "nsDOMProgressEvent.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsContentUtils.h"
 #include "nsDOMFile.h"
 #include "nsDOMBlobBuilder.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptObjectPrincipal.h"
-#include "mozilla/dom/bindings/XMLHttpRequestBinding.h"
-#include "mozilla/dom/bindings/XMLHttpRequestUploadBinding.h"
+#include "mozilla/dom/XMLHttpRequestBinding.h"
+#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
 
 #include "mozilla/Assertions.h"
 
 class nsILoadGroup;
 class AsyncVerifyRedirectCallbackForwarder;
 class nsIUnicodeDecoder;
 class nsIDOMFormData;
 
@@ -90,17 +90,17 @@ class nsIDOMFormData;
                               mOn##_capitalized##Listener,              \
                               aCallback);                               \
   }
 
 class nsXHREventTarget : public nsDOMEventTargetHelper,
                          public nsIXMLHttpRequestEventTarget
 {
 public:
-  typedef mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType::value
+  typedef mozilla::dom::XMLHttpRequestResponseType
           XMLHttpRequestResponseType;
 
   virtual ~nsXHREventTarget() {}
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXHREventTarget,
                                            nsDOMEventTargetHelper)
   NS_DECL_NSIXMLHTTPREQUESTEVENTTARGET
   NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
@@ -165,17 +165,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
   NS_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget::)
   NS_DECL_NSIXMLHTTPREQUESTUPLOAD
 
   virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
                                bool *triedToWrap)
   {
-    return mozilla::dom::bindings::prototypes::XMLHttpRequestUpload::Wrap(cx, scope, this, triedToWrap);
+    return mozilla::dom::XMLHttpRequestUploadBinding::Wrap(cx, scope, this, triedToWrap);
   }
   nsISupports* GetParentObject()
   {
     return GetOwner();
   }
 
   bool HasListeners()
   {
@@ -197,17 +197,17 @@ class nsXMLHttpRequest : public nsXHREve
   friend class nsXHRParseEndListener;
 public:
   nsXMLHttpRequest();
   virtual ~nsXMLHttpRequest();
 
   virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
                                bool *triedToWrap)
   {
-    return mozilla::dom::bindings::prototypes::XMLHttpRequest::Wrap(cx, scope, this, triedToWrap);
+    return mozilla::dom::XMLHttpRequestBinding::Wrap(cx, scope, this, triedToWrap);
   }
   nsISupports* GetParentObject()
   {
     return GetOwner();
   }
 
   // The WebIDL parser converts constructors into methods called _Constructor.
   static already_AddRefed<nsXMLHttpRequest>
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -54,22 +54,22 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsContentUtils.h"
 #include "nsDOMJSUtils.h"
 #include "mozilla/Services.h"
 #include "xpcpublic.h"
 #include "mozilla/scache/StartupCache.h"
 #include "mozilla/scache/StartupCacheUtils.h"
 #include "nsCCUncollectableMarker.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla::scache;
 using namespace mozilla;
 
-using mozilla::dom::bindings::DestroyProtoOrIfaceCache;
+using mozilla::dom::DestroyProtoOrIfaceCache;
 
 static const char kXBLCachePrefix[] = "xblcache";
 
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 // An XBLDocumentInfo object has a special context associated with it which we can use to pre-compile 
 // properties and methods of XBL bindings against.
 class nsXBLDocGlobalObject : public nsIScriptGlobalObject,
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -61,19 +61,19 @@
 #include "mozilla/FunctionTimer.h"
 #include "nsIDOMScriptObjectFactory.h"
 #include "nsDOMCID.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsDOMJSUtils.h" // for GetScriptContextFromJSContext
 #include "xpcpublic.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
-using mozilla::dom::bindings::DestroyProtoOrIfaceCache;
+using mozilla::dom::DestroyProtoOrIfaceCache;
 
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
                      NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 
 class nsXULPDGlobalObject : public nsIScriptGlobalObject,
                             public nsIScriptObjectPrincipal
 {
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -54,17 +54,17 @@
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
 #include "XrayWrapper.h"
 
 #include "xpcpublic.h"
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 
-#include "mozilla/dom/bindings/Common.h"
+#include "mozilla/dom/RegisterBindings.h"
 
 #include "nscore.h"
 #include "nsDOMClassInfo.h"
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsIComponentRegistrar.h"
@@ -4486,17 +4486,17 @@ nsDOMClassInfo::Init()
 
   sDisableGlobalScopePollutionSupport =
     Preferences::GetBool("browser.dom.global_scope_pollution.disabled");
 
   // Proxy bindings
   mozilla::dom::binding::Register(nameSpaceManager);
 
   // Non-proxy bindings
-  mozilla::dom::bindings::Register(nameSpaceManager);
+  mozilla::dom::Register(nameSpaceManager);
 
   sIsInitialized = true;
 
   return NS_OK;
 }
 
 // static
 PRInt32
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -105,17 +105,17 @@
 #define FORCE_PR_LOG 1
 #endif
 #include "prlog.h"
 #include "prthread.h"
 
 #include "mozilla/FunctionTimer.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 #include "sampler.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 const size_t gStackSize = 8192;
 
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -56,17 +56,17 @@
 #include "nsIXPConnect.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsPIDOMWindow.h"
 
 #include "nsDOMJSUtils.h" // for GetScriptContextFromJSContext
 
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 JSBool
 nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename,
                               PRUint32* aLineno)
 {
   JSScript* script = nsnull;
   unsigned lineno = 0;
 
rename from dom/bindings/Utils.cpp
rename to dom/bindings/BindingUtils.cpp
--- a/dom/bindings/Utils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -1,19 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
 /* vim: set ts=2 sw=2 et tw=79: */
 /* 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/. */
 
-#include "Utils.h"
+#include "BindingUtils.h"
 
 namespace mozilla {
 namespace dom {
-namespace bindings {
 
 static bool
 DefineConstants(JSContext* cx, JSObject* obj, ConstantSpec* cs)
 {
   for (; cs->name; ++cs) {
     JSBool ok =
       JS_DefineProperty(cx, obj, cs->name, cs->value, NULL, NULL,
                         JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
@@ -235,11 +234,10 @@ QueryInterface(JSContext* cx, unsigned a
     return WrapObject(cx, obj, ci, &NS_GET_IID(nsIClassInfo), vp);
   }
   
   // Lie, otherwise we need to check classinfo or QI
   *vp = thisv;
   return true;
 }
 
-} // namespace bindings
 } // namespace dom
 } // namespace mozilla
rename from dom/bindings/Utils.h
rename to dom/bindings/BindingUtils.h
--- a/dom/bindings/Utils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1,31 +1,34 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
 /* vim: set ts=2 sw=2 et tw=79: */
 /* 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/. */
 
-#ifndef mozilla_dom_bindings_Utils_h__
-#define mozilla_dom_bindings_Utils_h__
+#ifndef mozilla_dom_BindingUtils_h__
+#define mozilla_dom_BindingUtils_h__
 
-#include "mozilla/dom/bindings/DOMJSClass.h"
+#include "mozilla/dom/DOMJSClass.h"
 #include "mozilla/dom/workers/Workers.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
 #include "XPCQuickStubs.h"
 #include "XPCWrapper.h"
 #include "nsTraceRefcnt.h"
 #include "nsWrapperCacheInlines.h"
 
+// nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
+// try to use it without fixing that first.
+class nsGlobalWindow;
+
 namespace mozilla {
 namespace dom {
-namespace bindings {
 
 template<bool mainThread>
 inline bool
 Throw(JSContext* cx, nsresult rv)
 {
   using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
 
   // XXX Introduce exception machinery.
@@ -372,19 +375,16 @@ FindEnumStringIndex(JSContext* cx, JS::V
 }
 
 inline nsWrapperCache*
 GetWrapperCache(nsWrapperCache* cache)
 {
   return cache;
 }
 
-// nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
-// try to use it without fixing that first.
-class nsGlobalWindow;
 inline nsWrapperCache*
 GetWrapperCache(nsGlobalWindow* not_allowed);
 
 inline nsWrapperCache*
 GetWrapperCache(void* p)
 {
   return NULL;
 }
@@ -503,13 +503,12 @@ InitIds(JSContext* cx, Spec* specs, jsid
   } while (++ids, (++spec)->name);
 
   return true;
 }
 
 JSBool
 QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp);
 
-} // namespace bindings
 } // namespace dom
 } // namespace mozilla
 
-#endif /* mozilla_dom_bindings_Utils_h__ */
+#endif /* mozilla_dom_BindingUtils_h__ */
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -35,16 +35,19 @@ def replaceFileIfChanged(filename, newCo
 
     f = open(filename, 'wb')
     f.write(newContents)
     f.close()
 
 def toStringBool(arg):
     return str(not not arg).lower()
 
+def toBindingNamespace(arg):
+    return re.sub("((_workers)?$)", "Binding\\1", arg);
+
 class CGThing():
     """
     Abstract base class for things that spit out code.
     """
     def __init__(self):
         pass # Nothing for now
     def declare(self):
         """Produce code for a header file."""
@@ -59,39 +62,40 @@ class CGNativePropertyHooks(CGThing):
     """
     def __init__(self, descriptor):
         CGThing.__init__(self)
         self.descriptor = descriptor
     def declare(self):
         return "  extern const NativePropertyHooks NativeHooks;\n"
     def define(self):
         parent = self.descriptor.interface.parent
-        parentHooks = "&" + parent.identifier.name + "::NativeHooks" if parent else 'NULL'
+        parentHooks = ("&" + toBindingNamespace(parent.identifier.name) + "::NativeHooks"
+                       if parent else 'NULL')
         return """
 const NativePropertyHooks NativeHooks = { ResolveProperty, EnumerateProperties, %s };
 """ % parentHooks
 
 class CGDOMJSClass(CGThing):
     """
     Generate a DOMJSClass for a given descriptor
     """
     def __init__(self, descriptor):
         CGThing.__init__(self)
         self.descriptor = descriptor
     def declare(self):
         return "  extern DOMJSClass Class;\n"
     def define(self):
         traceHook = TRACE_HOOK_NAME if self.descriptor.customTrace else 'NULL'
-        protoList = ['id::' + proto for proto in self.descriptor.prototypeChain]
+        protoList = ['prototypes::id::' + proto for proto in self.descriptor.prototypeChain]
         # Pad out the list to the right length with _ID_Count so we
         # guarantee that all the lists are the same length.  _ID_Count
         # is never the ID of any prototype, so it's safe to use as
         # padding.
         while len(protoList) < self.descriptor.config.maxProtoChainLength:
-            protoList.append('id::_ID_Count')
+            protoList.append('prototypes::id::_ID_Count')
         prototypeChainString = ', '.join(protoList)
         return """
 DOMJSClass Class = {
   { "%s",
     JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
     %s, /* addProperty */
     JS_PropertyStub,       /* delProperty */
     JS_PropertyStub,       /* getProperty */
@@ -234,26 +238,29 @@ class CGIndenter(CGThing):
             return ""
 
 class CGWrapper(CGThing):
     """
     Generic CGThing that wraps other CGThings with pre and post text.
     """
     def __init__(self, child, pre="", post="", declarePre=None,
                  declarePost=None, definePre=None, definePost=None,
-                 declareOnly=False, reindent=False):
+                 declareOnly=False, defineOnly=False, reindent=False):
         CGThing.__init__(self)
         self.child = child
         self.declarePre = declarePre or pre
         self.declarePost = declarePost or post
         self.definePre = definePre or pre
         self.definePost = definePost or post
         self.declareOnly = declareOnly
+        self.defineOnly = defineOnly
         self.reindent = reindent
     def declare(self):
+        if self.defineOnly:
+            return ''
         decl = self.child.declare()
         if self.reindent:
             # We don't use lineStartDetector because we don't want to
             # insert whitespace at the beginning of our _first_ line.
             decl = stripTrailingWhitespace(
                 decl.replace("\n", "\n" + (" " * len(self.declarePre))))
         return self.declarePre + decl + self.declarePost
     def define(self):
@@ -285,17 +292,17 @@ class CGNamespace(CGWrapper):
                            declareOnly=declareOnly)
 
 class CGIncludeGuard(CGWrapper):
     """
     Generates include guards for a header.
     """
     def __init__(self, prefix, child):
         """|prefix| is the filename without the extension."""
-        define = 'mozilla_dom_bindings_%s_h__' % prefix
+        define = 'mozilla_dom_%s_h__' % prefix
         CGWrapper.__init__(self, child,
                            declarePre='#ifndef %s\n#define %s\n\n' % (define, define),
                            declarePost='\n#endif // %s\n' % define)
 
 class CGHeaders(CGWrapper):
     """
     Generates the appropriate include statements.
     """
@@ -353,17 +360,17 @@ class CGHeaders(CGWrapper):
                            declarePre=_includeString(declareIncludes),
                            definePre=_includeString(sorted(set(defineIncludes) |
                                                            bindingIncludes |
                                                            bindingHeaders |
                                                            implementationIncludes)))
     @staticmethod
     def getInterfaceFilename(interface):
         basename = os.path.basename(interface.filename())
-        return 'mozilla/dom/bindings/' + \
+        return 'mozilla/dom/' + \
                basename.replace('.webidl', 'Binding.h')
 
 class Argument():
     """
     A class for outputting the type and name of an argument
     """
     def __init__(self, argType, name):
         self.argType = argType
@@ -806,17 +813,18 @@ class CGCreateInterfaceObjectsMethod(CGA
         CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', 'JSObject*', args)
         self.properties = properties
     def definition_body(self):
         protoChain = self.descriptor.prototypeChain
         if len(protoChain) == 1:
             getParentProto = "JS_GetObjectPrototype(aCx, aGlobal)"
         else:
             parentProtoName = self.descriptor.prototypeChain[-2]
-            getParentProto = "%s::GetProtoObject(aCx, aGlobal, aReceiver)" % (parentProtoName)
+            getParentProto = ("%s::GetProtoObject(aCx, aGlobal, aReceiver)" %
+                              toBindingNamespace(parentProtoName))
 
         needInterfaceObject = self.descriptor.interface.hasInterfaceObject()
         needInterfacePrototypeObject = self.descriptor.interface.hasInterfacePrototypeObject()
 
         # if we don't need to create anything, why are we generating this?
         assert needInterfaceObject or needInterfacePrototypeObject
 
         idsToInit = []
@@ -845,20 +853,20 @@ class CGCreateInterfaceObjectsMethod(CGA
         else:
             initIds = None
             
         getParentProto = ("JSObject* parentProto = %s;\n"
                           "if (!parentProto) {\n"
                           "  return NULL;\n"
                           "}") % getParentProto
 
-        call = CGGeneric(("return bindings::CreateInterfaceObjects(aCx, aGlobal, aReceiver, parentProto,\n"
-                          "                                        %s, %s,\n"
-                          "                                        %%(methods)s, %%(attrs)s, %%(consts)s, %%(staticMethods)s,\n"
-                          "                                        %s);") % (
+        call = CGGeneric(("return dom::CreateInterfaceObjects(aCx, aGlobal, aReceiver, parentProto,\n"
+                          "                                   %s, %s,\n"
+                          "                                   %%(methods)s, %%(attrs)s, %%(consts)s, %%(staticMethods)s,\n"
+                          "                                   %s);") % (
             "&PrototypeClass" if needInterfacePrototypeObject else "NULL",
             "&InterfaceObjectClass" if needInterfaceObject else "NULL",
             '"' + self.descriptor.interface.identifier.name + '"' if needInterfaceObject else "NULL"))
 
         if self.properties.hasChromeOnly():
             if self.descriptor.workers:
                 accessCheck = "mozilla::dom::workers::GetWorkerPrivateFromContext(aCx)->IsChromeWorker()"
             else:
@@ -909,28 +917,30 @@ class CGGetPerInterfaceObject(CGAbstract
   /* cachedObject might _still_ be null, but that's OK */
   return cachedObject;""" % (self.id, self.id)
 
 class CGGetProtoObjectMethod(CGGetPerInterfaceObject):
     """
     A method for getting the interface prototype object.
     """
     def __init__(self, descriptor):
-        CGGetPerInterfaceObject.__init__(self, descriptor, "GetProtoObject")
+        CGGetPerInterfaceObject.__init__(self, descriptor, "GetProtoObject",
+                                         "prototypes::")
     def definition_body(self):
         return """
   /* Get the interface prototype object for this class.  This will create the
      object as needed. */""" + CGGetPerInterfaceObject.definition_body(self)
 
 class CGGetConstructorObjectMethod(CGGetPerInterfaceObject):
     """
     A method for getting the interface constructor object.
     """
     def __init__(self, descriptor):
-        CGGetPerInterfaceObject.__init__(self, descriptor, "GetConstructorObject", "constructors::")
+        CGGetPerInterfaceObject.__init__(self, descriptor, "GetConstructorObject",
+                                         "constructors::")
     def definition_body(self):
         return """
   /* Get the interface object for this class.  This will create the object as
      needed. */""" + CGGetPerInterfaceObject.definition_body(self)
 
 def CheckPref(descriptor, globalName, varName, retval, wrapperCache = None):
     """
     Check whether bindings should be enabled for this descriptor.  If not, set
@@ -1022,17 +1032,17 @@ class CGWrapMethod(CGAbstractMethod):
         if self.descriptor.workers:
             return """
   *aTriedToWrap = true;
   return aObject->GetJSObject();"""
 
         return """
   *aTriedToWrap = true;
 
-  JSObject* parent = bindings::WrapNativeParent(aCx, aScope, aObject->GetParentObject());
+  JSObject* parent = WrapNativeParent(aCx, aScope, aObject->GetParentObject());
   if (!parent) {
     return NULL;
   }
 
   JSAutoEnterCompartment ac;
   if (js::GetGlobalForObjectCrossCompartment(parent) != aScope) {
     if (!ac.enter(aCx, parent)) {
       return NULL;
@@ -1078,17 +1088,17 @@ class CastableObjectUnwrapper():
     based on the passed-in descriptor and storing it in a variable
     called by the name in the "target" argument.
 
     codeOnFailure is the code to run if unwrapping fails.
     """
     def __init__(self, descriptor, source, target, codeOnFailure):
         assert descriptor.castable
         self.substitution = { "type" : descriptor.nativeType,
-                              "protoID" : "id::" + descriptor.name,
+                              "protoID" : "prototypes::id::" + descriptor.name,
                               "source" : source,
                               "target" : target,
                               "codeOnFailure" : codeOnFailure }
 
     def __str__(self):
         return string.Template(
 """  {
     nsresult rv = UnwrapObject<${protoID}>(cx, ${source}, &${target});
@@ -1275,18 +1285,18 @@ def getArgumentConversionTemplate(type, 
         return (
             "  %(enumtype)s ${name};\n"
             "  {\n"
             "    bool ok;\n"
             "    ${name} = static_cast<%(enumtype)s>(FindEnumStringIndex(cx, ${argVal}, %(values)s, &ok));\n"
             "    if (!ok) {\n"
             "      return false;\n"
             "    }\n"
-            "  }" % { "enumtype" : enum + "::value",
-                      "values" : enum + "::strings" })
+            "  }" % { "enumtype" : enum,
+                      "values" : enum + "Values::strings" })
 
     if type.isCallback():
         # XXXbz we're going to assume that callback types are always
         # nullable and always have [TreatNonCallableAsNull] for now.
         return (
             "  JSObject* ${name};\n"
             "  if (${argVal}.isObject() && JS_ObjectIsCallable(cx, &${argVal}.toObject())) {\n"
             "    ${name} = &${argVal}.toObject();\n"
@@ -1518,17 +1528,17 @@ def getWrapTemplateForTypeImpl(type, res
         return """
   MOZ_ASSERT(uint32_t(%(result)s) < ArrayLength(%(strings)s));
   JSString* result_str = JS_NewStringCopyN(cx, %(strings)s[uint32_t(%(result)s)].value, %(strings)s[uint32_t(%(result)s)].length);
   if (!result_str) {
     return false;
   }
   ${jsvalRef} = JS::StringValue(result_str);
   return true;""" % { "result" : result,
-                      "strings" : type.inner.identifier.name + "::strings" }
+                      "strings" : type.inner.identifier.name + "Values::strings" }
 
     if type.isCallback() and not type.isInterface():
         # XXXbz we're going to assume that callback types are always
         # nullable and always have [TreatNonCallableAsNull] for now.
         # See comments in WrapNewBindingObject explaining why we need
         # to wrap here.
         return """
   ${jsvalRef} = JS::ObjectOrNullValue(%s);
@@ -1612,17 +1622,17 @@ class CGCallGenerator(CGThing):
             result = CGGeneric(builtinNames[returnType.tag()])
             if returnType.nullable():
                 result = CGWrapper(result, pre="Nullable<", post=">")
         elif returnType.isString():
             result = CGGeneric("nsString")
         elif returnType.isEnum():
             if returnType.nullable():
                 raise TypeError("We don't support nullable enum return values")
-            result = CGGeneric(returnType.inner.identifier.name + "::value")
+            result = CGGeneric(returnType.inner.identifier.name)
         elif returnType.isInterface() and not returnType.isArrayBuffer():
             result = CGGeneric(descriptorProvider.getDescriptor(
                 returnType.unroll().inner.identifier.name).nativeType)
             if resultAlreadyAddRefed:
                 result = CGWrapper(result, pre="nsRefPtr<", post=">")
             else:
                 result = CGWrapper(result, post="*")
         elif returnType.isCallback():
@@ -2289,17 +2299,17 @@ def getEnumValueName(value):
 
 class CGEnum(CGThing):
     def __init__(self, enum):
         CGThing.__init__(self)
         self.enum = enum
 
     def declare(self):
         return """
-  enum value {
+  enum valuelist {
     %s
   };
 
   extern const EnumEntry strings[%d];
 """ % (",\n    ".join(map(getEnumValueName, self.enum.values())),
        len(self.enum.values()) + 1)
 
     def define(self):
@@ -2779,17 +2789,18 @@ class CGDescriptor(CGThing):
         if descriptor.interface.hasInterfaceObject():
             cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
 
         if descriptor.concrete:
             cgThings.append(CGWrapMethod(descriptor))
 
         cgThings = CGList(cgThings)
         cgThings = CGWrapper(cgThings, post='\n')
-        self.cgRoot = CGWrapper(CGNamespace(descriptor.name, cgThings),
+        self.cgRoot = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name),
+                                            cgThings),
                                 post='\n')
 
     def declare(self):
         return self.cgRoot.declare()
     def define(self):
         return self.cgRoot.define()
 
 class CGNamespacedEnum(CGThing):
@@ -2839,17 +2850,17 @@ class CGRegisterProtos(CGAbstractMethod)
     def __init__(self, config):
         CGAbstractMethod.__init__(self, None, 'Register', 'void',
                                   [Argument('nsScriptNameSpaceManager*', 'aNameSpaceManager')])
         self.config = config
 
     def _defineMacro(self):
        return """
 #define REGISTER_PROTO(_dom_class) \\
-  aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), prototypes::_dom_class::DefineDOMInterface);\n\n"""
+  aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Binding::DefineDOMInterface);\n\n"""
     def _undefineMacro(self):
         return "\n#undef REGISTER_PROTO"
     def _registerProtos(self):
         lines = ["REGISTER_PROTO(%s);" % desc.name
                  for desc in self.config.getDescriptors(hasInterfaceObject=True,
                                                         isExternal=False,
                                                         workers=False)]
         return '\n'.join(lines) + '\n'
@@ -2886,42 +2897,51 @@ class CGBindingRoot(CGThing):
 
         # We must have a 1:1 mapping here, skip for prototypes that have more
         # than one concrete class implementation.
         traitsClasses.extend([CGPrototypeIDMapClass(d) for d in descriptorsWithPrototype
                               if d.uniqueImplementation])
 
         # Wrap all of that in our namespaces.
         if len(traitsClasses) > 0:
-            traitsClasses = CGNamespace.build(['mozilla', 'dom', 'bindings'],
+            traitsClasses = CGNamespace.build(['mozilla', 'dom'],
                                      CGWrapper(CGList(traitsClasses),
                                                declarePre='\n'),
                                                declareOnly=True)
             traitsClasses = CGWrapper(traitsClasses, declarePost='\n')
         else:
-            traitsClasses = CGGeneric()
+            traitsClasses = None
 
         # Do codegen for all the descriptors and enums.
-        cgthings = [CGWrapper(CGNamespace.build([e.identifier.name],
-                                                CGEnum(e)),
-                              post="\n") for e in config.getEnums(webIDLFile)]
+        def makeEnum(e):
+            return CGNamespace.build([e.identifier.name + "Values"],
+                                     CGEnum(e))
+        def makeEnumTypedef(e):
+            return CGGeneric(declare=("typedef %sValues::valuelist %s;\n" %
+                                      (e.identifier.name, e.identifier.name)))
+        cgthings = [ fun(e) for e in config.getEnums(webIDLFile)
+                     for fun in [makeEnum, makeEnumTypedef] ]
         cgthings.extend([CGDescriptor(x) for x in descriptors])
-        curr = CGList(cgthings)
+        curr = CGList(cgthings, "\n")
 
         # Wrap all of that in our namespaces.
-        curr = CGNamespace.build(['mozilla', 'dom', 'bindings', 'prototypes'],
+        curr = CGNamespace.build(['mozilla', 'dom'],
                                  CGWrapper(curr, pre="\n"))
 
-        curr = CGList([forwardDeclares, traitsClasses, curr])
+        curr = CGList([forwardDeclares,
+                       CGWrapper(CGGeneric("using namespace mozilla::dom;"),
+                                 defineOnly=True),
+                       traitsClasses, curr],
+                      "\n")
 
         # Add header includes.
         curr = CGHeaders(descriptors,
-                         ['mozilla/dom/bindings/Utils.h',
-                          'DOMJSClass.h'],
-                         ['mozilla/dom/bindings/Nullable.h',
+                         ['mozilla/dom/BindingUtils.h',
+                          'mozilla/dom/DOMJSClass.h'],
+                         ['mozilla/dom/Nullable.h',
                           'XPCQuickStubs.h',
                           'AccessCheck.h',
                           'WorkerPrivate.h',
                           'nsContentUtils.h'],
                          curr)
 
         # Add include guards.
         curr = CGIncludeGuard(prefix, curr)
@@ -2952,71 +2972,71 @@ class GlobalGenRoots():
         # Prototype ID enum.
         protos = [d.name for d in config.getDescriptors(hasInterfacePrototypeObject=True)]
         idEnum = CGNamespacedEnum('id', 'ID', protos, [0])
         idEnum = CGList([idEnum])
         idEnum.append(CGGeneric(declare="const unsigned MaxProtoChainLength = " +
                                 str(config.maxProtoChainLength) + ";\n\n"))
 
         # Wrap all of that in our namespaces.
-        idEnum = CGNamespace.build(['mozilla', 'dom', 'bindings', 'prototypes'],
+        idEnum = CGNamespace.build(['mozilla', 'dom', 'prototypes'],
                                    CGWrapper(idEnum, pre='\n'))
         idEnum = CGWrapper(idEnum, post='\n')
 
         curr = CGList([idEnum])
 
         # Constructor ID enum.
         constructors = [d.name for d in config.getDescriptors(hasInterfaceObject=True,
                                                               hasInterfacePrototypeObject=False)]
         idEnum = CGNamespacedEnum('id', 'ID', constructors, [0])
 
         # Wrap all of that in our namespaces.
-        idEnum = CGNamespace.build(['mozilla', 'dom', 'bindings', 'constructors'],
+        idEnum = CGNamespace.build(['mozilla', 'dom', 'constructors'],
                                    CGWrapper(idEnum, pre='\n'))
         idEnum = CGWrapper(idEnum, post='\n')
 
         curr.append(idEnum)
 
         traitsDecl = CGGeneric(declare="""
 template <prototypes::ID PrototypeID>
 struct PrototypeTraits;
 
 template <class ConcreteClass>
 struct PrototypeIDMap;
 """)
 
-        traitsDecl = CGNamespace.build(['mozilla', 'dom', 'bindings'],
+        traitsDecl = CGNamespace.build(['mozilla', 'dom'],
                                         CGWrapper(traitsDecl, post='\n'))
 
         curr.append(traitsDecl)
 
         # Add include guards.
         curr = CGIncludeGuard('PrototypeList', curr)
 
         # Add the auto-generated comment.
         curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
 
         # Done.
         return curr
 
     @staticmethod
-    def Common(config):
+    def RegisterBindings(config):
 
         # TODO - Generate the methods we want
         curr = CGRegisterProtos(config)
 
         # Wrap all of that in our namespaces.
-        curr = CGNamespace.build(['mozilla', 'dom', 'bindings'],
+        curr = CGNamespace.build(['mozilla', 'dom'],
                                  CGWrapper(curr, post='\n'))
         curr = CGWrapper(curr, post='\n')
 
         # Add the includes
         defineIncludes = [CGHeaders.getInterfaceFilename(desc.interface)
                           for desc in config.getDescriptors(hasInterfaceObject=True,
                                                             workers=False)]
         defineIncludes.append('nsScriptNameSpaceManager.h')
         curr = CGHeaders([], [], defineIncludes, curr)
 
         # Add include guards.
-        curr = CGIncludeGuard('Common', curr)
+        curr = CGIncludeGuard('RegisterBindings', curr)
 
         # Done.
         return curr
--- a/dom/bindings/DOMJSClass.h
+++ b/dom/bindings/DOMJSClass.h
@@ -1,37 +1,36 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
 /* 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/. */
 
-#ifndef mozilla_dom_bindings_DOMJSClass_h
-#define mozilla_dom_bindings_DOMJSClass_h
+#ifndef mozilla_dom_DOMJSClass_h
+#define mozilla_dom_DOMJSClass_h
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
-#include "mozilla/dom/bindings/PrototypeList.h" // auto-generated
+#include "mozilla/dom/PrototypeList.h" // auto-generated
 
 // For non-global objects we use slot 0 for holding the raw object.
 #define DOM_OBJECT_SLOT 0
 
 // All DOM globals must have two slots at DOM_GLOBAL_OBJECT_SLOT and
 // DOM_PROTOTYPE_SLOT. We have to start at 1 past JSCLASS_GLOBAL_SLOT_COUNT
 // because XPConnect uses that one.
 #define DOM_GLOBAL_OBJECT_SLOT (JSCLASS_GLOBAL_SLOT_COUNT + 1)
 #define DOM_PROTOTYPE_SLOT (JSCLASS_GLOBAL_SLOT_COUNT + 2)
 
 // We use these flag bits for the new bindings.
 #define JSCLASS_IS_DOMJSCLASS JSCLASS_USERBIT1
 #define JSCLASS_DOM_GLOBAL JSCLASS_USERBIT2
 
 namespace mozilla {
 namespace dom {
-namespace bindings {
 
 typedef bool
 (* ResolveProperty)(JSContext* cx, JSObject* wrapper, jsid id, bool set,
                     JSPropertyDescriptor* desc);
 typedef bool
 (* EnumerateProperties)(JS::AutoIdVector& props);
 
 struct NativePropertyHooks
@@ -92,13 +91,12 @@ struct DOMJSClass
 inline JSObject**
 GetProtoOrIfaceArray(JSObject* global)
 {
   MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
   return static_cast<JSObject**>(
     js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).toPrivate());
 }
 
-} // namespace bindings
 } // namespace dom
 } // namespace mozilla
 
-#endif /* mozilla_dom_bindings_DOMJSClass_h */
+#endif /* mozilla_dom_DOMJSClass_h */
--- a/dom/bindings/GlobalGen.py
+++ b/dom/bindings/GlobalGen.py
@@ -69,13 +69,13 @@ def main():
 
     # Load the configuration.
     config = Configuration(configFile, parserResults)
 
     # Generate the prototype list.
     generate_file(config, 'PrototypeList', 'declare')
 
     # Generate the common code.
-    generate_file(config, 'Common', 'declare')
-    generate_file(config, 'Common', 'define')
+    generate_file(config, 'RegisterBindings', 'declare')
+    generate_file(config, 'RegisterBindings', 'define')
 
 if __name__ == '__main__':
     main()
--- a/dom/bindings/Makefile.in
+++ b/dom/bindings/Makefile.in
@@ -24,40 +24,40 @@ else
 ACCESSOR_OPT =
 endif
 
 # Need this to find all our DOM source files.
 include $(topsrcdir)/dom/dom-config.mk
 
 include $(topsrcdir)/dom/webidl/WebIDL.mk
 
-binding_include_path := mozilla/dom/bindings
+binding_include_path := mozilla/dom
 binding_header_files := $(subst .webidl,Binding.h,$(webidl_files))
 binding_cpp_files := $(subst .webidl,Binding.cpp,$(webidl_files))
 
 globalgen_targets := \
   PrototypeList.h \
-  Common.h \
-  Common.cpp \
+  RegisterBindings.h \
+  RegisterBindings.cpp \
   $(NULL)
 
 CPPSRCS = \
   $(binding_cpp_files) \
   $(filter %.cpp, $(globalgen_targets)) \
-  Utils.cpp \
+  BindingUtils.cpp \
   $(NULL)
 
 EXPORTS_NAMESPACES = $(binding_include_path)
 
 EXPORTS_$(binding_include_path) = \
   DOMJSClass.h \
   PrototypeList.h \
-  Common.h \
+  RegisterBindings.h \
   Nullable.h \
-  Utils.h \
+  BindingUtils.h \
   $(binding_header_files) \
   $(NULL)
 
 LOCAL_INCLUDES += -I$(topsrcdir)/js/xpconnect/src \
   -I$(topsrcdir)/js/xpconnect/wrappers
 
 TEST_DIRS += test
 
--- a/dom/bindings/Nullable.h
+++ b/dom/bindings/Nullable.h
@@ -1,22 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
 /* vim: set ts=2 sw=2 et tw=79: */
 /* 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/. */
 
-#ifndef mozilla_dom_bindings_Nullable_h
-#define mozilla_dom_bindings_Nullable_h
+#ifndef mozilla_dom_Nullable_h
+#define mozilla_dom_Nullable_h
 
 #include "mozilla/Assertions.h"
 
 namespace mozilla {
 namespace dom {
-namespace bindings {
 
 // Support for nullable types
 template <typename T>
 struct Nullable
 {
 private:
   T mValue;
   bool mIsNull;
@@ -53,13 +52,12 @@ public:
     return mValue;
   }
 
   bool IsNull() const {
     return mIsNull;
   }
 };
 
-} // namespace bindings
 } // namespace dom
 } // namespace mozilla
 
-#endif /* mozilla_dom_bindings_Nullable_h */
+#endif /* mozilla_dom_Nullable_h */
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -36,19 +36,19 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "domstubs.idl"
 
 %{C++
 #include "nsEvent.h"
-#include "mozilla/dom/bindings/Nullable.h"
+#include "mozilla/dom/Nullable.h"
 
-using mozilla::dom::bindings::Nullable;
+using mozilla::dom::Nullable;
 
 class nsPresContext;
 class nsEventChainPreVisitor;
 class nsEventChainPostVisitor;
 struct JSContext;
 class nsEventListenerManager;
 %}
 
--- a/dom/workers/DOMBindingBase.cpp
+++ b/dom/workers/DOMBindingBase.cpp
@@ -3,17 +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/. */
 
 #include "DOMBindingBase.h"
 
 #include "nsIJSContextStack.h"
 
 #include "jsfriendapi.h"
-#include "mozilla/dom/bindings/DOMJSClass.h"
+#include "mozilla/dom/DOMJSClass.h"
 #include "nsContentUtils.h"
 #include "nsWrapperCacheInlines.h"
 
 USING_WORKERS_NAMESPACE
 
 DOMBindingBase::DOMBindingBase(JSContext* aCx)
 : mJSContext(aCx)
 {
--- a/dom/workers/DOMBindingInlines.h
+++ b/dom/workers/DOMBindingInlines.h
@@ -1,18 +1,18 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* 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/. */
 
 #ifndef mozilla_dom_workers_dombindinginlines_h__
 #define mozilla_dom_workers_dombindinginlines_h__
 
-#include "mozilla/dom/bindings/XMLHttpRequestBinding.h"
-#include "mozilla/dom/bindings/XMLHttpRequestUploadBinding.h"
+#include "mozilla/dom/XMLHttpRequestBinding.h"
+#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
 
 BEGIN_WORKERS_NAMESPACE
 
 class XMLHttpRequest;
 class XMLHttpRequestUpload;
 
 namespace {
 
@@ -24,25 +24,25 @@ struct WrapPrototypeTraits
 //     binding headers.
 #define SPECIALIZE_PROTO_TRAITS(_class)                                        \
   template <>                                                                  \
   struct WrapPrototypeTraits<_class>                                           \
   {                                                                            \
     static inline JSClass*                                                     \
     GetJSClass()                                                               \
     {                                                                          \
-      using namespace mozilla::dom::bindings::prototypes;                      \
-      return _class##_workers::Class.ToJSClass();                              \
+      using namespace mozilla::dom;                                            \
+      return _class##Binding_workers::Class.ToJSClass();                       \
     }                                                                          \
                                                                                \
     static inline JSObject*                                                    \
     GetProtoObject(JSContext* aCx, JSObject* aGlobal)                          \
     {                                                                          \
-      using namespace mozilla::dom::bindings::prototypes;                      \
-      return _class##_workers::GetProtoObject(aCx, aGlobal, aGlobal);          \
+      using namespace mozilla::dom;                                            \
+      return _class##Binding_workers::GetProtoObject(aCx, aGlobal, aGlobal);   \
     }                                                                          \
   };
 
 SPECIALIZE_PROTO_TRAITS(XMLHttpRequest)
 SPECIALIZE_PROTO_TRAITS(XMLHttpRequestUpload)
 
 #undef SPECIALIZE_PROTO_TRAITS
 
--- a/dom/workers/EventTarget.h
+++ b/dom/workers/EventTarget.h
@@ -6,19 +6,19 @@
 #ifndef mozilla_dom_workers_eventtarget_h__
 #define mozilla_dom_workers_eventtarget_h__
 
 #include "mozilla/dom/workers/bindings/DOMBindingBase.h"
 
 // I hate having to export this...
 #include "mozilla/dom/workers/bindings/EventListenerManager.h"
 
-#include "mozilla/dom/bindings/Nullable.h"
+#include "mozilla/dom/Nullable.h"
 
-using namespace mozilla::dom::bindings;
+using namespace mozilla::dom;
 
 BEGIN_WORKERS_NAMESPACE
 
 class EventTarget : public DOMBindingBase
 {
   EventListenerManager mListenerManager;
 
 protected:
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -48,34 +48,34 @@
 #include "nsIPlatformCharset.h"
 #include "nsIPrincipal.h"
 #include "nsIJSContextStack.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsISupportsPriority.h"
 #include "nsITimer.h"
 #include "nsPIDOMWindow.h"
 
-#include "mozilla/dom/bindings/EventTargetBinding.h"
+#include "mozilla/dom/EventTargetBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsContentUtils.h"
 #include "nsDOMJSUtils.h"
 #include <Navigator.h>
 #include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 #include "nsXPCOMPrivate.h"
 #include "xpcpublic.h"
 
 #include "Events.h"
 #include "Worker.h"
 #include "WorkerPrivate.h"
 
 using namespace mozilla;
-using namespace mozilla::dom::bindings::prototypes;
+using namespace mozilla::dom;
 
 USING_WORKERS_NAMESPACE
 
 using mozilla::MutexAutoLock;
 using mozilla::MutexAutoUnlock;
 using mozilla::Preferences;
 
 // The size of the worker runtime heaps in bytes. May be changed via pref.
@@ -444,17 +444,17 @@ ResolveWorkerClasses(JSContext* aCx, JSO
 
   if (shouldResolve) {
     // Don't do anything if workers are disabled.
     if (!isChrome && !Preferences::GetBool(PREF_WORKERS_ENABLED)) {
       *aObjp = nsnull;
       return true;
     }
 
-    JSObject* eventTarget = EventTarget_workers::GetProtoObject(aCx, aObj, aObj);
+    JSObject* eventTarget = EventTargetBinding_workers::GetProtoObject(aCx, aObj, aObj);
     if (!eventTarget) {
       return false;
     }
 
     JSObject* worker = worker::InitClass(aCx, aObj, eventTarget, true);
     if (!worker) {
       return false;
     }
--- a/dom/workers/Worker.cpp
+++ b/dom/workers/Worker.cpp
@@ -33,34 +33,34 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "Worker.h"
 
-#include "mozilla/dom/bindings/DOMJSClass.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/DOMJSClass.h"
+#include "mozilla/dom/BindingUtils.h"
 
 #include "EventTarget.h"
 #include "RuntimeService.h"
 #include "WorkerPrivate.h"
 
 #include "WorkerInlines.h"
 
 #define PROPERTY_FLAGS \
   (JSPROP_ENUMERATE | JSPROP_SHARED)
 
 #define FUNCTION_FLAGS \
   JSPROP_ENUMERATE
 
 USING_WORKERS_NAMESPACE
 
-using namespace mozilla::dom::bindings;
+using namespace mozilla::dom;
 
 namespace {
 
 class Worker
 {
   static DOMJSClass sClass;
   static JSPropertySpec sProperties[];
   static JSFunctionSpec sFunctions[];
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -37,21 +37,21 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "WorkerScope.h"
 
 #include "jsapi.h"
 #include "jsdbgapi.h"
 #include "mozilla/Util.h"
-#include "mozilla/dom/bindings/DOMJSClass.h"
-#include "mozilla/dom/bindings/EventTargetBinding.h"
-#include "mozilla/dom/bindings/Utils.h"
-#include "mozilla/dom/bindings/XMLHttpRequestBinding.h"
-#include "mozilla/dom/bindings/XMLHttpRequestUploadBinding.h"
+#include "mozilla/dom/DOMJSClass.h"
+#include "mozilla/dom/EventTargetBinding.h"
+#include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/XMLHttpRequestBinding.h"
+#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
 #include "nsTraceRefcnt.h"
 #include "xpcpublic.h"
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 
 #include "ChromeWorkerScope.h"
@@ -74,17 +74,16 @@
 
 #define PROPERTY_FLAGS \
   (JSPROP_ENUMERATE | JSPROP_SHARED)
 
 #define FUNCTION_FLAGS \
   JSPROP_ENUMERATE
 
 using namespace mozilla;
-using namespace mozilla::dom::bindings;
 USING_WORKERS_NAMESPACE
 
 namespace {
 
 class WorkerGlobalScope : public EventTarget
 {
   static JSClass sClass;
   static JSPropertySpec sProperties[];
@@ -702,17 +701,17 @@ public:
                         sProperties, sFunctions, NULL, NULL);
   }
 
   static JSBool
   InitPrivate(JSContext* aCx, JSObject* aObj, WorkerPrivate* aWorkerPrivate)
   {
     JS_ASSERT(JS_GetClass(aObj) == Class());
 
-    mozilla::dom::bindings::AllocateProtoOrIfaceCache(aObj);
+    dom::AllocateProtoOrIfaceCache(aObj);
 
     nsRefPtr<DedicatedWorkerGlobalScope> scope =
       new DedicatedWorkerGlobalScope(aCx, aWorkerPrivate);
 
     js::SetReservedSlot(aObj, DOM_GLOBAL_OBJECT_SLOT, PRIVATE_TO_JSVAL(scope));
 
     scope->SetIsDOMBinding();
     scope->SetWrapper(aObj);
@@ -925,17 +924,17 @@ WorkerGlobalScope::GetInstancePrivate(JS
 
 } /* anonymous namespace */
 
 BEGIN_WORKERS_NAMESPACE
 
 JSObject*
 CreateDedicatedWorkerGlobalScope(JSContext* aCx)
 {
-  using namespace mozilla::dom::bindings::prototypes;
+  using namespace mozilla::dom;
 
   WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
   JS_ASSERT(worker);
 
   JSObject* global =
     JS_NewCompartmentAndGlobalObject(aCx, DedicatedWorkerGlobalScope::Class(),
                                      GetWorkerPrincipal());
   if (!global) {
@@ -954,17 +953,17 @@ CreateDedicatedWorkerGlobalScope(JSConte
 
   // Proto chain should be:
   //   global -> DedicatedWorkerGlobalScope
   //          -> WorkerGlobalScope
   //          -> EventTarget
   //          -> Object
 
   JSObject* eventTargetProto =
-    EventTarget_workers::GetProtoObject(aCx, global, global);
+    EventTargetBinding_workers::GetProtoObject(aCx, global, global);
   if (!eventTargetProto) {
     return NULL;
   }
 
   JSObject* scopeProto =
     WorkerGlobalScope::InitClass(aCx, global, eventTargetProto);
   if (!scopeProto) {
     return NULL;
@@ -999,19 +998,20 @@ CreateDedicatedWorkerGlobalScope(JSConte
       !exceptions::InitClasses(aCx, global) ||
       !location::InitClass(aCx, global) ||
       !imagedata::InitClass(aCx, global) ||
       !navigator::InitClass(aCx, global)) {
     return NULL;
   }
 
   // Init other paris-bindings.
-  if (!XMLHttpRequest_workers::CreateInterfaceObjects(aCx, global, global) ||
-      !XMLHttpRequestUpload_workers::CreateInterfaceObjects(aCx, global,
-                                                            global)) {
+  if (!XMLHttpRequestBinding_workers::CreateInterfaceObjects(aCx, global,
+                                                             global) ||
+      !XMLHttpRequestUploadBinding_workers::CreateInterfaceObjects(aCx, global,
+                                                                   global)) {
     return NULL;
   }
 
   if (!JS_DefineProfilingFunctions(aCx, global)) {
     return NULL;
   }
 
   return global;
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -26,19 +26,16 @@
 #include "RuntimeService.h"
 #include "WorkerPrivate.h"
 #include "XMLHttpRequestUpload.h"
 
 #include "DOMBindingInlines.h"
 
 USING_WORKERS_NAMESPACE
 
-namespace XMLHttpRequestResponseTypeValues = 
-  mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType;
-
 using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
 
 // XXX Need to figure this out...
 #define UNCATCHABLE_EXCEPTION NS_ERROR_OUT_OF_MEMORY
 
 /**
  *  XMLHttpRequest in workers
  *
@@ -210,41 +207,42 @@ public:
 };
 
 END_WORKERS_NAMESPACE
 
 
 namespace {
 
 inline void
-ConvertResponseTypeToString(XMLHttpRequestResponseType aType, nsString& aString)
+ConvertResponseTypeToString(XMLHttpRequestResponseType aType,
+                            nsString& aString)
 {
   using namespace
-    mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType;
+    mozilla::dom::XMLHttpRequestResponseTypeValues;
 
   size_t index = static_cast<size_t>(aType);
   MOZ_ASSERT(index < ArrayLength(strings), "Codegen gave us a bad value!");
 
   aString.AssignASCII(strings[index].value, strings[index].length);
 }
 
 inline XMLHttpRequestResponseType
 ConvertStringToResponseType(const nsAString& aString)
 {
   using namespace
-    mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType;
+    mozilla::dom::XMLHttpRequestResponseTypeValues;
 
   for (size_t index = 0; index < ArrayLength(strings) - 1; index++) {
     if (aString.EqualsASCII(strings[index].value, strings[index].length)) {
       return static_cast<XMLHttpRequestResponseType>(index);
     }
   }
 
   MOZ_NOT_REACHED("Don't know anything about this response type!");
-  return XMLHttpRequestResponseTypeValues::_empty;
+  return _empty;
 }
 
 enum
 {
   STRING_abort = 0,
   STRING_error,
   STRING_load,
   STRING_loadstart,
--- a/dom/workers/XMLHttpRequest.h
+++ b/dom/workers/XMLHttpRequest.h
@@ -5,27 +5,24 @@
 
 #ifndef mozilla_dom_workers_xmlhttprequest_h__
 #define mozilla_dom_workers_xmlhttprequest_h__
 
 #include "mozilla/dom/workers/bindings/XMLHttpRequestEventTarget.h"
 #include "mozilla/dom/workers/bindings/WorkerFeature.h"
 
 // Need this for XMLHttpRequestResponseType.
-#include "mozilla/dom/bindings/XMLHttpRequestBinding.h"
+#include "mozilla/dom/XMLHttpRequestBinding.h"
 
 BEGIN_WORKERS_NAMESPACE
 
 class Proxy;
 class XMLHttpRequestUpload;
 class WorkerPrivate;
 
-typedef mozilla::dom::bindings::prototypes::XMLHttpRequestResponseType::value
-        XMLHttpRequestResponseType;
-
 class XMLHttpRequest : public XMLHttpRequestEventTarget,
                        public WorkerFeature
 {
 public:
   struct StateData
   {
     nsString mResponseText;
     uint32_t mStatus;
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -56,22 +56,22 @@
 #include "XrayWrapper.h"
 #include "nsNullPrincipal.h"
 #include "nsJSUtils.h"
 #include "mozJSComponentLoader.h"
 #include "nsContentUtils.h"
 #include "jsgc.h"
 #include "jsfriendapi.h"
 #include "AccessCheck.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla;
 using namespace js;
 
-using mozilla::dom::bindings::DestroyProtoOrIfaceCache;
+using mozilla::dom::DestroyProtoOrIfaceCache;
 
 /***************************************************************************/
 // stuff used by all
 
 static nsresult ThrowAndFail(unsigned errNum, JSContext* cx, bool* retval)
 {
     XPCThrower::Throw(errNum, cx);
     *retval = false;
@@ -3221,17 +3221,17 @@ xpc_CreateSandboxObject(JSContext * cx, 
                     return NS_ERROR_FAILURE;
                 proto = JSVAL_TO_OBJECT(v);
             }
 
             // Now check what sort of thing we've got in |proto|
             JSObject *unwrappedProto = js::UnwrapObject(proto, false);
             js::Class *unwrappedClass = js::GetObjectClass(unwrappedProto);
             if (IS_WRAPPER_CLASS(unwrappedClass) ||
-                mozilla::dom::bindings::IsDOMClass(Jsvalify(unwrappedClass))) {
+                mozilla::dom::IsDOMClass(Jsvalify(unwrappedClass))) {
                 // Wrap it up in a proxy that will do the right thing in terms
                 // of this-binding for methods.
                 proto = js::NewProxyObject(cx, &xpc::sandboxProxyHandler,
                                            ObjectValue(*proto), nsnull,
                                            sandbox);
                 if (!proto)
                     return NS_ERROR_OUT_OF_MEMORY;
             }
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -55,17 +55,17 @@
 #include "nsJSUtils.h"
 
 #include "dombindings.h"
 #include "nsWrapperCacheInlines.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //#define STRICT_CHECK_OF_UNICODE
 #ifdef STRICT_CHECK_OF_UNICODE
 #define ILLEGAL_RANGE(c) (0!=((c) & 0xFF80))
 #else // STRICT_CHECK_OF_UNICODE
@@ -105,18 +105,18 @@ XPCConvert::GetISupportsFromJSObject(JSO
     NS_ASSERTION(jsclass, "obj has no class");
     if (jsclass &&
         (jsclass->flags & JSCLASS_HAS_PRIVATE) &&
         (jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
         *iface = (nsISupports*) xpc_GetJSPrivate(obj);
         return true;
     }
     if (jsclass && (jsclass->flags & JSCLASS_IS_DOMJSCLASS) &&
-        bindings::DOMJSClass::FromJSClass(jsclass)->mDOMObjectIsISupports) {
-        *iface = bindings::UnwrapDOMObject<nsISupports>(obj, jsclass);
+        DOMJSClass::FromJSClass(jsclass)->mDOMObjectIsISupports) {
+        *iface = UnwrapDOMObject<nsISupports>(obj, jsclass);
         return true;
     }
     return false;
 }
 
 /***************************************************************************/
 
 static void
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -37,18 +37,18 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* An xpcom implementation of the JavaScript nsIID and nsCID objects. */
 
 #include "xpcprivate.h"
-#include "mozilla/dom/bindings/DOMJSClass.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/DOMJSClass.h"
+#include "mozilla/dom/BindingUtils.h"
 
 /***************************************************************************/
 // nsJSID
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsJSID, nsIJSID)
 
 char nsJSID::gNoString[] = "";
 
@@ -514,23 +514,23 @@ nsJSIID::HasInstance(nsIXPConnectWrapped
             if (!MorphSlimWrapper(cx, obj))
                 return NS_ERROR_FAILURE;
         }
 
         nsISupports *identity;
         if (mozilla::dom::binding::instanceIsProxy(obj)) {
             identity =
                 static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
-        } else if (mozilla::dom::bindings::IsDOMClass(js::GetObjectJSClass(obj))) {
-            NS_ASSERTION(mozilla::dom::bindings::DOMJSClass::FromJSClass(
+        } else if (mozilla::dom::IsDOMClass(js::GetObjectJSClass(obj))) {
+            NS_ASSERTION(mozilla::dom::DOMJSClass::FromJSClass(
                               js::GetObjectJSClass(obj))->mDOMObjectIsISupports,
                          "This only works on nsISupports classes!");
             identity =
-                mozilla::dom::bindings::UnwrapDOMObject<nsISupports>(obj,
-                                                                     js::GetObjectJSClass(obj));
+                mozilla::dom::UnwrapDOMObject<nsISupports>(obj,
+                                                           js::GetObjectJSClass(obj));
         } else {
             identity = nsnull;
         }
 
         if (identity) {
             nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(identity);
 
             XPCCallContext ccx(JS_CALLER, cx);
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -54,17 +54,17 @@
 #include "prsystem.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "jsfriendapi.h"
 #include "js/MemoryMetrics.h"
-#include "mozilla/dom/bindings/DOMJSClass.h"
+#include "mozilla/dom/DOMJSClass.h"
 
 #include "nsJSPrincipals.h"
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 
 using namespace mozilla;
@@ -510,17 +510,17 @@ SuspectDOMExpandos(nsPtrHashKey<JSObject
     JSObject* obj = key->GetKey();
     nsISupports* native = nsnull;
     if (js::IsProxy(obj)) {
         NS_ASSERTION(mozilla::dom::binding::instanceIsProxy(obj),
                      "Not a DOM proxy?");
         native = static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
     }
     else {
-        NS_ASSERTION(mozilla::dom::bindings::DOMJSClass::FromJSClass(JS_GetClass(obj))->mDOMObjectIsISupports,
+        NS_ASSERTION(mozilla::dom::DOMJSClass::FromJSClass(JS_GetClass(obj))->mDOMObjectIsISupports,
                      "Someone added a wrapper for a non-nsISupports native to DOMExpandos!");
         native = static_cast<nsISupports*>(js::GetReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
     }
     closure->cb->NoteXPCOMRoot(native);
     return PL_DHASH_NEXT;
 }
 
 static PLDHashOperator
--- a/js/xpconnect/src/XPCThreadContext.cpp
+++ b/js/xpconnect/src/XPCThreadContext.cpp
@@ -42,20 +42,20 @@
 /* Implement global service to track stack of JSContext per thread. */
 
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 #include "mozilla/Mutex.h"
 #include "nsDOMJSUtils.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsNullPrincipal.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla;
-using mozilla::dom::bindings::DestroyProtoOrIfaceCache;
+using mozilla::dom::DestroyProtoOrIfaceCache;
 
 /***************************************************************************/
 
 XPCJSContextStack::~XPCJSContextStack()
 {
     if (mOwnSafeJSContext) {
         JS_DestroyContext(mOwnSafeJSContext);
         mOwnSafeJSContext = nsnull;
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -39,17 +39,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* JavaScript JSClasses and JSOps for our Wrapped Native JS Objects. */
 
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 #include "nsWrapperCacheInlines.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 /***************************************************************************/
 
 // All of the exceptions thrown into JS from this file go through here.
 // That makes this a nice place to set a breakpoint.
 
 static JSBool Throw(unsigned errNum, JSContext* cx)
 {
@@ -615,17 +615,17 @@ XPC_WN_Shared_Enumerate(JSContext *cx, J
 static PRUint32 sFinalizedSlimWrappers;
 #endif
 
 static void
 XPC_WN_NoHelper_Finalize(js::FreeOp *fop, JSObject *obj)
 {
     js::Class* clazz = js::GetObjectClass(obj);
     if (clazz->flags & JSCLASS_DOM_GLOBAL) {
-        mozilla::dom::bindings::DestroyProtoOrIfaceCache(obj);
+        mozilla::dom::DestroyProtoOrIfaceCache(obj);
     }
     nsISupports* p = static_cast<nsISupports*>(xpc_GetJSPrivate(obj));
     if (!p)
         return;
 
     if (IS_SLIM_WRAPPER_OBJECT(obj)) {
         SLIM_LOG(("----- %i finalized slim wrapper (%p, %p)\n",
                   ++sFinalizedSlimWrappers, obj, p));
@@ -1044,17 +1044,17 @@ XPC_WN_Helper_HasInstance(JSContext *cx,
     POST_HELPER_STUB
 }
 
 static void
 XPC_WN_Helper_Finalize(js::FreeOp *fop, JSObject *obj)
 {
     js::Class* clazz = js::GetObjectClass(obj);
     if (clazz->flags & JSCLASS_DOM_GLOBAL) {
-        mozilla::dom::bindings::DestroyProtoOrIfaceCache(obj);
+        mozilla::dom::DestroyProtoOrIfaceCache(obj);
     }
     nsISupports* p = static_cast<nsISupports*>(xpc_GetJSPrivate(obj));
     if (IS_SLIM_WRAPPER(obj)) {
         SLIM_LOG(("----- %i finalized slim wrapper (%p, %p)\n",
                   ++sFinalizedSlimWrappers, obj, p));
 
         nsWrapperCache* cache;
         CallQueryInterface(p, &cache);
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -38,19 +38,19 @@
  * ***** END LICENSE BLOCK ***** */
 
 /* Class used to manage the wrapped native objects within a JS scope. */
 
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 #include "jsproxy.h"
 
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
-using namespace mozilla::dom;
+using namespace mozilla;
 
 /***************************************************************************/
 
 #ifdef XPC_TRACK_SCOPE_STATS
 static int DEBUG_TotalScopeCount;
 static int DEBUG_TotalLiveScopeCount;
 static int DEBUG_TotalMaxScopeCount;
 static int DEBUG_TotalScopeTraversalCount;
@@ -253,18 +253,18 @@ XPCWrappedNativeScope::SetGlobal(XPCCall
         const JSClass *jsClass = js::GetObjectJSClass(aGlobal);
         nsISupports *priv;
         if (!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
                                  JSCLASS_PRIVATE_IS_NSISUPPORTS))) {
             // Our global has an nsISupports native pointer.  Let's
             // see whether it's what we want.
             priv = static_cast<nsISupports*>(xpc_GetJSPrivate(aGlobal));
         } else if ((jsClass->flags & JSCLASS_IS_DOMJSCLASS) &&
-                   bindings::DOMJSClass::FromJSClass(jsClass)->mDOMObjectIsISupports) {
-            priv = bindings::UnwrapDOMObject<nsISupports>(aGlobal, jsClass);
+                   dom::DOMJSClass::FromJSClass(jsClass)->mDOMObjectIsISupports) {
+            priv = dom::UnwrapDOMObject<nsISupports>(aGlobal, jsClass);
         } else {
             priv = nsnull;
         }
         nsCOMPtr<nsIXPConnectWrappedNative> wn = do_QueryInterface(priv);
         if (wn)
             native = static_cast<XPCWrappedNative*>(wn.get())->GetIdentityObject();
         else
             native = priv;
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -43,23 +43,23 @@
 #include "xpcpublic.h"
 #include "xpcprivate.h"
 #include "XPCQuickStubs.h"
 #include "XPCWrapper.h"
 #include "WrapperFactory.h"
 #include "nsDOMClassInfo.h"
 #include "nsGlobalWindow.h"
 #include "nsWrapperCacheInlines.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 #include "jsapi.h"
 #include "jsatom.h"
 
 using namespace JS;
-using namespace mozilla::dom::bindings;
+using namespace mozilla::dom;
 
 namespace mozilla {
 namespace dom {
 namespace binding {
 
 enum {
     JSPROXYSLOT_PROTOSHAPE = 0,
     JSPROXYSLOT_EXPANDO = 1
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -65,17 +65,17 @@
 
 #ifdef MOZ_JSDEBUGGER
 #include "jsdIDebuggerService.h"
 #endif
 
 #include "XPCQuickStubs.h"
 #include "dombindings.h"
 
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMMutationObserver.h"
 
 using namespace mozilla::dom;
 
 NS_IMPL_THREADSAFE_ISUPPORTS7(nsXPConnect,
                               nsIXPConnect,
@@ -903,19 +903,19 @@ nsXPConnect::Traverse(void *p, nsCycleCo
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "xpc_GetJSPrivate(obj)");
         cb.NoteXPCOMChild(static_cast<nsISupports*>(xpc_GetJSPrivate(obj)));
     } else if (binding::instanceIsProxy(obj)) {
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "js::GetProxyPrivate(obj)");
         nsISupports *identity =
             static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
         cb.NoteXPCOMChild(identity);
     } else if ((clazz->flags & JSCLASS_IS_DOMJSCLASS) &&
-               bindings::DOMJSClass::FromJSClass(clazz)->mDOMObjectIsISupports) {
+               DOMJSClass::FromJSClass(clazz)->mDOMObjectIsISupports) {
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "UnwrapDOMObject(obj)");
-        nsISupports *identity = bindings::UnwrapDOMObject<nsISupports>(obj, clazz);
+        nsISupports *identity = UnwrapDOMObject<nsISupports>(obj, clazz);
         cb.NoteXPCOMChild(identity);
     }
 
     return NS_OK;
 }
 
 unsigned
 nsXPConnect::GetOutstandingRequests(JSContext* cx)
@@ -1169,17 +1169,17 @@ xpc_CreateGlobalObject(JSContext *cx, JS
         JS_TracerInit(&trc.base, JS_GetRuntime(cx), VerifyTraceXPCGlobalCalled);
         trc.ok = false;
         JS_TraceChildren(&trc.base, *global, JSTRACE_OBJECT);
         NS_ABORT_IF_FALSE(trc.ok, "Trace hook needs to call TraceXPCGlobal if JSCLASS_XPCONNECT_GLOBAL is set.");
     }
 #endif
 
     if (clasp->flags & JSCLASS_DOM_GLOBAL) {
-        mozilla::dom::bindings::AllocateProtoOrIfaceCache(*global);
+        AllocateProtoOrIfaceCache(*global);
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
                                              nsISupports *aCOMObj,
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -48,17 +48,17 @@
 #include "jspubtd.h"
 #include "jsproxy.h"
 
 #include "nsISupports.h"
 #include "nsIPrincipal.h"
 #include "nsWrapperCache.h"
 #include "nsStringGlue.h"
 #include "nsTArray.h"
-#include "mozilla/dom/bindings/DOMJSClass.h"
+#include "mozilla/dom/DOMJSClass.h"
 
 class nsIPrincipal;
 class nsIXPConnectWrappedJS;
 class nsScriptNameSpaceManager;
 
 #ifndef BAD_TLS_INDEX
 #define BAD_TLS_INDEX ((PRUint32) -1)
 #endif
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -41,17 +41,17 @@
 #include "FilteringWrapper.h"
 #include "XrayWrapper.h"
 #include "AccessCheck.h"
 #include "XPCWrapper.h"
 
 #include "xpcprivate.h"
 #include "dombindings.h"
 #include "XPCMaps.h"
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 #include "jsfriendapi.h"
 
 using namespace js;
 
 namespace xpc {
 
 // When chrome pulls a naked property across the membrane using
 // .wrappedJSObject, we want it to cross the membrane into the
@@ -271,17 +271,17 @@ enum XrayType {
     XrayForWrappedNative,
     NotXray
 };
 
 static XrayType
 GetXrayType(JSObject *obj)
 {
     js::Class* clasp = js::GetObjectClass(obj);
-    if (mozilla::dom::bindings::IsDOMClass(Jsvalify(clasp))) {
+    if (mozilla::dom::IsDOMClass(Jsvalify(clasp))) {
         return XrayForDOMObject;
     }
     if (mozilla::dom::binding::instanceIsProxy(obj)) {
         return XrayForDOMProxyObject;
     }
     if (IS_WRAPPER_CLASS(clasp) || clasp->ext.innerObject) {
         NS_ASSERTION(clasp->ext.innerObject || IS_WN_WRAPPER_OBJECT(obj),
                      "We forgot to Morph a slim wrapper!");
@@ -359,17 +359,17 @@ WrapperFactory::Rewrap(JSContext *cx, JS
             typedef XrayWrapper<CrossCompartmentSecurityWrapper> Xray;
             usingXray = true;
             if (IsLocationObject(obj))
                 wrapper = &FilteringWrapper<Xray, LocationPolicy>::singleton;
             else
                 wrapper = &FilteringWrapper<Xray, CrossOriginAccessiblePropertiesOnly>::singleton;
         } else if (mozilla::dom::binding::instanceIsProxy(obj)) {
             wrapper = &FilteringWrapper<XrayProxy, CrossOriginAccessiblePropertiesOnly>::singleton;
-        } else if (mozilla::dom::bindings::IsDOMClass(JS_GetClass(obj))) {
+        } else if (mozilla::dom::IsDOMClass(JS_GetClass(obj))) {
             wrapper = &FilteringWrapper<XrayDOM, CrossOriginAccessiblePropertiesOnly>::singleton;
         } else if (IsComponentsObject(obj)) {
             wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper,
                                         ComponentsObjectPolicy>::singleton;
         } else {
             wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper,
                                         ExposedPropertiesOnly>::singleton;
         }
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -46,19 +46,19 @@
 #include "nsINode.h"
 #include "nsIDocument.h"
 
 #include "XPCWrapper.h"
 #include "xpcprivate.h"
 
 #include "jsapi.h"
 
-#include "mozilla/dom/bindings/Utils.h"
+#include "mozilla/dom/BindingUtils.h"
 
-using namespace mozilla::dom::bindings;
+using namespace mozilla::dom;
 
 namespace xpc {
 
 using namespace js;
 
 static const uint32_t JSSLOT_WN = 0;
 static const uint32_t JSSLOT_RESOLVING = 1;
 static const uint32_t JSSLOT_EXPANDO = 2;