Bug 1518384 - Fix some lines which depend on |using namespace mozilla| and |using namespace mozilla::dom| in Document.cpp and Element.cpp r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 08 Jan 2019 10:15:55 +0000
changeset 509981 54f18c480711e3cee577e4174f6def86ec2b2a05
parent 509980 d1babeef937f5cd40a840082bdb1e4252b831947
child 509982 ef42fcd70042334d12a4208d7e07c6a4542ede2e
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1518384, 1517241
milestone66.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 1518384 - Fix some lines which depend on |using namespace mozilla| and |using namespace mozilla::dom| in Document.cpp and Element.cpp r=smaug After landing bug 1517241, some lines in Document.cpp and Element.cpp depend on `using namespace mozilla` and `using namespace mozilla::dom` of *different* cpp files. Therefore, when you rename some cpp files in dom/base, you'll hit compile error. This patch fixes the dependency with moving some classes into mozilla namespace and adding |mozilla::| or |dom::| to a couple of lines. Differential Revision: https://phabricator.services.mozilla.com/D15897
dom/base/Document.cpp
dom/base/DocumentOrShadowRoot.cpp
dom/base/DocumentOrShadowRoot.h
dom/base/Element.cpp
dom/base/IdentifierMapEntry.h
dom/base/ShadowRoot.cpp
dom/base/ShadowRoot.h
dom/base/moz.build
dom/base/nsIdentifierMapEntry.h
dom/html/nsHTMLDocument.cpp
dom/xul/nsXULCommandDispatcher.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -15,16 +15,17 @@
 #include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/BinarySearch.h"
 #include "mozilla/CSSEnabledState.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/EnumSet.h"
+#include "mozilla/IdentifierMapEntry.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Likely.h"
 #include "mozilla/PresShell.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/URLExtraData.h"
 #include <algorithm>
 
@@ -295,16 +296,18 @@
 #include "StorageAccessPermissionRequest.h"
 #include "mozilla/dom/WindowProxyHolder.h"
 
 #define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
 #define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
 #define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2)
 #define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3)
 
+extern bool sDisablePrefetchHTTPSPref;
+
 namespace mozilla {
 namespace dom {
 
 typedef nsTArray<Link*> LinkArray;
 
 static LazyLogModule gDocumentLeakPRLog("DocumentLeak");
 static LazyLogModule gCspPRLog("CSP");
 static LazyLogModule gUserInteractionPRLog("UserInteraction");
@@ -331,129 +334,122 @@ static nsresult GetHttpChannelHelper(nsI
 
   httpChannel = do_QueryInterface(baseChannel);
   httpChannel.forget(aHttpChannel);
 
   return NS_OK;
 }
 
 }  // namespace dom
-}  // namespace mozilla
-
-extern bool sDisablePrefetchHTTPSPref;
 
 #define NAME_NOT_VALID ((nsSimpleContentList*)1)
 
-nsIdentifierMapEntry::nsIdentifierMapEntry(
-    const nsIdentifierMapEntry::AtomOrString& aKey)
+IdentifierMapEntry::IdentifierMapEntry(
+    const IdentifierMapEntry::AtomOrString& aKey)
     : mKey(aKey) {}
 
-nsIdentifierMapEntry::nsIdentifierMapEntry(
-    const nsIdentifierMapEntry::AtomOrString* aKey)
+IdentifierMapEntry::IdentifierMapEntry(
+    const IdentifierMapEntry::AtomOrString* aKey)
     : mKey(aKey ? *aKey : nullptr) {}
 
-nsIdentifierMapEntry::~nsIdentifierMapEntry() {}
-
-nsIdentifierMapEntry::nsIdentifierMapEntry(nsIdentifierMapEntry&& aOther)
+IdentifierMapEntry::~IdentifierMapEntry() {}
+
+IdentifierMapEntry::IdentifierMapEntry(IdentifierMapEntry&& aOther)
     : PLDHashEntryHdr(std::move(aOther)),
       mKey(std::move(aOther.mKey)),
       mIdContentList(std::move(aOther.mIdContentList)),
       mNameContentList(std::move(aOther.mNameContentList)),
       mChangeCallbacks(std::move(aOther.mChangeCallbacks)),
       mImageElement(std::move(aOther.mImageElement)) {}
 
-void nsIdentifierMapEntry::Traverse(
+void IdentifierMapEntry::Traverse(
     nsCycleCollectionTraversalCallback* aCallback) {
   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback,
                                      "mIdentifierMap mNameContentList");
   aCallback->NoteXPCOMChild(static_cast<nsINodeList*>(mNameContentList));
 
   if (mImageElement) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback,
                                        "mIdentifierMap mImageElement element");
     nsIContent* imageElement = mImageElement;
     aCallback->NoteXPCOMChild(imageElement);
   }
 }
 
-bool nsIdentifierMapEntry::IsEmpty() {
+bool IdentifierMapEntry::IsEmpty() {
   return mIdContentList.IsEmpty() && !mNameContentList && !mChangeCallbacks &&
          !mImageElement;
 }
 
-bool nsIdentifierMapEntry::HasNameElement() const {
+bool IdentifierMapEntry::HasNameElement() const {
   return mNameContentList && mNameContentList->Length() != 0;
 }
 
-Element* nsIdentifierMapEntry::GetIdElement() {
+Element* IdentifierMapEntry::GetIdElement() {
   return mIdContentList.SafeElementAt(0);
 }
 
-Element* nsIdentifierMapEntry::GetImageIdElement() {
+Element* IdentifierMapEntry::GetImageIdElement() {
   return mImageElement ? mImageElement.get() : GetIdElement();
 }
 
-void nsIdentifierMapEntry::AddContentChangeCallback(
+void IdentifierMapEntry::AddContentChangeCallback(
     Document::IDTargetObserver aCallback, void* aData, bool aForImage) {
   if (!mChangeCallbacks) {
     mChangeCallbacks = new nsTHashtable<ChangeCallbackEntry>;
   }
 
   ChangeCallback cc = {aCallback, aData, aForImage};
   mChangeCallbacks->PutEntry(cc);
 }
 
-void nsIdentifierMapEntry::RemoveContentChangeCallback(
+void IdentifierMapEntry::RemoveContentChangeCallback(
     Document::IDTargetObserver aCallback, void* aData, bool aForImage) {
   if (!mChangeCallbacks) return;
   ChangeCallback cc = {aCallback, aData, aForImage};
   mChangeCallbacks->RemoveEntry(cc);
   if (mChangeCallbacks->Count() == 0) {
     mChangeCallbacks = nullptr;
   }
 }
 
-void nsIdentifierMapEntry::FireChangeCallbacks(Element* aOldElement,
-                                               Element* aNewElement,
-                                               bool aImageOnly) {
+void IdentifierMapEntry::FireChangeCallbacks(Element* aOldElement,
+                                             Element* aNewElement,
+                                             bool aImageOnly) {
   if (!mChangeCallbacks) return;
 
   for (auto iter = mChangeCallbacks->ConstIter(); !iter.Done(); iter.Next()) {
-    nsIdentifierMapEntry::ChangeCallbackEntry* entry = iter.Get();
+    IdentifierMapEntry::ChangeCallbackEntry* entry = iter.Get();
     // Don't fire image changes for non-image observers, and don't fire element
     // changes for image observers when an image override is active.
     if (entry->mKey.mForImage ? (mImageElement && !aImageOnly) : aImageOnly) {
       continue;
     }
 
     if (!entry->mKey.mCallback(aOldElement, aNewElement, entry->mKey.mData)) {
       iter.Remove();
     }
   }
 }
 
-namespace {
-
 struct PositionComparator {
   Element* const mElement;
   explicit PositionComparator(Element* const aElement) : mElement(aElement) {}
 
   int operator()(void* aElement) const {
     Element* curElement = static_cast<Element*>(aElement);
     MOZ_DIAGNOSTIC_ASSERT(mElement != curElement);
     if (nsContentUtils::PositionIsBefore(mElement, curElement)) {
       return -1;
     }
     return 1;
   }
 };
 
-}  // namespace
-
-void nsIdentifierMapEntry::AddIdElement(Element* aElement) {
+void IdentifierMapEntry::AddIdElement(Element* aElement) {
   MOZ_ASSERT(aElement, "Must have element");
   MOZ_ASSERT(!mIdContentList.Contains(nullptr), "Why is null in our list?");
 
   // Common case
   if (mIdContentList.IsEmpty()) {
     mIdContentList.AppendElement(aElement);
     FireChangeCallbacks(nullptr, aElement);
     return;
@@ -474,17 +470,17 @@ void nsIdentifierMapEntry::AddIdElement(
 
   if (idx == 0) {
     Element* oldElement = mIdContentList.SafeElementAt(1);
     NS_ASSERTION(currentElement == oldElement, "How did that happen?");
     FireChangeCallbacks(oldElement, aElement);
   }
 }
 
-void nsIdentifierMapEntry::RemoveIdElement(Element* aElement) {
+void IdentifierMapEntry::RemoveIdElement(Element* aElement) {
   MOZ_ASSERT(aElement, "Missing element");
 
   // This should only be called while the document is in an update.
   // Assertions near the call to this method guarantee this.
 
   // This could fire in OOM situations
   // Only assert this in HTML documents for now as XUL does all sorts of weird
   // crap.
@@ -496,26 +492,25 @@ void nsIdentifierMapEntry::RemoveIdEleme
   // we'll just get cleaned up in the natural order of things...
   Element* currentElement = mIdContentList.SafeElementAt(0);
   mIdContentList.RemoveElement(aElement);
   if (currentElement == aElement) {
     FireChangeCallbacks(currentElement, mIdContentList.SafeElementAt(0));
   }
 }
 
-void nsIdentifierMapEntry::SetImageElement(Element* aElement) {
+void IdentifierMapEntry::SetImageElement(Element* aElement) {
   Element* oldElement = GetImageIdElement();
   mImageElement = aElement;
   Element* newElement = GetImageIdElement();
   if (oldElement != newElement) {
     FireChangeCallbacks(oldElement, newElement, true);
   }
 }
 
-namespace mozilla {
 namespace dom {
 
 class SimpleHTMLCollection final : public nsSimpleContentList,
                                    public nsIHTMLCollection {
  public:
   explicit SimpleHTMLCollection(nsINode* aRoot) : nsSimpleContentList(aRoot) {}
 
   NS_DECL_ISUPPORTS_INHERITED
@@ -589,111 +584,109 @@ class SimpleHTMLCollection final : publi
  private:
   virtual ~SimpleHTMLCollection() {}
 };
 
 NS_IMPL_ISUPPORTS_INHERITED(SimpleHTMLCollection, nsSimpleContentList,
                             nsIHTMLCollection)
 
 }  // namespace dom
-}  // namespace mozilla
-
-void nsIdentifierMapEntry::AddNameElement(nsINode* aNode, Element* aElement) {
+
+void IdentifierMapEntry::AddNameElement(nsINode* aNode, Element* aElement) {
   if (!mNameContentList) {
-    mNameContentList = new SimpleHTMLCollection(aNode);
+    mNameContentList = new dom::SimpleHTMLCollection(aNode);
   }
 
   mNameContentList->AppendElement(aElement);
 }
 
-void nsIdentifierMapEntry::RemoveNameElement(Element* aElement) {
+void IdentifierMapEntry::RemoveNameElement(Element* aElement) {
   if (mNameContentList) {
     mNameContentList->RemoveElement(aElement);
   }
 }
 
-bool nsIdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty() {
+bool IdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty() {
   Element* idElement = GetIdElement();
   return idElement &&
          nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(idElement);
 }
 
-size_t nsIdentifierMapEntry::SizeOfExcludingThis(
+size_t IdentifierMapEntry::SizeOfExcludingThis(
     MallocSizeOf aMallocSizeOf) const {
   return mKey.mString.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
 }
 
 // Helper structs for the content->subdoc map
 
 class SubDocMapEntry : public PLDHashEntryHdr {
  public:
   // Both of these are strong references
   Element* mKey;  // must be first, to look like PLDHashEntryStub
-  Document* mSubDocument;
+  dom::Document* mSubDocument;
 };
 
-class nsOnloadBlocker final : public nsIRequest {
+class OnloadBlocker final : public nsIRequest {
  public:
-  nsOnloadBlocker() {}
+  OnloadBlocker() {}
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUEST
 
  private:
-  ~nsOnloadBlocker() {}
+  ~OnloadBlocker() {}
 };
 
-NS_IMPL_ISUPPORTS(nsOnloadBlocker, nsIRequest)
+NS_IMPL_ISUPPORTS(OnloadBlocker, nsIRequest)
 
 NS_IMETHODIMP
-nsOnloadBlocker::GetName(nsACString& aResult) {
+OnloadBlocker::GetName(nsACString& aResult) {
   aResult.AssignLiteral("about:document-onload-blocker");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsOnloadBlocker::IsPending(bool* _retval) {
+OnloadBlocker::IsPending(bool* _retval) {
   *_retval = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsOnloadBlocker::GetStatus(nsresult* status) {
+OnloadBlocker::GetStatus(nsresult* status) {
   *status = NS_OK;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsOnloadBlocker::Cancel(nsresult status) { return NS_OK; }
+OnloadBlocker::Cancel(nsresult status) { return NS_OK; }
 NS_IMETHODIMP
-nsOnloadBlocker::Suspend(void) { return NS_OK; }
+OnloadBlocker::Suspend(void) { return NS_OK; }
 NS_IMETHODIMP
-nsOnloadBlocker::Resume(void) { return NS_OK; }
+OnloadBlocker::Resume(void) { return NS_OK; }
 
 NS_IMETHODIMP
-nsOnloadBlocker::GetLoadGroup(nsILoadGroup** aLoadGroup) {
+OnloadBlocker::GetLoadGroup(nsILoadGroup** aLoadGroup) {
   *aLoadGroup = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsOnloadBlocker::SetLoadGroup(nsILoadGroup* aLoadGroup) { return NS_OK; }
+OnloadBlocker::SetLoadGroup(nsILoadGroup* aLoadGroup) { return NS_OK; }
 
 NS_IMETHODIMP
-nsOnloadBlocker::GetLoadFlags(nsLoadFlags* aLoadFlags) {
+OnloadBlocker::GetLoadFlags(nsLoadFlags* aLoadFlags) {
   *aLoadFlags = nsIRequest::LOAD_NORMAL;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsOnloadBlocker::SetLoadFlags(nsLoadFlags aLoadFlags) { return NS_OK; }
+OnloadBlocker::SetLoadFlags(nsLoadFlags aLoadFlags) { return NS_OK; }
 
 // ==================================================================
 
-namespace mozilla {
 namespace dom {
 
 ExternalResourceMap::ExternalResourceMap() : mHaveShutDown(false) {}
 
 Document* ExternalResourceMap::RequestResource(
     nsIURI* aURI, nsIURI* aReferrer, uint32_t aReferrerPolicy,
     nsINode* aRequestingNode, Document* aDisplayDocument,
     ExternalResourceLoad** aPendingLoad) {
@@ -1912,17 +1905,17 @@ nsresult Document::Init() {
 
   // Prepend self as mutation-observer whether we need it or not (some
   // subclasses currently do, other don't). This is because the code in
   // nsNodeUtils always notifies the first observer first, expecting the
   // first observer to be the document.
   slots->mMutationObservers.PrependElementUnlessExists(
       static_cast<nsIMutationObserver*>(this));
 
-  mOnloadBlocker = new nsOnloadBlocker();
+  mOnloadBlocker = new OnloadBlocker();
   mCSSLoader = new mozilla::css::Loader(this);
   // Assume we're not quirky, until we know otherwise
   mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
 
   mStyleImageLoader = new mozilla::css::ImageLoader(this);
 
   mNodeInfoManager = new nsNodeInfoManager();
   nsresult rv = mNodeInfoManager->Init(this);
@@ -2896,45 +2889,45 @@ static void IncrementExpandoGeneration(D
 }
 
 void Document::AddToNameTable(Element* aElement, nsAtom* aName) {
   MOZ_ASSERT(
       nsGenericHTMLElement::ShouldExposeNameAsHTMLDocumentProperty(aElement),
       "Only put elements that need to be exposed as document['name'] in "
       "the named table.");
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aName);
+  IdentifierMapEntry* entry = mIdentifierMap.PutEntry(aName);
 
   // Null for out-of-memory
   if (entry) {
     if (!entry->HasNameElement() &&
         !entry->HasIdElementExposedAsHTMLDocumentProperty()) {
       IncrementExpandoGeneration(*this);
     }
     entry->AddNameElement(this, aElement);
   }
 }
 
 void Document::RemoveFromNameTable(Element* aElement, nsAtom* aName) {
   // Speed up document teardown
   if (mIdentifierMap.Count() == 0) return;
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aName);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aName);
   if (!entry)  // Could be false if the element was anonymous, hence never added
     return;
 
   entry->RemoveNameElement(aElement);
   if (!entry->HasNameElement() &&
       !entry->HasIdElementExposedAsHTMLDocumentProperty()) {
     IncrementExpandoGeneration(*this);
   }
 }
 
 void Document::AddToIdTable(Element* aElement, nsAtom* aId) {
-  nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
+  IdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
 
   if (entry) { /* True except on OOM */
     if (nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(aElement) &&
         !entry->HasNameElement() &&
         !entry->HasIdElementExposedAsHTMLDocumentProperty()) {
       IncrementExpandoGeneration(*this);
     }
     entry->AddIdElement(aElement);
@@ -2944,17 +2937,17 @@ void Document::AddToIdTable(Element* aEl
 void Document::RemoveFromIdTable(Element* aElement, nsAtom* aId) {
   NS_ASSERTION(aId, "huhwhatnow?");
 
   // Speed up document teardown
   if (mIdentifierMap.Count() == 0) {
     return;
   }
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
   if (!entry)  // Can be null for XML elements with changing ids.
     return;
 
   entry->RemoveIdElement(aElement);
   if (nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(aElement) &&
       !entry->HasNameElement() &&
       !entry->HasIdElementExposedAsHTMLDocumentProperty()) {
     IncrementExpandoGeneration(*this);
@@ -4622,17 +4615,17 @@ void Document::BeginLoad() {
 void Document::MozSetImageElement(const nsAString& aImageElementId,
                                   Element* aElement) {
   if (aImageElementId.IsEmpty()) return;
 
   // Hold a script blocker while calling SetImageElement since that can call
   // out to id-observers
   nsAutoScriptBlocker scriptBlocker;
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aImageElementId);
+  IdentifierMapEntry* entry = mIdentifierMap.PutEntry(aImageElementId);
   if (entry) {
     entry->SetImageElement(aElement);
     if (entry->IsEmpty()) {
       mIdentifierMap.RemoveEntry(entry);
     }
   }
 }
 
@@ -6291,26 +6284,26 @@ void nsDOMAttributeMap::BlastSubtreeToPi
           if (iter.Done()) {
             break;
           }
           attr = iter.UserData();
         }
 
         BlastSubtreeToPieces(attr);
 
-        DebugOnly<nsresult> rv =
+        mozilla::DebugOnly<nsresult> rv =
             element->UnsetAttr(attr->NodeInfo()->NamespaceID(),
                                attr->NodeInfo()->NameAtom(), false);
 
         // XXX Should we abort here?
         NS_ASSERTION(NS_SUCCEEDED(rv), "Uh-oh, UnsetAttr shouldn't fail!");
       }
     }
 
-    if (ShadowRoot* shadow = element->GetShadowRoot()) {
+    if (mozilla::dom::ShadowRoot* shadow = element->GetShadowRoot()) {
       BlastSubtreeToPieces(shadow);
       element->UnattachShadow();
     }
   }
 
   while (aNode->HasChildren()) {
     nsIContent* node = aNode->GetFirstChild();
     BlastSubtreeToPieces(node);
--- a/dom/base/DocumentOrShadowRoot.cpp
+++ b/dom/base/DocumentOrShadowRoot.cpp
@@ -84,17 +84,17 @@ already_AddRefed<StyleSheet> DocumentOrS
 }
 
 Element* DocumentOrShadowRoot::GetElementById(const nsAString& aElementId) {
   if (MOZ_UNLIKELY(aElementId.IsEmpty())) {
     nsContentUtils::ReportEmptyGetElementByIdArg(AsNode().OwnerDoc());
     return nullptr;
   }
 
-  if (nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aElementId)) {
+  if (IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aElementId)) {
     if (Element* el = entry->GetIdElement()) {
       return el;
     }
   }
 
   return nullptr;
 }
 
@@ -389,46 +389,46 @@ Element* DocumentOrShadowRoot::AddIDTarg
                                                    void* aData,
                                                    bool aForImage) {
   nsDependentAtomString id(aID);
 
   if (!CheckGetElementByIdArg(id)) {
     return nullptr;
   }
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aID);
+  IdentifierMapEntry* entry = mIdentifierMap.PutEntry(aID);
   NS_ENSURE_TRUE(entry, nullptr);
 
   entry->AddContentChangeCallback(aObserver, aData, aForImage);
   return aForImage ? entry->GetImageIdElement() : entry->GetIdElement();
 }
 
 void DocumentOrShadowRoot::RemoveIDTargetObserver(nsAtom* aID,
                                                   IDTargetObserver aObserver,
                                                   void* aData, bool aForImage) {
   nsDependentAtomString id(aID);
 
   if (!CheckGetElementByIdArg(id)) {
     return;
   }
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aID);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aID);
   if (!entry) {
     return;
   }
 
   entry->RemoveContentChangeCallback(aObserver, aData, aForImage);
 }
 
 Element* DocumentOrShadowRoot::LookupImageElement(const nsAString& aId) {
   if (aId.IsEmpty()) {
     return nullptr;
   }
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
   return entry ? entry->GetImageIdElement() : nullptr;
 }
 
 void DocumentOrShadowRoot::ReportEmptyGetElementByIdArg() {
   nsContentUtils::ReportEmptyGetElementByIdArg(AsNode().OwnerDoc());
 }
 
 /**
--- a/dom/base/DocumentOrShadowRoot.h
+++ b/dom/base/DocumentOrShadowRoot.h
@@ -3,20 +3,20 @@
 /* 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_DocumentOrShadowRoot_h__
 #define mozilla_dom_DocumentOrShadowRoot_h__
 
 #include "mozilla/dom/NameSpaceConstants.h"
+#include "mozilla/IdentifierMapEntry.h"
 #include "nsClassHashtable.h"
 #include "nsContentListDeclarations.h"
 #include "nsTArray.h"
-#include "nsIdentifierMapEntry.h"
 
 class nsContentList;
 class nsCycleCollectionTraversalCallback;
 class nsINode;
 class nsINodeList;
 class nsIRadioVisitor;
 class nsWindowSizes;
 
@@ -221,31 +221,31 @@ class DocumentOrShadowRoot {
   /*
    * mIdentifierMap works as follows for IDs:
    * 1) Attribute changes affect the table immediately (removing and adding
    *    entries as needed).
    * 2) Removals from the DOM affect the table immediately
    * 3) Additions to the DOM always update existing entries for names, and add
    *    new ones for IDs.
    */
-  nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
+  nsTHashtable<IdentifierMapEntry> mIdentifierMap;
 
   nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
 
   nsINode& mAsNode;
   const Kind mKind;
 };
 
 inline const nsTArray<Element*>* DocumentOrShadowRoot::GetAllElementsForId(
     const nsAString& aElementId) const {
   if (aElementId.IsEmpty()) {
     return nullptr;
   }
 
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aElementId);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aElementId);
   return entry ? &entry->GetIdElements() : nullptr;
 }
 
 }  // namespace dom
 
 }  // namespace mozilla
 
 #endif
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -160,21 +160,21 @@
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIBrowser.h"
 
 #include "nsISpeculativeConnect.h"
 #include "nsIIOService.h"
 
 #include "DOMMatrix.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
-
 using mozilla::gfx::Matrix4x4;
 
+namespace mozilla {
+namespace dom {
+
 // Verify sizes of nodes. We use a template rather than a direct static
 // assert so that the error message actually displays the sizes.
 // On 32 bit systems the actual allocated size varies a bit between
 // OSes/compilers.
 //
 // We need different numbers on certain build types to deal with the owning
 // thread pointer that comes with the non-threadsafe refcount on
 // nsIContent.
@@ -200,23 +200,29 @@ using mozilla::gfx::Matrix4x4;
 ASSERT_NODE_SIZE(Element, 128, 80);
 ASSERT_NODE_SIZE(HTMLDivElement, 128, 80);
 ASSERT_NODE_SIZE(HTMLSpanElement, 128, 80);
 ASSERT_NODE_SIZE(Text, 120, 64);
 
 #undef ASSERT_NODE_SIZE
 #undef EXTRA_DOM_NODE_BYTES
 
+}  // namespace dom
+}  // namespace mozilla
+
 nsAtom* nsIContent::DoGetID() const {
   MOZ_ASSERT(HasID(), "Unexpected call");
   MOZ_ASSERT(IsElement(), "Only elements can have IDs");
 
   return AsElement()->GetParsedAttr(nsGkAtoms::id)->GetAtomValue();
 }
 
+namespace mozilla {
+namespace dom {
+
 const nsAttrValue* Element::GetSVGAnimatedClass() const {
   MOZ_ASSERT(MayHaveClass() && IsSVGElement(), "Unexpected call");
   return static_cast<const SVGElement*>(this)->GetAnimatedClassName();
 }
 
 NS_IMETHODIMP
 Element::QueryInterface(REFNSIID aIID, void** aInstancePtr) {
   if (aIID.Equals(NS_GET_IID(Element))) {
@@ -267,16 +273,19 @@ void Element::UpdateState(bool aNotify) 
       if (doc) {
         nsAutoScriptBlocker scriptBlocker;
         doc->ContentStateChanged(this, changedStates);
       }
     }
   }
 }
 
+}  // namespace dom
+}  // namespace mozilla
+
 void nsIContent::UpdateEditableState(bool aNotify) {
   // Guaranteed to be non-element content
   NS_ASSERTION(!IsElement(), "What happened here?");
   nsIContent* parent = GetParent();
 
   // Skip over unknown native anonymous content to avoid setting a flag we
   // can't clear later
   bool isUnknownNativeAnon = false;
@@ -296,16 +305,19 @@ void nsIContent::UpdateEditableState(boo
       }
     }
   }
 
   SetEditableFlag(parent && parent->HasFlag(NODE_IS_EDITABLE) &&
                   !isUnknownNativeAnon);
 }
 
+namespace mozilla {
+namespace dom {
+
 void Element::UpdateEditableState(bool aNotify) {
   nsIContent* parent = GetParent();
 
   SetEditableFlag(parent && parent->HasFlag(NODE_IS_EDITABLE));
   if (aNotify) {
     UpdateState(aNotify);
   } else {
     // Avoid calling UpdateState in this very common case, because
@@ -4370,8 +4382,11 @@ void Element::NoteAnimationOnlyDirtyForS
 void Element::NoteDescendantsNeedFramesForServo() {
   // Since lazy frame construction can be required for non-element nodes, this
   // Note() method operates on the parent of the frame-requiring content, unlike
   // the other Note() methods above (which operate directly on the element that
   // needs processing).
   NoteDirtyElement(this, NODE_DESCENDANTS_NEED_FRAMES);
   SetFlags(NODE_DESCENDANTS_NEED_FRAMES);
 }
+
+}  // namespace dom
+}  // namespace mozilla
rename from dom/base/nsIdentifierMapEntry.h
rename to dom/base/IdentifierMapEntry.h
--- a/dom/base/nsIdentifierMapEntry.h
+++ b/dom/base/IdentifierMapEntry.h
@@ -3,18 +3,18 @@
 /* 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/. */
 
 /*
  * Base class for all our document implementations.
  */
 
-#ifndef nsIdentifierMapEntry_h
-#define nsIdentifierMapEntry_h
+#ifndef mozilla_IdentifierMapEntry_h
+#define mozilla_IdentifierMapEntry_h
 
 #include "PLDHashTable.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
 #include "nsCOMPtr.h"
@@ -24,35 +24,36 @@
 #include "nsTHashtable.h"
 
 class nsIContent;
 class nsContentList;
 class nsBaseContentList;
 
 namespace mozilla {
 namespace dom {
+class Document;
 class Element;
 }
-}  // namespace mozilla
 
 /**
  * Right now our identifier map entries contain information for 'name'
  * and 'id' mappings of a given string. This is so that
  * nsHTMLDocument::ResolveName only has to do one hash lookup instead
  * of two. It's not clear whether this still matters for performance.
  *
  * We also store the document.all result list here. This is mainly so that
  * when all elements with the given ID are removed and we remove
- * the ID's nsIdentifierMapEntry, the document.all result is released too.
+ * the ID's IdentifierMapEntry, the document.all result is released too.
  * Perhaps the document.all results should have their own hashtable
  * in nsHTMLDocument.
  */
-class nsIdentifierMapEntry : public PLDHashEntryHdr {
-  typedef mozilla::dom::Element Element;
-  typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
+class IdentifierMapEntry : public PLDHashEntryHdr {
+  typedef dom::Document Document;
+  typedef dom::Element Element;
+  typedef net::ReferrerPolicy ReferrerPolicy;
 
   /**
    * @see Document::IDTargetObserver, this is just here to avoid include hell.
    */
   typedef bool (*IDTargetObserver)(Element* aOldElement, Element* aNewelement,
                                    void* aData);
 
  public:
@@ -67,20 +68,20 @@ class nsIdentifierMapEntry : public PLDH
 
     RefPtr<nsAtom> mAtom;
     const nsString mString;
   };
 
   typedef const AtomOrString& KeyType;
   typedef const AtomOrString* KeyTypePointer;
 
-  explicit nsIdentifierMapEntry(const AtomOrString& aKey);
-  explicit nsIdentifierMapEntry(const AtomOrString* aKey);
-  nsIdentifierMapEntry(nsIdentifierMapEntry&& aOther);
-  ~nsIdentifierMapEntry();
+  explicit IdentifierMapEntry(const AtomOrString& aKey);
+  explicit IdentifierMapEntry(const AtomOrString* aKey);
+  IdentifierMapEntry(IdentifierMapEntry&& aOther);
+  ~IdentifierMapEntry();
 
   nsString GetKeyAsString() const {
     if (mKey.mAtom) {
       return nsAtomString(mKey.mAtom);
     }
 
     return mKey.mString;
   }
@@ -99,18 +100,17 @@ class nsIdentifierMapEntry : public PLDH
     }
 
     return mKey.mString.Equals(aOtherKey->mString);
   }
 
   static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
 
   static PLDHashNumber HashKey(const KeyTypePointer aKey) {
-    return aKey->mAtom ? aKey->mAtom->hash()
-                       : mozilla::HashString(aKey->mString);
+    return aKey->mAtom ? aKey->mAtom->hash() : HashString(aKey->mString);
   }
 
   enum { ALLOW_MEMMOVE = false };
 
   void AddNameElement(nsINode* aDocument, Element* aElement);
   void RemoveNameElement(Element* aElement);
   bool IsEmpty();
   nsBaseContentList* GetNameContentList() { return mNameContentList; }
@@ -170,34 +170,36 @@ class nsIdentifierMapEntry : public PLDH
     KeyType GetKey() const { return mKey; }
     bool KeyEquals(KeyTypePointer aKey) const {
       return aKey->mCallback == mKey.mCallback && aKey->mData == mKey.mData &&
              aKey->mForImage == mKey.mForImage;
     }
 
     static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
     static PLDHashNumber HashKey(KeyTypePointer aKey) {
-      return mozilla::HashGeneric(aKey->mCallback, aKey->mData);
+      return HashGeneric(aKey->mCallback, aKey->mData);
     }
     enum { ALLOW_MEMMOVE = true };
 
     ChangeCallback mKey;
   };
 
-  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+  size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
 
  private:
-  nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) = delete;
-  nsIdentifierMapEntry& operator=(const nsIdentifierMapEntry& aOther) = delete;
+  IdentifierMapEntry(const IdentifierMapEntry& aOther) = delete;
+  IdentifierMapEntry& operator=(const IdentifierMapEntry& aOther) = delete;
 
   void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
                            bool aImageOnly = false);
 
   AtomOrString mKey;
   // empty if there are no elements with this ID.
   // The elements are stored as weak pointers.
   AutoTArray<Element*, 1> mIdContentList;
   RefPtr<nsBaseContentList> mNameContentList;
   nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
   RefPtr<Element> mImageElement;
 };
 
-#endif  // #ifndef nsIdentifierMapEntry_h
+}  // namespace mozilla
+
+#endif  // #ifndef mozilla_IdentifierMapEntry_h
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -11,16 +11,17 @@
 #include "nsContentUtils.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsWindowSizes.h"
 #include "nsXBLPrototypeBinding.h"
 #include "mozilla/dom/DirectionalityUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLSlotElement.h"
 #include "mozilla/EventDispatcher.h"
+#include "mozilla/IdentifierMapEntry.h"
 #include "mozilla/ServoStyleRuleMap.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/dom/StyleSheetList.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -425,24 +426,24 @@ void ShadowRoot::RemoveSheet(StyleSheet*
       mStyleRuleMap->SheetRemoved(*sheet);
     }
     Servo_AuthorStyles_RemoveStyleSheet(mServoStyles.get(), sheet);
     ApplicableRulesChanged();
   }
 }
 
 void ShadowRoot::AddToIdTable(Element* aElement, nsAtom* aId) {
-  nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
+  IdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
   if (entry) {
     entry->AddIdElement(aElement);
   }
 }
 
 void ShadowRoot::RemoveFromIdTable(Element* aElement, nsAtom* aId) {
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
   if (entry) {
     entry->RemoveIdElement(aElement);
     if (entry->IsEmpty()) {
       mIdentifierMap.RemoveEntry(entry);
     }
   }
 }
 
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -10,17 +10,16 @@
 #include "mozilla/dom/DocumentBinding.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/DocumentOrShadowRoot.h"
 #include "mozilla/dom/NameSpaceConstants.h"
 #include "mozilla/dom/ShadowRootBinding.h"
 #include "mozilla/ServoBindings.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsIdentifierMapEntry.h"
 #include "nsIRadioGroupContainer.h"
 #include "nsStubMutationObserver.h"
 #include "nsTHashtable.h"
 
 class nsAtom;
 class nsIContent;
 class nsXBLPrototypeBinding;
 
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -71,17 +71,16 @@ EXPORTS += [
     'nsGlobalWindow.h',  # Because binding headers include it.
     'nsGlobalWindowInner.h',  # Because binding headers include it.
     'nsGlobalWindowOuter.h',  # Because binding headers include it.
     'nsIAnimationObserver.h',
     'nsIContent.h',
     'nsIContentInlines.h',
     'nsIContentIterator.h',
     'nsIContentSerializer.h',
-    'nsIdentifierMapEntry.h',
     'nsIDocumentObserver.h',
     'nsIGlobalObject.h',
     'nsImageLoadingContent.h',
     'nsIMutationObserver.h',
     'nsINode.h',
     'nsINodeList.h',
     'nsIScriptContext.h',
     'nsIScriptGlobalObject.h',
@@ -124,16 +123,17 @@ if CONFIG['MOZ_WEBRTC']:
         'nsDOMDataChannel.h',
         'nsDOMDataChannelDeclarations.h',
     ]
 
 EXPORTS.mozilla += [
     'CORSMode.h',
     'FlushType.h',
     'FullscreenChange.h',
+    'IdentifierMapEntry.h',
     'RangeBoundary.h',
     'ScriptableContentIterator.h',
     'SelectionChangeEventDispatcher.h',
     'TextInputProcessor.h',
     'UseCounter.h',
 ]
 
 EXPORTS.mozilla.dom += [
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -74,16 +74,17 @@
 #include "nsIEffectiveTLDService.h"
 
 // AHMED 12-2
 #include "nsBidiUtils.h"
 
 #include "mozilla/dom/FallbackEncoding.h"
 #include "mozilla/Encoding.h"
 #include "mozilla/HTMLEditor.h"
+#include "mozilla/IdentifierMapEntry.h"
 #include "mozilla/LoadInfo.h"
 #include "nsIEditingSession.h"
 #include "nsNodeInfoManager.h"
 #include "nsIPlaintextEditor.h"
 #include "nsIEditorStyleSheets.h"
 #include "nsIInlineSpellChecker.h"
 #include "nsRange.h"
 #include "mozAutoDocUpdate.h"
@@ -1834,17 +1835,17 @@ void nsHTMLDocument::CaptureEvents() {
 
 void nsHTMLDocument::ReleaseEvents() {
   WarnOnceAbout(Document::eUseOfReleaseEvents);
 }
 
 bool nsHTMLDocument::ResolveName(JSContext* aCx, const nsAString& aName,
                                  JS::MutableHandle<JS::Value> aRetval,
                                  ErrorResult& aError) {
-  nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aName);
+  IdentifierMapEntry* entry = mIdentifierMap.GetEntry(aName);
   if (!entry) {
     return false;
   }
 
   nsBaseContentList* list = entry->GetNameContentList();
   uint32_t length = list ? list->Length() : 0;
 
   nsIContent* node;
@@ -1877,17 +1878,17 @@ bool nsHTMLDocument::ResolveName(JSConte
     return false;
   }
 
   return true;
 }
 
 void nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames) {
   for (auto iter = mIdentifierMap.Iter(); !iter.Done(); iter.Next()) {
-    nsIdentifierMapEntry* entry = iter.Get();
+    IdentifierMapEntry* entry = iter.Get();
     if (entry->HasNameElement() ||
         entry->HasIdElementExposedAsHTMLDocumentProperty()) {
       aNames.AppendElement(entry->GetKeyAsString());
     }
   }
 }
 
 //----------------------------
--- a/dom/xul/nsXULCommandDispatcher.h
+++ b/dom/xul/nsXULCommandDispatcher.h
@@ -46,17 +46,17 @@ class nsXULCommandDispatcher : public ns
  protected:
   virtual ~nsXULCommandDispatcher();
 
   already_AddRefed<nsPIWindowRoot> GetWindowRoot();
 
   mozilla::dom::Element* GetRootFocusedContentAndWindow(
       nsPIDOMWindowOuter** aWindow);
 
-  RefPtr<Document> mDocument;
+  RefPtr<mozilla::dom::Document> mDocument;
 
   class Updater {
    public:
     Updater(mozilla::dom::Element* aElement, const nsAString& aEvents,
             const nsAString& aTargets)
         : mElement(aElement),
           mEvents(aEvents),
           mTargets(aTargets),