Bug 1600362 - Cleanup IntersectionObserver. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 29 Nov 2019 20:39:36 +0000
changeset 504748 533f7fabb17b506db69ef1ac1c2f9fe327895f2c
parent 504747 97e1a1f7230ce2650804ac5a50efc7901a210e59
child 504749 e3d87330819774902687ba23d1a76b5f46daf26d
push id101932
push userealvarez@mozilla.com
push dateFri, 29 Nov 2019 21:17:33 +0000
treeherderautoland@533f7fabb17b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1600362
milestone72.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 1600362 - Cleanup IntersectionObserver. r=smaug Initially this was going to be a simple cleanup: Remove some useless namespaces here and there and so on, remove `using` statements from the header and so on. But unfortunately, DOMIntersectionObserver.h (which is included in Element.h, unnecessarily) ended up exposing `Element` unnamespaced to a lot of code, so I had to fix that. Differential Revision: https://phabricator.services.mozilla.com/D55316
accessible/android/AccessibleWrap.cpp
accessible/base/ARIAMap.h
accessible/base/TextAttrs.cpp
accessible/base/nsAccUtils.cpp
accessible/base/nsAccessibilityService.h
accessible/generic/Accessible.cpp
accessible/generic/HyperTextAccessible.cpp
accessible/xul/XULComboboxAccessible.cpp
accessible/xul/XULFormControlAccessible.cpp
accessible/xul/XULListboxAccessible.cpp
accessible/xul/XULMenuAccessible.cpp
accessible/xul/XULSelectControlAccessible.cpp
accessible/xul/XULSelectControlAccessible.h
docshell/base/BaseHistory.cpp
dom/animation/KeyframeEffect.h
dom/base/DOMIntersectionObserver.cpp
dom/base/DOMIntersectionObserver.h
dom/base/DOMQuad.cpp
dom/base/Document.cpp
dom/base/Document.h
dom/base/Element.h
dom/base/ElementInlines.h
dom/base/nsTreeSanitizer.h
dom/events/EventStateManager.h
dom/html/nsHTMLDocument.h
dom/media/MediaManager.cpp
dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp
dom/xul/XULBroadcastManager.cpp
dom/xul/nsXULSortService.cpp
editor/libeditor/EditorUtils.h
editor/libeditor/HTMLEditor.h
editor/libeditor/ManualNAC.h
layout/base/nsLayoutUtils.h
layout/forms/nsButtonFrameRenderer.cpp
layout/forms/nsCheckboxRadioFrame.cpp
layout/forms/nsComboboxControlFrame.h
layout/forms/nsTextControlFrame.h
layout/generic/ScrollbarActivity.cpp
layout/generic/ViewportFrame.cpp
layout/generic/nsCanvasFrame.h
layout/generic/nsGfxScrollFrame.h
layout/generic/nsIFrameInlines.h
layout/generic/nsPluginFrame.cpp
layout/mathml/nsMathMLmtableFrame.cpp
layout/painting/nsImageRenderer.cpp
layout/style/DocumentStyleRootIterator.cpp
layout/xul/nsResizerFrame.cpp
layout/xul/nsRootBoxFrame.cpp
layout/xul/nsScrollbarButtonFrame.cpp
layout/xul/nsScrollbarFrame.cpp
layout/xul/nsScrollbarFrame.h
layout/xul/nsSliderFrame.cpp
layout/xul/nsSplitterFrame.cpp
layout/xul/nsTextBoxFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
toolkit/components/autocomplete/nsAutoCompleteController.h
xpfe/appshell/AppWindow.cpp
xpfe/appshell/AppWindow.h
--- a/accessible/android/AccessibleWrap.cpp
+++ b/accessible/android/AccessibleWrap.cpp
@@ -857,17 +857,17 @@ bool AccessibleWrap::HandleLiveRegionEve
                                      atomic);
 
   Accessible* announcementTarget = this;
   nsAutoString announcement;
   if (atomic.EqualsIgnoreCase("true")) {
     Accessible* atomicAncestor = nullptr;
     for (Accessible* parent = announcementTarget; parent;
          parent = parent->Parent()) {
-      Element* element = parent->Elm();
+      dom::Element* element = parent->Elm();
       if (element &&
           element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_atomic,
                                nsGkAtoms::_true, eCaseMatters)) {
         atomicAncestor = parent;
         break;
       }
     }
 
--- a/accessible/base/ARIAMap.h
+++ b/accessible/base/ARIAMap.h
@@ -249,17 +249,17 @@ const nsRoleMapEntry* GetRoleMapFromInde
  *                  NO_ROLE_MAP_ENTRY_INDEX if none
  */
 uint8_t GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMap);
 
 /**
  * Return accessible state from ARIA universal states applied to the given
  * element.
  */
-uint64_t UniversalStatesFor(mozilla::dom::Element* aElement);
+uint64_t UniversalStatesFor(dom::Element* aElement);
 
 /**
  * Get the ARIA attribute characteristics for a given ARIA attribute.
  *
  * @param aAtom  ARIA attribute
  * @return       A bitflag representing the attribute characteristics
  *               (see above for possible bit masks, prefixed "ATTR_")
  */
@@ -272,17 +272,17 @@ bool HasDefinedARIAHidden(nsIContent* aC
 
 /**
  * Represents a simple enumerator for iterating through ARIA attributes
  * exposed as object attributes on a given accessible.
  */
 class AttrIterator {
  public:
   explicit AttrIterator(nsIContent* aContent)
-      : mElement(Element::FromNode(aContent)), mAttrIdx(0) {
+      : mElement(dom::Element::FromNode(aContent)), mAttrIdx(0) {
     mAttrCount = mElement ? mElement->GetAttrCount() : 0;
   }
 
   bool Next(nsAString& aAttrName, nsAString& aAttrValue);
 
  private:
   AttrIterator() = delete;
   AttrIterator(const AttrIterator&) = delete;
--- a/accessible/base/TextAttrs.cpp
+++ b/accessible/base/TextAttrs.cpp
@@ -258,17 +258,17 @@ void TextAttrsMgr::InvalidTextAttr::Expo
   }
 }
 
 bool TextAttrsMgr::InvalidTextAttr::GetValue(nsIContent* aElm,
                                              uint32_t* aValue) {
   nsIContent* elm = aElm;
   do {
     if (nsAccUtils::HasDefinedARIAToken(elm, nsGkAtoms::aria_invalid)) {
-      static Element::AttrValuesArray tokens[] = {
+      static dom::Element::AttrValuesArray tokens[] = {
           nsGkAtoms::_false, nsGkAtoms::grammar, nsGkAtoms::spelling, nullptr};
 
       int32_t idx = elm->AsElement()->FindAttrValueIn(
           kNameSpaceID_None, nsGkAtoms::aria_invalid, tokens, eCaseMatters);
       switch (idx) {
         case 0:
           *aValue = eFalse;
           return true;
--- a/accessible/base/nsAccUtils.cpp
+++ b/accessible/base/nsAccUtils.cpp
@@ -92,17 +92,17 @@ int32_t nsAccUtils::GetARIAOrDefaultLeve
   return GetDefaultLevel(aAccessible);
 }
 
 int32_t nsAccUtils::GetLevelForXULContainerItem(nsIContent* aContent) {
   nsCOMPtr<nsIDOMXULContainerItemElement> item =
       aContent->AsElement()->AsXULContainerItem();
   if (!item) return 0;
 
-  nsCOMPtr<Element> containerElement;
+  nsCOMPtr<dom::Element> containerElement;
   item->GetParentContainer(getter_AddRefs(containerElement));
   nsCOMPtr<nsIDOMXULContainerElement> container =
       containerElement ? containerElement->AsXULContainer() : nullptr;
   if (!container) return 0;
 
   // Get level of the item.
   int32_t level = -1;
   while (container) {
@@ -174,48 +174,48 @@ void nsAccUtils::SetLiveContainerAttribu
   }
 }
 
 bool nsAccUtils::HasDefinedARIAToken(nsIContent* aContent, nsAtom* aAtom) {
   NS_ASSERTION(aContent, "aContent is null in call to HasDefinedARIAToken!");
 
   if (!aContent->IsElement()) return false;
 
-  Element* element = aContent->AsElement();
+  dom::Element* element = aContent->AsElement();
   if (!element->HasAttr(kNameSpaceID_None, aAtom) ||
       element->AttrValueIs(kNameSpaceID_None, aAtom, nsGkAtoms::_empty,
                            eCaseMatters) ||
       element->AttrValueIs(kNameSpaceID_None, aAtom, nsGkAtoms::_undefined,
                            eCaseMatters)) {
     return false;
   }
   return true;
 }
 
 nsStaticAtom* nsAccUtils::GetARIAToken(dom::Element* aElement, nsAtom* aAttr) {
   if (!HasDefinedARIAToken(aElement, aAttr)) return nsGkAtoms::_empty;
 
-  static Element::AttrValuesArray tokens[] = {
+  static dom::Element::AttrValuesArray tokens[] = {
       nsGkAtoms::_false, nsGkAtoms::_true, nsGkAtoms::mixed, nullptr};
 
   int32_t idx =
       aElement->FindAttrValueIn(kNameSpaceID_None, aAttr, tokens, eCaseMatters);
   if (idx >= 0) return tokens[idx];
 
   return nullptr;
 }
 
 nsStaticAtom* nsAccUtils::NormalizeARIAToken(dom::Element* aElement,
                                              nsAtom* aAttr) {
   if (!HasDefinedARIAToken(aElement, aAttr)) {
     return nsGkAtoms::_empty;
   }
 
   if (aAttr == nsGkAtoms::aria_current) {
-    static Element::AttrValuesArray tokens[] = {
+    static dom::Element::AttrValuesArray tokens[] = {
         nsGkAtoms::page, nsGkAtoms::step, nsGkAtoms::location_,
         nsGkAtoms::date, nsGkAtoms::time, nsGkAtoms::_true,
         nullptr};
     int32_t idx = aElement->FindAttrValueIn(kNameSpaceID_None, aAttr, tokens,
                                             eCaseMatters);
     // If the token is present, return it, otherwise TRUE as per spec.
     return (idx >= 0) ? tokens[idx] : nsGkAtoms::_true;
   }
--- a/accessible/base/nsAccessibilityService.h
+++ b/accessible/base/nsAccessibilityService.h
@@ -25,16 +25,17 @@ class nsPluginFrame;
 class nsITreeView;
 
 namespace mozilla {
 
 class PresShell;
 
 namespace dom {
 class DOMStringList;
+class Element;
 }
 
 namespace a11y {
 
 class ApplicationAccessible;
 class xpcAccessibleApplication;
 
 /**
@@ -48,17 +49,18 @@ FocusManager* FocusMgr();
 SelectionManager* SelectionMgr();
 
 /**
  * Returns the application accessible.
  */
 ApplicationAccessible* ApplicationAcc();
 xpcAccessibleApplication* XPCApplicationAcc();
 
-typedef Accessible*(New_Accessible)(Element* aElement, Accessible* aContext);
+typedef Accessible*(New_Accessible)(mozilla::dom::Element* aElement,
+                                    Accessible* aContext);
 
 // These fields are not `nsStaticAtom* const` because MSVC doesn't like it.
 struct MarkupAttrInfo {
   nsStaticAtom* name;
   nsStaticAtom* value;
 
   nsStaticAtom* DOMAttrName;
   nsStaticAtom* DOMAttrValue;
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -742,18 +742,17 @@ void Accessible::TakeFocus() const {
       }
     }
   }
 
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm) {
     dom::AutoHandlingUserInputStatePusher inputStatePusher(true);
     // XXXbz: Can we actually have a non-element content here?
-    RefPtr<Element> element =
-        focusContent->IsElement() ? focusContent->AsElement() : nullptr;
+    RefPtr<dom::Element> element = dom::Element::FromNodeOrNull(focusContent);
     fm->SetFocus(element, 0);
   }
 }
 
 void Accessible::NameFromAssociatedXULLabel(DocAccessible* aDocument,
                                             nsIContent* aElm, nsString& aName) {
   Accessible* label = nullptr;
   XULLabelIterator iter(aDocument, aElm);
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -323,17 +323,17 @@ uint32_t HyperTextAccessible::TransformO
  * GetElementAsContentOf() returns a content representing an element which is
  * or includes aNode.
  *
  * XXX This method is enough to retrieve ::before or ::after pseudo element.
  *     So, if you want to use this for other purpose, you might need to check
  *     ancestors too.
  */
 static nsIContent* GetElementAsContentOf(nsINode* aNode) {
-  if (Element* element = Element::FromNode(aNode)) {
+  if (auto* element = dom::Element::FromNode(aNode)) {
     return element;
   }
   return aNode->GetParentElement();
 }
 
 bool HyperTextAccessible::OffsetsToDOMRange(int32_t aStartOffset,
                                             int32_t aEndOffset,
                                             nsRange* aRange) {
--- a/accessible/xul/XULComboboxAccessible.cpp
+++ b/accessible/xul/XULComboboxAccessible.cpp
@@ -55,17 +55,17 @@ uint64_t XULComboboxAccessible::NativeSt
 }
 
 void XULComboboxAccessible::Description(nsString& aDescription) {
   aDescription.Truncate();
   // Use description of currently focused option
   nsCOMPtr<nsIDOMXULMenuListElement> menuListElm = Elm()->AsXULMenuList();
   if (!menuListElm) return;
 
-  nsCOMPtr<Element> focusedOptionItem;
+  nsCOMPtr<dom::Element> focusedOptionItem;
   menuListElm->GetSelectedItem(getter_AddRefs(focusedOptionItem));
   if (focusedOptionItem && mDoc) {
     Accessible* focusedOptionAcc = mDoc->GetAccessible(focusedOptionItem);
     if (focusedOptionAcc) focusedOptionAcc->Description(aDescription);
   }
 }
 
 void XULComboboxAccessible::Value(nsString& aValue) const {
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -307,17 +307,17 @@ bool XULRadioGroupAccessible::IsActiveWi
 
 bool XULRadioGroupAccessible::AreItemsOperable() const { return true; }
 
 Accessible* XULRadioGroupAccessible::CurrentItem() const {
   if (!mSelectControl) {
     return nullptr;
   }
 
-  RefPtr<Element> currentItemElm;
+  RefPtr<dom::Element> currentItemElm;
   nsCOMPtr<nsIDOMXULRadioGroupElement> group =
       mSelectControl->AsXULRadioGroup();
   if (group) {
     group->GetFocusedItem(getter_AddRefs(currentItemElm));
   }
 
   if (currentItemElm) {
     DocAccessible* document = Document();
@@ -329,17 +329,17 @@ Accessible* XULRadioGroupAccessible::Cur
   return nullptr;
 }
 
 void XULRadioGroupAccessible::SetCurrentItem(const Accessible* aItem) {
   if (!mSelectControl) {
     return;
   }
 
-  nsCOMPtr<Element> itemElm = aItem->Elm();
+  nsCOMPtr<dom::Element> itemElm = aItem->Elm();
   nsCOMPtr<nsIDOMXULRadioGroupElement> group =
       mSelectControl->AsXULRadioGroup();
   if (group) {
     group->SetFocusedItem(itemElm);
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/xul/XULListboxAccessible.cpp
+++ b/accessible/xul/XULListboxAccessible.cpp
@@ -103,17 +103,17 @@ uint64_t XULListboxAccessible::NativeSta
 /**
  * Our value is the label of our ( first ) selected child.
  */
 void XULListboxAccessible::Value(nsString& aValue) const {
   aValue.Truncate();
 
   nsCOMPtr<nsIDOMXULSelectControlElement> select = Elm()->AsXULSelectControl();
   if (select) {
-    RefPtr<Element> element;
+    RefPtr<dom::Element> element;
     select->GetSelectedItem(getter_AddRefs(element));
 
     if (element) {
       nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem =
           element->AsXULSelectControlItem();
       if (selectedItem) {
         selectedItem->GetLabel(aValue);
       }
@@ -145,17 +145,17 @@ uint32_t XULListboxAccessible::RowCount(
   return itemCount;
 }
 
 Accessible* XULListboxAccessible::CellAt(uint32_t aRowIndex,
                                          uint32_t aColumnIndex) {
   nsCOMPtr<nsIDOMXULSelectControlElement> control = Elm()->AsXULSelectControl();
   NS_ENSURE_TRUE(control, nullptr);
 
-  RefPtr<Element> element;
+  RefPtr<dom::Element> element;
   control->GetItemAtIndex(aRowIndex, getter_AddRefs(element));
   if (!element) return nullptr;
 
   Accessible* row = mDoc->GetAccessible(element);
   NS_ENSURE_TRUE(row, nullptr);
 
   return row->GetChildAt(aColumnIndex);
 }
@@ -172,17 +172,17 @@ bool XULListboxAccessible::IsColSelected
 
   return selectedrowCount == static_cast<int32_t>(RowCount());
 }
 
 bool XULListboxAccessible::IsRowSelected(uint32_t aRowIdx) {
   nsCOMPtr<nsIDOMXULSelectControlElement> control = Elm()->AsXULSelectControl();
   NS_ASSERTION(control, "Doesn't implement nsIDOMXULSelectControlElement.");
 
-  RefPtr<Element> element;
+  RefPtr<dom::Element> element;
   nsresult rv = control->GetItemAtIndex(aRowIdx, getter_AddRefs(element));
   NS_ENSURE_SUCCESS(rv, false);
   if (!element) {
     return false;
   }
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
       element->AsXULSelectControlItem();
@@ -337,34 +337,34 @@ void XULListboxAccessible::SelectedRowIn
 }
 
 void XULListboxAccessible::SelectRow(uint32_t aRowIdx) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
       Elm()->AsXULMultiSelectControl();
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
-  RefPtr<Element> item;
+  RefPtr<dom::Element> item;
   control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
   if (!item) {
     return;
   }
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
       item->AsXULSelectControlItem();
   control->SelectItem(itemElm);
 }
 
 void XULListboxAccessible::UnselectRow(uint32_t aRowIdx) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
       Elm()->AsXULMultiSelectControl();
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
-  RefPtr<Element> item;
+  RefPtr<dom::Element> item;
   control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
   if (!item) {
     return;
   }
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
       item->AsXULSelectControlItem();
   control->RemoveItemFromSelection(itemElm);
@@ -443,17 +443,17 @@ XULListitemAccessible::~XULListitemAcces
 
 Accessible* XULListitemAccessible::GetListAccessible() const {
   if (IsDefunct()) return nullptr;
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
       Elm()->AsXULSelectControlItem();
   if (!listItem) return nullptr;
 
-  RefPtr<Element> listElement;
+  RefPtr<dom::Element> listElement;
   listItem->GetControl(getter_AddRefs(listElement));
   if (!listElement) return nullptr;
 
   return mDoc->GetAccessible(listElement);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListitemAccessible Accessible
--- a/accessible/xul/XULMenuAccessible.cpp
+++ b/accessible/xul/XULMenuAccessible.cpp
@@ -46,18 +46,18 @@ uint64_t XULMenuitemAccessible::NativeSt
     state |= states::HASPOPUP;
     if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::open))
       state |= states::EXPANDED;
     else
       state |= states::COLLAPSED;
   }
 
   // Checkable/checked?
-  static Element::AttrValuesArray strings[] = {nsGkAtoms::radio,
-                                               nsGkAtoms::checkbox, nullptr};
+  static dom::Element::AttrValuesArray strings[] = {
+      nsGkAtoms::radio, nsGkAtoms::checkbox, nullptr};
 
   if (mContent->AsElement()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type,
                                              strings, eCaseMatters) >= 0) {
     // Checkable?
     state |= states::CHECKABLE;
 
     // Checked?
     if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None,
@@ -176,17 +176,17 @@ KeyBinding XULMenuitemAccessible::Access
   return KeyBinding(accesskey[0], modifierKey);
 }
 
 KeyBinding XULMenuitemAccessible::KeyboardShortcut() const {
   nsAutoString keyElmId;
   mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::key, keyElmId);
   if (keyElmId.IsEmpty()) return KeyBinding();
 
-  Element* keyElm = mContent->OwnerDoc()->GetElementById(keyElmId);
+  dom::Element* keyElm = mContent->OwnerDoc()->GetElementById(keyElmId);
   if (!keyElm) return KeyBinding();
 
   uint32_t key = 0;
 
   nsAutoString keyStr;
   keyElm->GetAttr(kNameSpaceID_None, nsGkAtoms::key, keyStr);
   if (keyStr.IsEmpty()) {
     nsAutoString keyCodeStr;
--- a/accessible/xul/XULSelectControlAccessible.cpp
+++ b/accessible/xul/XULSelectControlAccessible.cpp
@@ -45,38 +45,38 @@ void XULSelectControlAccessible::Shutdow
 void XULSelectControlAccessible::SelectedItems(nsTArray<Accessible*>* aItems) {
   // For XUL multi-select control
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
       mSelectControl->AsXULMultiSelectControl();
   if (xulMultiSelect) {
     int32_t length = 0;
     xulMultiSelect->GetSelectedCount(&length);
     for (int32_t index = 0; index < length; index++) {
-      RefPtr<Element> element;
+      RefPtr<dom::Element> element;
       xulMultiSelect->MultiGetSelectedItem(index, getter_AddRefs(element));
       Accessible* item = mDoc->GetAccessible(element);
       if (item) aItems->AppendElement(item);
     }
   } else {  // Single select?
     nsCOMPtr<nsIDOMXULSelectControlElement> selectControl =
         mSelectControl->AsXULSelectControl();
-    RefPtr<Element> element;
+    RefPtr<dom::Element> element;
     selectControl->GetSelectedItem(getter_AddRefs(element));
     if (element) {
       Accessible* item = mDoc->GetAccessible(element);
       if (item) aItems->AppendElement(item);
     }
   }
 }
 
 Accessible* XULSelectControlAccessible::GetSelectedItem(uint32_t aIndex) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       mSelectControl->AsXULMultiSelectControl();
 
-  RefPtr<Element> element;
+  RefPtr<dom::Element> element;
   if (multiSelectControl) {
     multiSelectControl->MultiGetSelectedItem(aIndex, getter_AddRefs(element));
   } else if (aIndex == 0) {
     nsCOMPtr<nsIDOMXULSelectControlElement> selectControl =
         mSelectControl->AsXULSelectControl();
     if (selectControl) {
       selectControl->GetSelectedItem(getter_AddRefs(element));
     }
@@ -205,17 +205,17 @@ bool XULSelectControlAccessible::SelectA
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULSelectControlAccessible: Widgets
 
 Accessible* XULSelectControlAccessible::CurrentItem() const {
   if (!mSelectControl) return nullptr;
 
-  RefPtr<Element> currentItemElm;
+  RefPtr<dom::Element> currentItemElm;
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       mSelectControl->AsXULMultiSelectControl();
   if (multiSelectControl) {
     multiSelectControl->GetCurrentItem(getter_AddRefs(currentItemElm));
   } else {
     nsCOMPtr<nsIDOMXULSelectControlElement> selectControl =
         mSelectControl->AsXULSelectControl();
     if (selectControl) {
@@ -229,17 +229,17 @@ Accessible* XULSelectControlAccessible::
   }
 
   return nullptr;
 }
 
 void XULSelectControlAccessible::SetCurrentItem(const Accessible* aItem) {
   if (!mSelectControl) return;
 
-  nsCOMPtr<Element> itemElm = aItem->Elm();
+  nsCOMPtr<dom::Element> itemElm = aItem->Elm();
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       itemElm->AsXULMultiSelectControl();
   if (multiSelectControl) {
     multiSelectControl->SetCurrentItem(itemElm);
   } else {
     nsCOMPtr<nsIDOMXULSelectControlElement> selectControl =
         mSelectControl->AsXULSelectControl();
     if (selectControl) {
--- a/accessible/xul/XULSelectControlAccessible.h
+++ b/accessible/xul/XULSelectControlAccessible.h
@@ -34,15 +34,15 @@ class XULSelectControlAccessible : publi
   virtual bool SelectAll() override;
   virtual bool UnselectAll() override;
 
   // Widgets
   virtual Accessible* CurrentItem() const override;
   virtual void SetCurrentItem(const Accessible* aItem) override;
 
  protected:
-  RefPtr<Element> mSelectControl;
+  RefPtr<dom::Element> mSelectControl;
 };
 
 }  // namespace a11y
 }  // namespace mozilla
 
 #endif
--- a/docshell/base/BaseHistory.cpp
+++ b/docshell/base/BaseHistory.cpp
@@ -7,16 +7,17 @@
 #include "BaseHistory.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/Link.h"
 #include "mozilla/dom/Element.h"
 
 namespace mozilla {
 
 using mozilla::dom::Document;
+using mozilla::dom::Element;
 using mozilla::dom::Link;
 
 static Document* GetLinkDocument(const Link& aLink) {
   Element* element = aLink.GetElement();
   // Element can only be null for mock_Link.
   return element ? element->OwnerDoc() : nullptr;
 }
 
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -96,17 +96,17 @@ struct AnimationProperty {
   bool operator==(const AnimationProperty& aOther) const {
     return mProperty == aOther.mProperty && mSegments == aOther.mSegments;
   }
   bool operator!=(const AnimationProperty& aOther) const {
     return !(*this == aOther);
   }
 
   void SetPerformanceWarning(const AnimationPerformanceWarning& aWarning,
-                             const Element* aElement);
+                             const dom::Element* aElement);
 };
 
 struct ElementPropertyTransition;
 
 namespace dom {
 
 class Animation;
 class Document;
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -57,26 +57,24 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueuedEntries)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 already_AddRefed<DOMIntersectionObserver> DOMIntersectionObserver::Constructor(
-    const mozilla::dom::GlobalObject& aGlobal,
-    mozilla::dom::IntersectionCallback& aCb, mozilla::ErrorResult& aRv) {
+    const GlobalObject& aGlobal, dom::IntersectionCallback& aCb,
+    ErrorResult& aRv) {
   return Constructor(aGlobal, aCb, IntersectionObserverInit(), aRv);
 }
 
 already_AddRefed<DOMIntersectionObserver> DOMIntersectionObserver::Constructor(
-    const mozilla::dom::GlobalObject& aGlobal,
-    mozilla::dom::IntersectionCallback& aCb,
-    const mozilla::dom::IntersectionObserverInit& aOptions,
-    mozilla::ErrorResult& aRv) {
+    const GlobalObject& aGlobal, dom::IntersectionCallback& aCb,
+    const IntersectionObserverInit& aOptions, ErrorResult& aRv) {
   nsCOMPtr<nsPIDOMWindowInner> window =
       do_QueryInterface(aGlobal.GetAsSupports());
   if (!window) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   RefPtr<DOMIntersectionObserver> observer =
       new DOMIntersectionObserver(window.forget(), aCb);
@@ -85,17 +83,17 @@ already_AddRefed<DOMIntersectionObserver
 
   if (!observer->SetRootMargin(aOptions.mRootMargin)) {
     aRv.ThrowDOMException(NS_ERROR_DOM_SYNTAX_ERR,
                           "rootMargin must be specified in pixels or percent.");
     return nullptr;
   }
 
   if (aOptions.mThreshold.IsDoubleSequence()) {
-    const mozilla::dom::Sequence<double>& thresholds =
+    const Sequence<double>& thresholds =
         aOptions.mThreshold.GetAsDoubleSequence();
     observer->mThresholds.SetCapacity(thresholds.Length());
     for (const auto& thresh : thresholds) {
       if (thresh < 0.0 || thresh > 1.0) {
         aRv.ThrowTypeError<dom::MSG_THRESHOLD_RANGE_ERROR>();
         return nullptr;
       }
       observer->mThresholds.AppendElement(thresh);
@@ -112,17 +110,17 @@ already_AddRefed<DOMIntersectionObserver
 
   return observer.forget();
 }
 
 bool DOMIntersectionObserver::SetRootMargin(const nsAString& aString) {
   return Servo_IntersectionObserverRootMargin_Parse(&aString, &mRootMargin);
 }
 
-void DOMIntersectionObserver::GetRootMargin(mozilla::dom::DOMString& aRetVal) {
+void DOMIntersectionObserver::GetRootMargin(DOMString& aRetVal) {
   nsString& retVal = aRetVal;
   Servo_IntersectionObserverRootMargin_ToString(&mRootMargin, &retVal);
 }
 
 void DOMIntersectionObserver::GetThresholds(nsTArray<double>& aRetVal) {
   aRetVal = mThresholds;
 }
 
@@ -509,18 +507,17 @@ void DOMIntersectionObserver::QueueInter
       aIntersectionRatio);
   mQueuedEntries.AppendElement(entry.forget());
 }
 
 void DOMIntersectionObserver::Notify() {
   if (!mQueuedEntries.Length()) {
     return;
   }
-  mozilla::dom::Sequence<mozilla::OwningNonNull<DOMIntersectionObserverEntry>>
-      entries;
+  Sequence<OwningNonNull<DOMIntersectionObserverEntry>> entries;
   if (entries.SetCapacity(mQueuedEntries.Length(), mozilla::fallible)) {
     for (size_t i = 0; i < mQueuedEntries.Length(); ++i) {
       RefPtr<DOMIntersectionObserverEntry> next = mQueuedEntries[i];
       *entries.AppendElement(mozilla::fallible) = next;
     }
   }
   mQueuedEntries.Clear();
   RefPtr<dom::IntersectionCallback> callback(mCallback);
--- a/dom/base/DOMIntersectionObserver.h
+++ b/dom/base/DOMIntersectionObserver.h
@@ -7,19 +7,16 @@
 #ifndef DOMIntersectionObserver_h
 #define DOMIntersectionObserver_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/IntersectionObserverBinding.h"
 #include "mozilla/ServoStyleConsts.h"
 #include "nsTArray.h"
 
-using mozilla::dom::DOMRect;
-using mozilla::dom::Element;
-
 namespace mozilla {
 namespace dom {
 
 class DOMIntersectionObserver;
 
 class DOMIntersectionObserverEntry final : public nsISupports,
                                            public nsWrapperCache {
   ~DOMIntersectionObserverEntry() {}
@@ -39,33 +36,32 @@ class DOMIntersectionObserverEntry final
         mIsIntersecting(aIsIntersecting),
         mTarget(aTarget),
         mIntersectionRatio(aIntersectionRatio) {}
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMIntersectionObserverEntry)
 
   nsISupports* GetParentObject() const { return mOwner; }
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override {
-    return mozilla::dom::IntersectionObserverEntry_Binding::Wrap(aCx, this,
-                                                                 aGivenProto);
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override {
+    return IntersectionObserverEntry_Binding::Wrap(aCx, this, aGivenProto);
   }
 
-  DOMHighResTimeStamp Time() { return mTime; }
+  DOMHighResTimeStamp Time() const { return mTime; }
 
   DOMRect* GetRootBounds() { return mRootBounds; }
 
   DOMRect* BoundingClientRect() { return mBoundingClientRect; }
 
   DOMRect* IntersectionRect() { return mIntersectionRect; }
 
-  bool IsIntersecting() { return mIsIntersecting; }
+  bool IsIntersecting() const { return mIsIntersecting; }
 
-  double IntersectionRatio() { return mIntersectionRatio; }
+  double IntersectionRatio() const { return mIntersectionRatio; }
 
   Element* Target() { return mTarget; }
 
  protected:
   nsCOMPtr<nsISupports> mOwner;
   DOMHighResTimeStamp mTime;
   RefPtr<DOMRect> mRootBounds;
   RefPtr<DOMRect> mBoundingClientRect;
@@ -83,57 +79,51 @@ class DOMIntersectionObserverEntry final
   }
 
 class DOMIntersectionObserver final : public nsISupports,
                                       public nsWrapperCache {
   virtual ~DOMIntersectionObserver() { Disconnect(); }
 
  public:
   DOMIntersectionObserver(already_AddRefed<nsPIDOMWindowInner>&& aOwner,
-                          mozilla::dom::IntersectionCallback& aCb)
+                          dom::IntersectionCallback& aCb)
       : mOwner(aOwner),
         mDocument(mOwner->GetExtantDoc()),
         mCallback(&aCb),
         mConnected(false) {}
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMIntersectionObserver)
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_INTERSECTION_OBSERVER_IID)
 
   static already_AddRefed<DOMIntersectionObserver> Constructor(
-      const mozilla::dom::GlobalObject& aGlobal,
-      mozilla::dom::IntersectionCallback& aCb, mozilla::ErrorResult& aRv);
+      const GlobalObject&, dom::IntersectionCallback&, ErrorResult&);
   static already_AddRefed<DOMIntersectionObserver> Constructor(
-      const mozilla::dom::GlobalObject& aGlobal,
-      mozilla::dom::IntersectionCallback& aCb,
-      const mozilla::dom::IntersectionObserverInit& aOptions,
-      mozilla::ErrorResult& aRv);
+      const GlobalObject&, dom::IntersectionCallback&,
+      const IntersectionObserverInit&, ErrorResult&);
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override {
-    return mozilla::dom::IntersectionObserver_Binding::Wrap(aCx, this,
-                                                            aGivenProto);
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override {
+    return IntersectionObserver_Binding::Wrap(aCx, this, aGivenProto);
   }
 
   nsISupports* GetParentObject() const { return mOwner; }
 
   Element* GetRoot() const { return mRoot; }
 
-  void GetRootMargin(mozilla::dom::DOMString& aRetVal);
+  void GetRootMargin(DOMString& aRetVal);
   void GetThresholds(nsTArray<double>& aRetVal);
   void Observe(Element& aTarget);
   void Unobserve(Element& aTarget);
 
   void UnlinkTarget(Element& aTarget);
   void Disconnect();
 
   void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal);
 
-  mozilla::dom::IntersectionCallback* IntersectionCallback() {
-    return mCallback;
-  }
+  dom::IntersectionCallback* IntersectionCallback() { return mCallback; }
 
   bool SetRootMargin(const nsAString& aString);
 
   void Update(Document* aDocument, DOMHighResTimeStamp time);
   MOZ_CAN_RUN_SCRIPT void Notify();
 
  protected:
   void Connect();
@@ -141,17 +131,17 @@ class DOMIntersectionObserver final : pu
                                       DOMHighResTimeStamp time,
                                       const Maybe<nsRect>& aRootRect,
                                       const nsRect& aTargetRect,
                                       const Maybe<nsRect>& aIntersectionRect,
                                       double aIntersectionRatio);
 
   nsCOMPtr<nsPIDOMWindowInner> mOwner;
   RefPtr<Document> mDocument;
-  RefPtr<mozilla::dom::IntersectionCallback> mCallback;
+  RefPtr<dom::IntersectionCallback> mCallback;
   RefPtr<Element> mRoot;
   StyleRect<LengthPercentage> mRootMargin;
   nsTArray<double> mThresholds;
 
   // Holds raw pointers which are explicitly cleared by UnlinkTarget().
   nsTArray<Element*> mObservationTargets;
 
   nsTArray<RefPtr<DOMIntersectionObserverEntry>> mQueuedEntries;
--- a/dom/base/DOMQuad.cpp
+++ b/dom/base/DOMQuad.cpp
@@ -4,16 +4,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 "mozilla/dom/DOMQuad.h"
 
 #include "mozilla/dom/DOMQuadBinding.h"
 #include "mozilla/dom/DOMPoint.h"
 #include "mozilla/dom/DOMRect.h"
+#include "mozilla/dom/DOMRectBinding.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMQuad, mParent, mPoints[0], mPoints[1],
                                       mPoints[2], mPoints[3])
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -92,16 +92,17 @@
 #include "mozilla/FullscreenChange.h"
 #include "mozilla/PendingAnimationTracker.h"
 
 #include "mozilla/dom/Attr.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/CSPDictionariesBinding.h"
+#include "mozilla/dom/DOMIntersectionObserver.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/FeaturePolicy.h"
 #include "mozilla/dom/FeaturePolicyUtils.h"
 #include "mozilla/dom/FramingChecker.h"
 #include "mozilla/dom/HTMLAllCollection.h"
 #include "mozilla/dom/HTMLMetaElement.h"
 #include "mozilla/dom/HTMLSharedElement.h"
@@ -1402,18 +1403,17 @@ static bool IsAboutErrorPage(nsGlobalWin
   return aboutSpec.EqualsASCII(aSpec);
 }
 
 bool Document::CallerIsTrustedAboutNetError(JSContext* aCx, JSObject* aObject) {
   nsGlobalWindowInner* win = xpc::WindowOrNull(aObject);
   return IsAboutErrorPage(win, "neterror");
 }
 
-void Document::GetNetErrorInfo(mozilla::dom::NetErrorInfo& aInfo,
-                               ErrorResult& aRv) {
+void Document::GetNetErrorInfo(NetErrorInfo& aInfo, ErrorResult& aRv) {
   nsCOMPtr<nsISupports> info;
   nsCOMPtr<nsITransportSecurityInfo> tsi;
   nsresult rv = NS_OK;
   if (NS_WARN_IF(!mFailedChannel)) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
@@ -1438,18 +1438,18 @@ void Document::GetNetErrorInfo(mozilla::
 }
 
 bool Document::CallerIsTrustedAboutCertError(JSContext* aCx,
                                              JSObject* aObject) {
   nsGlobalWindowInner* win = xpc::WindowOrNull(aObject);
   return IsAboutErrorPage(win, "certerror");
 }
 
-void Document::GetFailedCertSecurityInfo(
-    mozilla::dom::FailedCertSecurityInfo& aInfo, ErrorResult& aRv) {
+void Document::GetFailedCertSecurityInfo(FailedCertSecurityInfo& aInfo,
+                                         ErrorResult& aRv) {
   nsCOMPtr<nsISupports> info;
   nsCOMPtr<nsITransportSecurityInfo> tsi;
   nsresult rv = NS_OK;
   if (NS_WARN_IF(!mFailedChannel)) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
@@ -1591,23 +1591,23 @@ void Document::GetFailedCertSecurityInfo
       return;
     }
 
     certArray.AppendElement(
         0);  // Append null terminator, required by nsC*String.
     nsDependentCString derString(reinterpret_cast<char*>(certArray.Elements()),
                                  certArray.Length() - 1);
     nsAutoCString der64;
-    rv = mozilla::Base64Encode(derString, der64);
+    rv = Base64Encode(derString, der64);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       aRv.Throw(rv);
       return;
     }
     if (!certChainStrings.AppendElement(NS_ConvertUTF8toUTF16(der64),
-                                        mozilla::fallible)) {
+                                        fallible)) {
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
   }
 
   aInfo.mIssuerCommonName.Assign(issuerCommonName);
   aInfo.mCertValidityRangeNotAfter = DOMTimeStamp(notAfter / PR_USEC_PER_MSEC);
   aInfo.mCertValidityRangeNotBefore =
@@ -1636,21 +1636,21 @@ void Document::GetFailedCertSecurityInfo
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(rv);
     return;
   }
 
   bool isPrivateBrowsing = nsContentUtils::IsInPrivateBrowsing(this);
   uint32_t flags =
       isPrivateBrowsing ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
-  mozilla::OriginAttributes attrs;
+  OriginAttributes attrs;
   attrs = nsContentUtils::GetOriginAttributes(this);
   nsCOMPtr<nsIURI> aURI;
   mFailedChannel->GetURI(getter_AddRefs(aURI));
-  mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
+  ContentChild* cc = ContentChild::GetSingleton();
   mozilla::ipc::URIParams uri;
   SerializeURI(aURI, uri);
   cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, uri, flags, attrs,
                       &aInfo.mHasHSTS);
   cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, uri, flags, attrs,
                       &aInfo.mHasHPKP);
 }
 
@@ -1855,17 +1855,17 @@ Document::~Document() {
 
 NS_INTERFACE_TABLE_HEAD(Document)
   NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
   NS_INTERFACE_TABLE_BEGIN
     NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(Document, nsISupports, nsINode)
     NS_INTERFACE_TABLE_ENTRY(Document, nsINode)
     NS_INTERFACE_TABLE_ENTRY(Document, Document)
     NS_INTERFACE_TABLE_ENTRY(Document, nsIScriptObjectPrincipal)
-    NS_INTERFACE_TABLE_ENTRY(Document, mozilla::dom::EventTarget)
+    NS_INTERFACE_TABLE_ENTRY(Document, EventTarget)
     NS_INTERFACE_TABLE_ENTRY(Document, nsISupportsWeakReference)
     NS_INTERFACE_TABLE_ENTRY(Document, nsIRadioGroupContainer)
     NS_INTERFACE_TABLE_ENTRY(Document, nsIMutationObserver)
     NS_INTERFACE_TABLE_ENTRY(Document, nsIApplicationCacheContainer)
   NS_INTERFACE_TABLE_END
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(Document)
 NS_INTERFACE_MAP_END
 
@@ -2174,21 +2174,21 @@ 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
   // MutationObservers always notifies the first observer first, expecting the
   // first observer to be the document.
   slots->mMutationObservers.PrependElementUnlessExists(
       static_cast<nsIMutationObserver*>(this));
 
   mOnloadBlocker = new OnloadBlocker();
-  mCSSLoader = new mozilla::css::Loader(this);
+  mCSSLoader = new css::Loader(this);
   // Assume we're not quirky, until we know otherwise
   mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
 
-  mStyleImageLoader = new mozilla::css::ImageLoader(this);
+  mStyleImageLoader = new css::ImageLoader(this);
 
   mNodeInfoManager = new nsNodeInfoManager();
   nsresult rv = mNodeInfoManager->Init(this);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // mNodeInfo keeps NodeInfoManager alive!
   mNodeInfo = mNodeInfoManager->GetDocumentNodeInfo();
   NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_OUT_OF_MEMORY);
@@ -2206,17 +2206,17 @@ nsresult Document::Init() {
   NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
   mScopeObject = do_GetWeakReference(global);
   MOZ_ASSERT(mScopeObject);
 
   mScriptLoader = new dom::ScriptLoader(this);
 
   // we need to create a policy here so getting the policy within
   // ::Policy() can *always* return a non null policy
-  mFeaturePolicy = new mozilla::dom::FeaturePolicy(this);
+  mFeaturePolicy = new dom::FeaturePolicy(this);
   mFeaturePolicy->SetDefaultOrigin(NodePrincipal());
 
   mStyleSet = MakeUnique<ServoStyleSet>(*this);
 
   mozilla::HoldJSObjects(this);
 
   return NS_OK;
 }
@@ -2387,17 +2387,17 @@ void Document::ResetToURI(nsIURI* aURI, 
 
     // XXXbz what does "just fine" mean exactly?  And given that there
     // is no nsDocShell::SetDocument, what is this talking about?
 
     if (IsContentDocument()) {
       // Inform the associated request context about this load start so
       // any of its internal load progress flags gets reset.
       nsCOMPtr<nsIRequestContextService> rcsvc =
-          mozilla::net::RequestContextService::GetOrCreate();
+          net::RequestContextService::GetOrCreate();
       if (rcsvc) {
         nsCOMPtr<nsIRequestContext> rc;
         rcsvc->GetRequestContextFromLoadGroup(aLoadGroup, getter_AddRefs(rc));
         if (rc) {
           rc->BeginLoad();
         }
       }
     }
@@ -3250,33 +3250,32 @@ nsresult Document::InitCSP(nsIChannel* a
     principal = NullPrincipal::CreateWithInheritedAttributes(principal);
     SetPrincipals(principal, principal);
   }
 
   ApplySettingsFromCSP(false);
   return NS_OK;
 }
 
-already_AddRefed<mozilla::dom::FeaturePolicy>
-Document::GetParentFeaturePolicy() {
+already_AddRefed<dom::FeaturePolicy> Document::GetParentFeaturePolicy() {
   if (!mDocumentContainer) {
     return nullptr;
   }
 
   nsPIDOMWindowOuter* containerWindow = mDocumentContainer->GetWindow();
   if (!containerWindow) {
     return nullptr;
   }
 
   BrowsingContext* context = containerWindow->GetBrowsingContext();
   if (!context) {
     return nullptr;
   }
 
-  RefPtr<mozilla::dom::FeaturePolicy> parentPolicy;
+  RefPtr<dom::FeaturePolicy> parentPolicy;
   if (context->IsContentSubframe() && !context->GetParent()->IsInProcess()) {
     // We are in cross process, so try to get feature policy from
     // container's BrowsingContext
     parentPolicy = context->GetFeaturePolicy();
     return parentPolicy.forget();
   }
 
   nsCOMPtr<nsINode> node = containerWindow->GetFrameElementInternal();
@@ -15343,18 +15342,17 @@ already_AddRefed<mozilla::dom::Promise> 
     outer = nsGlobalWindowOuter::Cast(inner->GetOuterWindow());
     promise->MaybeResolve(outer->HasStorageAccess());
   } else {
     promise->MaybeRejectWithUndefined();
   }
   return promise.forget();
 }
 
-already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
-    mozilla::ErrorResult& aRv) {
+already_AddRefed<Promise> Document::RequestStorageAccess(ErrorResult& aRv) {
   nsIGlobalObject* global = GetScopeObject();
   if (!global) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;
   }
 
   // Propagate user input event handling to the resolve handler
   RefPtr<Promise> promise =
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -5331,17 +5331,17 @@ class Document : public nsINode,
   uint32_t mIgnoreOpensDuringUnloadCounter;
 
   nsCOMPtr<nsIDOMXULCommandDispatcher>
       mCommandDispatcher;  // [OWNER] of the focus tracker
 
   RefPtr<XULBroadcastManager> mXULBroadcastManager;
   RefPtr<XULPersist> mXULPersist;
 
-  RefPtr<mozilla::dom::HTMLAllCollection> mAll;
+  RefPtr<HTMLAllCollection> mAll;
 
   // document lightweight theme for use with :-moz-lwtheme,
   // :-moz-lwtheme-brighttext and :-moz-lwtheme-darktext
   DocumentTheme mDocLWTheme;
 
   // Pres shell resolution saved before entering fullscreen mode.
   float mSavedResolution;
 
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -9,17 +9,16 @@
  * of DOM Core's Element, implements nsIContent, provides
  * utility methods for subclasses, and so forth.
  */
 
 #ifndef mozilla_dom_Element_h__
 #define mozilla_dom_Element_h__
 
 #include "AttrArray.h"
-#include "DOMIntersectionObserver.h"
 #include "nsAttrValue.h"
 #include "nsAttrValueInlines.h"
 #include "nsChangeHint.h"
 #include "nsContentUtils.h"
 #include "nsDOMAttributeMap.h"
 #include "nsINodeList.h"
 #include "nsIScrollableFrame.h"
 #include "nsPresContext.h"
--- a/dom/base/ElementInlines.h
+++ b/dom/base/ElementInlines.h
@@ -21,29 +21,28 @@ inline void Element::RegisterActivityObs
 
 inline void Element::UnregisterActivityObserver() {
   OwnerDoc()->UnregisterActivityObserver(this);
 }
 
 }  // namespace dom
 }  // namespace mozilla
 
-inline Element* nsINode::GetFlattenedTreeParentElement() const {
+inline mozilla::dom::Element* nsINode::GetFlattenedTreeParentElement() const {
   nsINode* parentNode = GetFlattenedTreeParentNode();
   if
     MOZ_LIKELY(parentNode && parentNode->IsElement()) {
       return parentNode->AsElement();
     }
 
   return nullptr;
 }
 
-inline Element* nsINode::GetFlattenedTreeParentElementForStyle() const {
+inline mozilla::dom::Element* nsINode::GetFlattenedTreeParentElementForStyle()
+    const {
   nsINode* parentNode = GetFlattenedTreeParentNodeForStyle();
-  if
-    MOZ_LIKELY(parentNode && parentNode->IsElement()) {
-      return parentNode->AsElement();
-    }
-
+  if (MOZ_LIKELY(parentNode && parentNode->IsElement())) {
+    return parentNode->AsElement();
+  }
   return nullptr;
 }
 
 #endif  // mozilla_dom_ElementInlines_h
--- a/dom/base/nsTreeSanitizer.h
+++ b/dom/base/nsTreeSanitizer.h
@@ -204,17 +204,18 @@ class MOZ_STACK_CLASS nsTreeSanitizer {
    *
    * @param aMessage   the basic message to log.
    * @param aDocument  the base document we're modifying
    *                   (used for the error message)
    * @param aElement   optional, the element being removed or modified.
    * @param aAttribute optional, the attribute being removed or modified.
    */
   void LogMessage(const char* aMessage, mozilla::dom::Document* aDoc,
-                  Element* aElement = nullptr, nsAtom* aAttr = nullptr);
+                  mozilla::dom::Element* aElement = nullptr,
+                  nsAtom* aAttr = nullptr);
 
   /**
    * The whitelist of HTML elements.
    */
   static AtomsTable* sElementsHTML;
 
   /**
    * The whitelist of non-presentational HTML attributes.
--- a/dom/events/EventStateManager.h
+++ b/dom/events/EventStateManager.h
@@ -245,17 +245,17 @@ class EventStateManager : public nsSuppo
 
   /**
    * Checks if the current mouse over element matches the given
    * Element (which has a remote frame), and if so, notifies
    * the BrowserParent of the mouse enter.
    * Called when we reconstruct the BrowserParent and need to
    * recompute state on the new object.
    */
-  void RecomputeMouseEnterStateForRemoteFrame(Element& aElement);
+  void RecomputeMouseEnterStateForRemoteFrame(dom::Element& aElement);
 
   nsPresContext* GetPresContext() { return mPresContext; }
 
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EventStateManager, nsIObserver)
 
   static dom::Document* sMouseOverDocument;
 
   static EventStateManager* GetActiveEventStateManager() { return sActiveESM; }
--- a/dom/html/nsHTMLDocument.h
+++ b/dom/html/nsHTMLDocument.h
@@ -60,17 +60,17 @@ class nsHTMLDocument : public mozilla::d
                                      nsIStreamListener** aDocListener,
                                      bool aReset = true,
                                      nsIContentSink* aSink = nullptr) override;
 
  protected:
   virtual bool UseWidthDeviceWidthFallbackViewport() const override;
 
  public:
-  virtual Element* GetUnfocusedKeyEventTarget() override;
+  mozilla::dom::Element* GetUnfocusedKeyEventTarget() override;
 
   nsContentList* GetExistingForms() const { return mForms; }
 
   // Returns whether an object was found for aName.
   bool ResolveName(JSContext* aCx, const nsAString& aName,
                    JS::MutableHandle<JS::Value> aRetval,
                    mozilla::ErrorResult& aError);
 
@@ -119,18 +119,19 @@ class nsHTMLDocument : public mozilla::d
     }
   }
   void GetSupportedNames(nsTArray<nsString>& aNames);
   // We're picking up GetLocation from Document
   already_AddRefed<mozilla::dom::Location> GetLocation() const {
     return Document::GetLocation();
   }
 
-  static bool MatchFormControls(Element* aElement, int32_t aNamespaceID,
-                                nsAtom* aAtom, void* aData);
+  static bool MatchFormControls(mozilla::dom::Element* aElement,
+                                int32_t aNamespaceID, nsAtom* aAtom,
+                                void* aData);
 
   void GetFormsAndFormControls(nsContentList** aFormList,
                                nsContentList** aFormControlList);
 
  protected:
   ~nsHTMLDocument();
 
   nsresult GetBodySize(int32_t* aWidth, int32_t* aHeight);
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -168,16 +168,17 @@ LazyLogModule gMediaManagerLog("MediaMan
 class LocalTrackSource;
 
 using dom::CallerType;
 using dom::ConstrainDOMStringParameters;
 using dom::ConstrainDoubleRange;
 using dom::ConstrainLongRange;
 using dom::DisplayMediaStreamConstraints;
 using dom::Document;
+using dom::Element;
 using dom::FeaturePolicyUtils;
 using dom::File;
 using dom::GetUserMediaRequest;
 using dom::MediaDeviceKind;
 using dom::MediaDevices;
 using dom::MediaSourceEnum;
 using dom::MediaStreamConstraints;
 using dom::MediaStreamError;
--- a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp
+++ b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp
@@ -244,17 +244,17 @@ class ResourceReader final : public nsIW
   // StartPersistence calls.
   size_t mOutstandingDocuments;
   // Collects the status parameters to DocumentDone calls.
   nsresult mEndStatus;
 
   nsresult OnWalkURI(const nsACString& aURISpec,
                      nsContentPolicyType aContentPolicyType);
   nsresult OnWalkURI(nsIURI* aURI, nsContentPolicyType aContentPolicyType);
-  nsresult OnWalkAttribute(Element* aElement,
+  nsresult OnWalkAttribute(dom::Element* aElement,
                            nsContentPolicyType aContentPolicyType,
                            const char* aAttribute,
                            const char* aNamespaceURI = "");
   nsresult OnWalkSubframe(nsINode* aNode);
 
   ~ResourceReader();
 
   using IWBP = nsIWebBrowserPersist;
@@ -349,17 +349,17 @@ nsresult ResourceReader::OnWalkURI(const
                  mCurrentBaseURI);
   if (NS_FAILED(rv)) {
     // We don't want to break saving a page in case of a malformed URI.
     return NS_OK;
   }
   return OnWalkURI(uri, aContentPolicyType);
 }
 
-static void ExtractAttribute(Element* aElement, const char* aAttribute,
+static void ExtractAttribute(dom::Element* aElement, const char* aAttribute,
                              const char* aNamespaceURI, nsCString& aValue) {
   // Find the named URI attribute on the (element) node and store
   // a reference to the URI that maps onto a local file name
 
   RefPtr<nsDOMAttributeMap> attrMap = aElement->Attributes();
 
   NS_ConvertASCIItoUTF16 namespaceURI(aNamespaceURI);
   NS_ConvertASCIItoUTF16 attribute(aAttribute);
@@ -368,17 +368,17 @@ static void ExtractAttribute(Element* aE
     nsAutoString value;
     attr->GetValue(value);
     CopyUTF16toUTF8(value, aValue);
   } else {
     aValue.Truncate();
   }
 }
 
-nsresult ResourceReader::OnWalkAttribute(Element* aElement,
+nsresult ResourceReader::OnWalkAttribute(dom::Element* aElement,
                                          nsContentPolicyType aContentPolicyType,
                                          const char* aAttribute,
                                          const char* aNamespaceURI) {
   nsAutoCString uriSpec;
   ExtractAttribute(aElement, aAttribute, aNamespaceURI, uriSpec);
   if (uriSpec.IsEmpty()) {
     return NS_OK;
   }
--- a/dom/xul/XULBroadcastManager.cpp
+++ b/dom/xul/XULBroadcastManager.cpp
@@ -13,17 +13,17 @@
 #include "nsXULElement.h"
 
 struct BroadcastListener {
   nsWeakPtr mListener;
   RefPtr<nsAtom> mAttribute;
 };
 
 struct BroadcasterMapEntry : public PLDHashEntryHdr {
-  Element* mBroadcaster;  // [WEAK]
+  mozilla::dom::Element* mBroadcaster;  // [WEAK]
   nsTArray<BroadcastListener*>
       mListeners;  // [OWNING] of BroadcastListener objects
 };
 
 struct nsAttrNameInfo {
   nsAttrNameInfo(int32_t aNamespaceID, nsAtom* aName, nsAtom* aPrefix)
       : mNamespaceID(aNamespaceID), mName(aName), mPrefix(aPrefix) {}
   nsAttrNameInfo(const nsAttrNameInfo& aOther)
--- a/dom/xul/nsXULSortService.cpp
+++ b/dom/xul/nsXULSortService.cpp
@@ -20,16 +20,17 @@
 #include "nsXULSortService.h"
 #include "nsXULElement.h"
 #include "nsICollation.h"
 #include "nsTArray.h"
 #include "nsUnicharUtils.h"
 
 #include "mozilla/dom/Element.h"
 
+using mozilla::dom::Element;
 const unsigned long SORT_COMPARECASE = 0x0001;
 const unsigned long SORT_INTEGER = 0x0100;
 
 enum nsSortState_direction {
   nsSortState_descending,
   nsSortState_ascending,
   nsSortState_natural
 };
--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -533,37 +533,37 @@ class MOZ_STACK_CLASS SplitRangeOffFromN
 
   /**
    * GetLeftContent() returns new created node before the part of quarried out.
    * This may return nullptr if the method didn't split at start edge of
    * the node.
    */
   nsIContent* GetLeftContent() const { return mLeftContent; }
   dom::Element* GetLeftContentAsElement() const {
-    return Element::FromNodeOrNull(mLeftContent);
+    return dom::Element::FromNodeOrNull(mLeftContent);
   }
 
   /**
    * GetMiddleContent() returns new created node between left node and right
    * node.  I.e., this is quarried out from the node.  This may return nullptr
    * if the method unwrapped the middle node.
    */
   nsIContent* GetMiddleContent() const { return mMiddleContent; }
   dom::Element* GetMiddleContentAsElement() const {
-    return Element::FromNodeOrNull(mMiddleContent);
+    return dom::Element::FromNodeOrNull(mMiddleContent);
   }
 
   /**
    * GetRightContent() returns the right node after the part of quarried out.
    * This may return nullptr it the method didn't split at end edge of the
    * node.
    */
   nsIContent* GetRightContent() const { return mRightContent; }
   dom::Element* GetRightContentAsElement() const {
-    return Element::FromNodeOrNull(mRightContent);
+    return dom::Element::FromNodeOrNull(mRightContent);
   }
 
   SplitRangeOffFromNodeResult(nsIContent* aLeftContent,
                               nsIContent* aMiddleContent,
                               nsIContent* aRightContent)
       : mLeftContent(aLeftContent),
         mMiddleContent(aMiddleContent),
         mRightContent(aRightContent),
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -4571,17 +4571,17 @@ class MOZ_STACK_CLASS ParagraphStateAtSe
    *
    * @param aArrayOfNodes               [in/out] Found descendant format blocks
    *                                    and first inline node in each non-format
    *                                    block will be appended to this.
    * @param aNonFormatBlockElement      Must be a non-format block element.
    */
   static void AppendDescendantFormatNodesAndFirstInlineNode(
       nsTArray<OwningNonNull<nsINode>>& aArrayOfNodes,
-      Element& aNonFormatBlockElement);
+      mozilla::dom::Element& aNonFormatBlockElement);
 
   /**
    * CollectEditableFormatNodesInSelection() collects only editable nodes
    * around selection ranges (with
    * `HTMLEditor::CollectEditTargetNodesInExtendedSelectionRanges()`, see its
    * document for the detail).  If it includes list, list item or table
    * related elements, they will be replaced their children.
    */
--- a/editor/libeditor/ManualNAC.h
+++ b/editor/libeditor/ManualNAC.h
@@ -21,17 +21,18 @@ typedef AutoTArray<RefPtr<dom::Element>,
 /**
  * Smart pointer class to own "manual" Native Anonymous Content, and perform
  * the necessary registration and deregistration on the parent element.
  */
 class ManualNACPtr final {
  public:
   ManualNACPtr() {}
   MOZ_IMPLICIT ManualNACPtr(decltype(nullptr)) {}
-  explicit ManualNACPtr(already_AddRefed<Element> aNewNAC) : mPtr(aNewNAC) {
+  explicit ManualNACPtr(already_AddRefed<dom::Element> aNewNAC)
+      : mPtr(aNewNAC) {
     if (!mPtr) {
       return;
     }
 
     // Record the NAC on the element, so that AllChildrenIterator can find it.
     nsIContent* parentContent = mPtr->GetParent();
     auto nac = static_cast<ManualNACArray*>(
         parentContent->GetProperty(nsGkAtoms::manualNACProperty));
@@ -54,17 +55,17 @@ class ManualNACPtr final {
 
   ~ManualNACPtr() { Reset(); }
 
   void Reset() {
     if (!mPtr) {
       return;
     }
 
-    RefPtr<Element> ptr = mPtr.forget();
+    RefPtr<dom::Element> ptr = mPtr.forget();
     RemoveContentFromNACArray(ptr);
   }
 
   static void RemoveContentFromNACArray(nsIContent* aAnonymousContent) {
     nsIContent* parentContent = aAnonymousContent->GetParent();
     if (!parentContent) {
       NS_WARNING("Potentially leaking manual NAC");
       return;
@@ -80,22 +81,22 @@ class ManualNACPtr final {
       if (nac->IsEmpty()) {
         parentContent->DeleteProperty(nsGkAtoms::manualNACProperty);
       }
     }
 
     aAnonymousContent->UnbindFromTree();
   }
 
-  Element* get() const { return mPtr.get(); }
-  Element* operator->() const { return get(); }
-  operator Element*() const& { return get(); }
+  dom::Element* get() const { return mPtr.get(); }
+  dom::Element* operator->() const { return get(); }
+  operator dom::Element*() const& { return get(); }
 
  private:
-  RefPtr<Element> mPtr;
+  RefPtr<dom::Element> mPtr;
 };
 
 }  // namespace mozilla
 
 inline void ImplCycleCollectionUnlink(mozilla::ManualNACPtr& field) {
   field.Reset();
 }
 
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -3161,28 +3161,28 @@ class nsSetAttrRunnable : public mozilla
  public:
   nsSetAttrRunnable(mozilla::dom::Element* aElement, nsAtom* aAttrName,
                     const nsAString& aValue);
   nsSetAttrRunnable(mozilla::dom::Element* aElement, nsAtom* aAttrName,
                     int32_t aValue);
 
   NS_DECL_NSIRUNNABLE
 
-  RefPtr<Element> mElement;
+  RefPtr<mozilla::dom::Element> mElement;
   RefPtr<nsAtom> mAttrName;
   nsAutoString mValue;
 };
 
 class nsUnsetAttrRunnable : public mozilla::Runnable {
  public:
   nsUnsetAttrRunnable(mozilla::dom::Element* aElement, nsAtom* aAttrName);
 
   NS_DECL_NSIRUNNABLE
 
-  RefPtr<Element> mElement;
+  RefPtr<mozilla::dom::Element> mElement;
   RefPtr<nsAtom> mAttrName;
 };
 
 // This class allows you to easily set any pointer variable and ensure it's
 // set to nullptr when leaving its scope.
 template <typename T>
 class MOZ_RAII SetAndNullOnExit {
  public:
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -42,17 +42,17 @@ void nsButtonFrameRenderer::SetFrame(nsF
                                      nsPresContext* aPresContext) {
   mFrame = aFrame;
   ReResolveStyles(aPresContext);
 }
 
 nsIFrame* nsButtonFrameRenderer::GetFrame() { return mFrame; }
 
 void nsButtonFrameRenderer::SetDisabled(bool aDisabled, bool aNotify) {
-  Element* element = mFrame->GetContent()->AsElement();
+  dom::Element* element = mFrame->GetContent()->AsElement();
   if (aDisabled)
     element->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
                      aNotify);
   else
     element->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, aNotify);
 }
 
 bool nsButtonFrameRenderer::isDisabled() {
--- a/layout/forms/nsCheckboxRadioFrame.cpp
+++ b/layout/forms/nsCheckboxRadioFrame.cpp
@@ -12,16 +12,17 @@
 #include "mozilla/EventStateManager.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/PresShell.h"
 #include "nsDeviceContext.h"
 #include "nsIContent.h"
 #include "nsStyleConsts.h"
 
 using namespace mozilla;
+using mozilla::dom::Element;
 using mozilla::dom::HTMLInputElement;
 
 //#define FCF_NOISY
 
 nsCheckboxRadioFrame* NS_NewCheckboxRadioFrame(PresShell* aPresShell,
                                                ComputedStyle* aStyle) {
   return new (aPresShell)
       nsCheckboxRadioFrame(aStyle, aPresShell->GetPresContext());
--- a/layout/forms/nsComboboxControlFrame.h
+++ b/layout/forms/nsComboboxControlFrame.h
@@ -45,17 +45,18 @@ class DrawTarget;
 }  // namespace mozilla
 
 class nsComboboxControlFrame final : public nsBlockFrame,
                                      public nsIFormControlFrame,
                                      public nsIAnonymousContentCreator,
                                      public nsISelectControlFrame,
                                      public nsIRollupListener,
                                      public nsIStatefulFrame {
-  typedef mozilla::gfx::DrawTarget DrawTarget;
+  using DrawTarget = mozilla::gfx::DrawTarget;
+  using Element = mozilla::dom::Element;
 
  public:
   friend nsComboboxControlFrame* NS_NewComboboxControlFrame(
       mozilla::PresShell* aPresShell, ComputedStyle* aStyle,
       nsFrameState aFlags);
   friend class nsComboboxDisplayFrame;
 
   explicit nsComboboxControlFrame(ComputedStyle* aStyle,
--- a/layout/forms/nsTextControlFrame.h
+++ b/layout/forms/nsTextControlFrame.h
@@ -330,20 +330,20 @@ class nsTextControlFrame final : public 
   nsresult CreateRootNode();
   void CreatePlaceholderIfNeeded();
   void CreatePreviewIfNeeded();
   enum class AnonymousDivType {
     Root,
     Placeholder,
     Preview,
   };
-  already_AddRefed<Element> CreateEmptyAnonymousDiv(
-      AnonymousDivType aAnonymousDivType) const;
-  already_AddRefed<Element> CreateEmptyAnonymousDivWithTextNode(
-      AnonymousDivType aAnonymousDivType) const;
+  already_AddRefed<mozilla::dom::Element> CreateEmptyAnonymousDiv(
+      AnonymousDivType) const;
+  already_AddRefed<mozilla::dom::Element> CreateEmptyAnonymousDivWithTextNode(
+      AnonymousDivType) const;
 
   bool ShouldInitializeEagerly() const;
   void InitializeEagerlyIfNeeded();
 
   RefPtr<mozilla::dom::Element> mRootNode;
   RefPtr<mozilla::dom::Element> mPlaceholderDiv;
   RefPtr<mozilla::dom::Element> mPreviewDiv;
   RefPtr<nsAnonDivObserver> mMutationObserver;
--- a/layout/generic/ScrollbarActivity.cpp
+++ b/layout/generic/ScrollbarActivity.cpp
@@ -17,16 +17,18 @@
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace layout {
 
+using mozilla::dom::Element;
+
 NS_IMPL_ISUPPORTS(ScrollbarActivity, nsIDOMEventListener)
 
 static bool GetForceAlwaysVisiblePref() {
   static bool sForceAlwaysVisible;
   static bool sForceAlwaysVisiblePrefCached = false;
   if (!sForceAlwaysVisiblePrefCached) {
     Preferences::AddBoolVarCache(
         &sForceAlwaysVisible,
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -63,17 +63,17 @@ void ViewportFrame::BuildDisplayList(nsD
   }
 }
 
 #ifdef DEBUG
 /**
  * Returns whether we are going to put an element in the top layer for
  * fullscreen. This function should matches the CSS rule in ua.css.
  */
-static bool ShouldInTopLayerForFullscreen(Element* aElement) {
+static bool ShouldInTopLayerForFullscreen(dom::Element* aElement) {
   if (!aElement->GetParent()) {
     return false;
   }
   nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aElement);
   if (browserFrame && browserFrame->GetReallyIsBrowser()) {
     return false;
   }
   return true;
@@ -111,19 +111,19 @@ static void BuildDisplayListForTopLayerF
 
   nsDisplayList list;
   aFrame->BuildDisplayListForStackingContext(aBuilder, &list);
   aList->AppendToTop(&list);
 }
 
 void ViewportFrame::BuildDisplayListForTopLayer(nsDisplayListBuilder* aBuilder,
                                                 nsDisplayList* aList) {
-  nsTArray<Element*> fullscreenStack =
+  nsTArray<dom::Element*> fullscreenStack =
       PresContext()->Document()->GetFullscreenStack();
-  for (Element* elem : fullscreenStack) {
+  for (dom::Element* elem : fullscreenStack) {
     if (nsIFrame* frame = elem->GetPrimaryFrame()) {
       // There are two cases where an element in fullscreen is not in
       // the top layer:
       // 1. When building display list for purpose other than painting,
       //    it is possible that there is inconsistency between the style
       //    info and the content tree.
       // 2. This is an element which we are not going to put in the top
       //    layer for fullscreen. See ShouldInTopLayerForFullscreen().
@@ -155,17 +155,17 @@ void ViewportFrame::BuildDisplayListForT
         MOZ_ASSERT(backdropFrame);
         BuildDisplayListForTopLayerFrame(aBuilder, backdropFrame, aList);
       }
       BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
     }
   }
 
   if (nsCanvasFrame* canvasFrame = PresShell()->GetCanvasFrame()) {
-    if (Element* container = canvasFrame->GetCustomContentContainer()) {
+    if (dom::Element* container = canvasFrame->GetCustomContentContainer()) {
       if (nsIFrame* frame = container->GetPrimaryFrame()) {
         MOZ_ASSERT(frame->StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE,
                    "ua.css should ensure this");
         MOZ_ASSERT(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW);
         BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
       }
     }
   }
--- a/layout/generic/nsCanvasFrame.h
+++ b/layout/generic/nsCanvasFrame.h
@@ -29,16 +29,18 @@ class nsPopupSetFrame;
  * frame.
  * @note nsCanvasFrame keeps overflow container continuations of its child
  * frame in the main child list.
  */
 class nsCanvasFrame final : public nsContainerFrame,
                             public nsIScrollPositionListener,
                             public nsIAnonymousContentCreator,
                             public nsIPopupContainer {
+  using Element = mozilla::dom::Element;
+
  public:
   explicit nsCanvasFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
       : nsContainerFrame(aStyle, aPresContext, kClassID),
         mDoPaintFocus(false),
         mAddedScrollPositionListener(false),
         mPopupSetFrame(nullptr) {}
 
   NS_DECL_QUERYFRAME
@@ -74,19 +76,17 @@ class nsCanvasFrame final : public nsCon
   }
 
   // nsIAnonymousContentCreator
   virtual nsresult CreateAnonymousContent(
       nsTArray<ContentInfo>& aElements) override;
   virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
                                         uint32_t aFilter) override;
 
-  mozilla::dom::Element* GetCustomContentContainer() const {
-    return mCustomContentContainer;
-  }
+  Element* GetCustomContentContainer() const { return mCustomContentContainer; }
 
   /**
    * Unhide the CustomContentContainer. This call only has an effect if
    * mCustomContentContainer is non-null.
    */
   void ShowCustomContentContainer();
 
   /**
@@ -117,22 +117,22 @@ class nsCanvasFrame final : public nsCon
 
   nsRect CanvasArea() const;
 
  protected:
   // Data members
   bool mDoPaintFocus;
   bool mAddedScrollPositionListener;
 
-  nsCOMPtr<mozilla::dom::Element> mCustomContentContainer;
+  nsCOMPtr<Element> mCustomContentContainer;
 
  private:
   nsPopupSetFrame* mPopupSetFrame;
-  nsCOMPtr<mozilla::dom::Element> mPopupgroupContent;
-  nsCOMPtr<mozilla::dom::Element> mTooltipContent;
+  nsCOMPtr<Element> mPopupgroupContent;
+  nsCOMPtr<Element> mTooltipContent;
 };
 
 /**
  * Override nsDisplayBackground methods so that we pass aBGClipRect to
  * PaintBackground, covering the whole overflow area.
  * We can also paint an "extra background color" behind the normal
  * background.
  */
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -49,16 +49,17 @@ class ScrollFrameHelper : public nsIRefl
   typedef mozilla::CSSIntPoint CSSIntPoint;
   typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
   typedef mozilla::layers::FrameMetrics FrameMetrics;
   typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
   typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo;
   typedef mozilla::layers::Layer Layer;
   typedef mozilla::layers::LayerManager LayerManager;
   typedef mozilla::layout::ScrollAnchorContainer ScrollAnchorContainer;
+  using Element = mozilla::dom::Element;
 
   class AsyncScroll;
   class AsyncSmoothMSDScroll;
 
   ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot);
   ~ScrollFrameHelper();
 
   mozilla::ScrollStyles GetScrollStylesFromFrame() const;
@@ -117,28 +118,27 @@ class ScrollFrameHelper : public nsIRefl
   void PostScrolledAreaEvent();
   void FireScrolledAreaEvent();
 
   bool IsSmoothScrollingEnabled();
 
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void FinishReflowForScrollbar(mozilla::dom::Element* aElement, nscoord aMinXY,
+  void FinishReflowForScrollbar(Element* aElement, nscoord aMinXY,
                                 nscoord aMaxXY, nscoord aCurPosXY,
                                 nscoord aPageIncrement, nscoord aIncrement);
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void SetScrollbarEnabled(mozilla::dom::Element* aElement, nscoord aMaxPos);
+  void SetScrollbarEnabled(Element* aElement, nscoord aMaxPos);
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void SetCoordAttribute(mozilla::dom::Element* aElement, nsAtom* aAtom,
-                         nscoord aSize);
+  void SetCoordAttribute(Element* aElement, nsAtom* aAtom, nscoord aSize);
 
   nscoord GetCoordAttribute(nsIFrame* aFrame, nsAtom* aAtom,
                             nscoord aDefaultValue, nscoord* aRangeStart,
                             nscoord* aRangeLength);
 
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    * Update scrollbar curpos attributes to reflect current scroll position
@@ -516,20 +516,20 @@ class ScrollFrameHelper : public nsIRefl
   // used to size the physical (visual) viewport.
   nsSize TrueOuterSize() const;
 
   already_AddRefed<Element> MakeScrollbar(dom::NodeInfo* aNodeInfo,
                                           bool aVertical,
                                           AnonymousContentKey& aKey);
 
   // owning references to the nsIAnonymousContentCreator-built content
-  nsCOMPtr<mozilla::dom::Element> mHScrollbarContent;
-  nsCOMPtr<mozilla::dom::Element> mVScrollbarContent;
-  nsCOMPtr<mozilla::dom::Element> mScrollCornerContent;
-  nsCOMPtr<mozilla::dom::Element> mResizerContent;
+  nsCOMPtr<Element> mHScrollbarContent;
+  nsCOMPtr<Element> mVScrollbarContent;
+  nsCOMPtr<Element> mScrollCornerContent;
+  nsCOMPtr<Element> mResizerContent;
 
   class ScrollEvent;
   class ScrollEndEvent;
   class AsyncScrollPortEvent;
   class ScrolledAreaEvent;
 
   RefPtr<ScrollEvent> mScrollEvent;
   RefPtr<ScrollEndEvent> mScrollEndEvent;
--- a/layout/generic/nsIFrameInlines.h
+++ b/layout/generic/nsIFrameInlines.h
@@ -207,17 +207,18 @@ nsContainerFrame* nsIFrame::GetInFlowPar
 //    descendant does.
 //
 // See GetFlattenedTreeParentElementForStyle for the difference between it and
 // plain GetFlattenedTreeParentElement.
 nsIFrame* nsIFrame::GetClosestFlattenedTreeAncestorPrimaryFrame() const {
   if (!mContent) {
     return nullptr;
   }
-  Element* parent = mContent->GetFlattenedTreeParentElementForStyle();
+  mozilla::dom::Element* parent =
+      mContent->GetFlattenedTreeParentElementForStyle();
   while (parent) {
     if (nsIFrame* frame = parent->GetPrimaryFrame()) {
       return frame;
     }
     // NOTE(emilio): This should be an assert except we have code in tree which
     // violates invariants like the <frameset> frame construction code.
     if (MOZ_UNLIKELY(!parent->IsDisplayContents())) {
       return nullptr;
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -1476,23 +1476,23 @@ nsresult nsPluginFrame::HandleEvent(nsPr
 
   if (!mInstanceOwner) return NS_ERROR_NULL_POINTER;
 
   mInstanceOwner->ConsiderNewEventloopNestingLevel();
 
   if (anEvent->mMessage == ePluginActivate) {
     nsIFocusManager* fm = nsFocusManager::GetFocusManager();
     if (fm) {
-      RefPtr<Element> elem = GetContent()->AsElement();
+      RefPtr<dom::Element> elem = GetContent()->AsElement();
       return fm->SetFocus(elem, 0);
     }
   } else if (anEvent->mMessage == ePluginFocus) {
     nsIFocusManager* fm = nsFocusManager::GetFocusManager();
     if (fm) {
-      RefPtr<Element> elem = GetContent()->AsElement();
+      RefPtr<dom::Element> elem = GetContent()->AsElement();
       return fm->FocusPlugin(elem);
     }
   }
 
   if (mInstanceOwner->SendNativeEvents() &&
       anEvent->IsNativeEventDelivererForPlugin()) {
     *anEventStatus = mInstanceOwner->ProcessEvent(*anEvent);
     // Due to plugin code reentering Gecko, this frame may be dead at this
--- a/layout/mathml/nsMathMLmtableFrame.cpp
+++ b/layout/mathml/nsMathMLmtableFrame.cpp
@@ -20,16 +20,17 @@
 #include "mozilla/RestyleManager.h"
 #include <algorithm>
 
 #include "nsIScriptError.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
+using mozilla::dom::Element;
 
 //
 // <mtable> -- table or matrix - implementation
 //
 
 static int8_t ParseStyleValue(nsAtom* aAttribute,
                               const nsAString& aAttributeValue) {
   if (aAttribute == nsGkAtoms::rowalign_) {
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -163,17 +163,17 @@ bool nsImageRenderer::PrepareImage() {
       mPrepareResult = ImgDrawResult::SUCCESS;
       break;
     }
     case eStyleImageType_Gradient:
       mGradientData = &mImage->GetGradient();
       mPrepareResult = ImgDrawResult::SUCCESS;
       break;
     case eStyleImageType_Element: {
-      Element* paintElement =  // may be null
+      dom::Element* paintElement =  // may be null
           SVGObserverUtils::GetAndObserveBackgroundImage(
               mForFrame->FirstContinuation(), mImage->GetElementId());
       // If the referenced element is an <img>, <canvas>, or <video> element,
       // prefer SurfaceFromElement as it's more reliable.
       mImageElementSurface = nsLayoutUtils::SurfaceFromElement(paintElement);
 
       if (!mImageElementSurface.GetSourceSurface()) {
         nsIFrame* paintServerFrame =
--- a/layout/style/DocumentStyleRootIterator.cpp
+++ b/layout/style/DocumentStyleRootIterator.cpp
@@ -17,23 +17,23 @@ DocumentStyleRootIterator::DocumentStyle
   MOZ_ASSERT(aStyleRoot);
   if (aStyleRoot->IsElement()) {
     mStyleRoots.AppendElement(aStyleRoot->AsElement());
     return;
   }
 
   dom::Document* doc = aStyleRoot->OwnerDoc();
   MOZ_ASSERT(doc == aStyleRoot);
-  if (Element* root = doc->GetRootElement()) {
+  if (dom::Element* root = doc->GetRootElement()) {
     mStyleRoots.AppendElement(root);
   }
   nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(doc, mStyleRoots);
 }
 
-Element* DocumentStyleRootIterator::GetNextStyleRoot() {
+dom::Element* DocumentStyleRootIterator::GetNextStyleRoot() {
   for (;;) {
     if (mPosition >= mStyleRoots.Length()) {
       return nullptr;
     }
 
     nsIContent* next = mStyleRoots[mPosition];
     ++mPosition;
 
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -478,17 +478,17 @@ void nsResizerFrame::RestoreOriginalSize
   Direction direction = {1, 1};
   ResizeContent(aContent, direction, *sizeInfo, nullptr);
   aContent->DeleteProperty(nsGkAtoms::_moz_original_size);
 }
 
 /* returns a Direction struct containing the horizontal and vertical direction
  */
 nsResizerFrame::Direction nsResizerFrame::GetDirection() {
-  static const Element::AttrValuesArray strings[] = {
+  static const mozilla::dom::Element::AttrValuesArray strings[] = {
       // clang-format off
      nsGkAtoms::topleft,    nsGkAtoms::top,    nsGkAtoms::topright,
      nsGkAtoms::left,                          nsGkAtoms::right,
      nsGkAtoms::bottomleft, nsGkAtoms::bottom, nsGkAtoms::bottomright,
      nsGkAtoms::bottomstart,                   nsGkAtoms::bottomend,
      nullptr
       // clang-format on
   };
--- a/layout/xul/nsRootBoxFrame.cpp
+++ b/layout/xul/nsRootBoxFrame.cpp
@@ -56,18 +56,18 @@ class nsRootBoxFrame final : public nsBo
 
   explicit nsRootBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
 
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS(nsRootBoxFrame)
 
   virtual nsPopupSetFrame* GetPopupSetFrame() override;
   virtual void SetPopupSetFrame(nsPopupSetFrame* aPopupSet) override;
-  virtual Element* GetDefaultTooltip() override;
-  virtual void SetDefaultTooltip(Element* aTooltip) override;
+  virtual dom::Element* GetDefaultTooltip() override;
+  virtual void SetDefaultTooltip(dom::Element* aTooltip) override;
 
   virtual void AppendFrames(ChildListID aListID,
                             nsFrameList& aFrameList) override;
   virtual void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
                             const nsLineList::iterator* aPrevFrameLine,
                             nsFrameList& aFrameList) override;
   virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
 
@@ -90,17 +90,17 @@ class nsRootBoxFrame final : public nsBo
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
   nsPopupSetFrame* mPopupSetFrame;
 
  protected:
-  Element* mDefaultTooltip;
+  dom::Element* mDefaultTooltip;
 };
 
 //----------------------------------------------------------------------
 
 nsContainerFrame* NS_NewRootBoxFrame(PresShell* aPresShell,
                                      ComputedStyle* aStyle) {
   return new (aPresShell) nsRootBoxFrame(aStyle, aPresShell->GetPresContext());
 }
@@ -205,19 +205,19 @@ void nsRootBoxFrame::SetPopupSetFrame(ns
   // popupset.  Since the anonymous content is associated with the
   // nsDocElementBoxFrame, we'll get a new popupset when the new doc
   // element box frame is created.
   MOZ_ASSERT(!aPopupSet || !mPopupSetFrame,
              "Popup set is already defined! Only 1 allowed.");
   mPopupSetFrame = aPopupSet;
 }
 
-Element* nsRootBoxFrame::GetDefaultTooltip() { return mDefaultTooltip; }
+dom::Element* nsRootBoxFrame::GetDefaultTooltip() { return mDefaultTooltip; }
 
-void nsRootBoxFrame::SetDefaultTooltip(Element* aTooltip) {
+void nsRootBoxFrame::SetDefaultTooltip(dom::Element* aTooltip) {
   mDefaultTooltip = aTooltip;
 }
 
 NS_QUERYFRAME_HEAD(nsRootBoxFrame)
   NS_QUERYFRAME_ENTRY(nsIPopupContainer)
 NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
 
 #ifdef DEBUG_FRAME_DUMP
--- a/layout/xul/nsScrollbarButtonFrame.cpp
+++ b/layout/xul/nsScrollbarButtonFrame.cpp
@@ -104,18 +104,18 @@ bool nsScrollbarButtonFrame::HandleButto
   }
 
   // get the scrollbar control
   nsIFrame* scrollbar;
   GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
 
   if (scrollbar == nullptr) return false;
 
-  static Element::AttrValuesArray strings[] = {nsGkAtoms::increment,
-                                               nsGkAtoms::decrement, nullptr};
+  static dom::Element::AttrValuesArray strings[] = {
+      nsGkAtoms::increment, nsGkAtoms::decrement, nullptr};
   int32_t index = mContent->AsElement()->FindAttrValueIn(
       kNameSpaceID_None, nsGkAtoms::type, strings, eCaseMatters);
   int32_t direction;
   if (index == 0)
     direction = 1;
   else if (index == 1)
     direction = -1;
   else
--- a/layout/xul/nsScrollbarFrame.cpp
+++ b/layout/xul/nsScrollbarFrame.cpp
@@ -20,16 +20,17 @@
 #include "nsIScrollbarMediator.h"
 #include "nsStyleConsts.h"
 #include "nsIContent.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/PresShell.h"
 #include "mozilla/dom/MutationEventBinding.h"
 
 using namespace mozilla;
+using mozilla::dom::Element;
 
 //
 // NS_NewScrollbarFrame
 //
 // Creates a new scrollbar frame and returns it
 //
 nsIFrame* NS_NewScrollbarFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
   return new (aPresShell)
--- a/layout/xul/nsScrollbarFrame.h
+++ b/layout/xul/nsScrollbarFrame.h
@@ -14,23 +14,28 @@
 #include "mozilla/Attributes.h"
 #include "nsIAnonymousContentCreator.h"
 #include "nsBoxFrame.h"
 
 class nsIScrollbarMediator;
 
 namespace mozilla {
 class PresShell;
+namespace dom {
+class Element;
+}
 }  // namespace mozilla
 
 nsIFrame* NS_NewScrollbarFrame(mozilla::PresShell* aPresShell,
                                mozilla::ComputedStyle* aStyle);
 
 class nsScrollbarFrame final : public nsBoxFrame,
                                public nsIAnonymousContentCreator {
+  using Element = mozilla::dom::Element;
+
  public:
   explicit nsScrollbarFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
       : nsBoxFrame(aStyle, aPresContext, kClassID),
         mIncrement(0),
         mSmoothScroll(false),
         mScrollbarMediator(nullptr),
         mUpTopButton(nullptr),
         mDownTopButton(nullptr),
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -593,17 +593,17 @@ nsresult nsSliderFrame::HandleEvent(nsPr
     AutoWeakFrame weakFrame(this);
     // should aMaySnap be true here?
     SetCurrentThumbPosition(scrollbar, pos - thumbLength / 2, false, false);
     NS_ENSURE_TRUE(weakFrame.IsAlive(), NS_OK);
 
     DragThumb(true);
 
 #ifdef MOZ_WIDGET_GTK
-    RefPtr<Element> thumb = thumbFrame->GetContent()->AsElement();
+    RefPtr<dom::Element> thumb = thumbFrame->GetContent()->AsElement();
     thumb->SetAttr(kNameSpaceID_None, nsGkAtoms::active,
                    NS_LITERAL_STRING("true"), true);
 #endif
 
     if (aEvent->mClass == eTouchEventClass) {
       *aEventStatus = nsEventStatus_eConsumeNoDefault;
     }
 
@@ -765,18 +765,18 @@ void nsSliderFrame::CurrentPositionChang
       scrollbarFrame ? scrollbarFrame->GetScrollbarMediator() : nullptr;
   if (!mediator || !mediator->ShouldSuppressScrollbarRepaints()) {
     SchedulePaint();
   }
 
   mCurPos = curPos;
 }
 
-static void UpdateAttribute(Element* aScrollbar, nscoord aNewPos, bool aNotify,
-                            bool aIsSmooth) {
+static void UpdateAttribute(dom::Element* aScrollbar, nscoord aNewPos,
+                            bool aNotify, bool aIsSmooth) {
   nsAutoString str;
   str.AppendInt(aNewPos);
 
   if (aIsSmooth) {
     aScrollbar->SetAttr(kNameSpaceID_None, nsGkAtoms::smooth,
                         NS_LITERAL_STRING("true"), false);
   }
   aScrollbar->SetAttr(kNameSpaceID_None, nsGkAtoms::curpos, str, aNotify);
@@ -1081,17 +1081,17 @@ nsresult nsSliderFrame::StartDrag(Event*
   }
 
   nsIFrame* thumbFrame = mFrames.FirstChild();
   if (!thumbFrame) {
     return NS_OK;
   }
 
 #ifdef MOZ_WIDGET_GTK
-  RefPtr<Element> thumb = thumbFrame->GetContent()->AsElement();
+  RefPtr<dom::Element> thumb = thumbFrame->GetContent()->AsElement();
   thumb->SetAttr(kNameSpaceID_None, nsGkAtoms::active,
                  NS_LITERAL_STRING("true"), true);
 #endif
 
   if (isHorizontal)
     mThumbStart = thumbFrame->GetPosition().x;
   else
     mThumbStart = thumbFrame->GetPosition().y;
@@ -1118,17 +1118,17 @@ nsresult nsSliderFrame::StopDrag() {
 
   mScrollingWithAPZ = false;
 
   UnsuppressDisplayport();
 
 #ifdef MOZ_WIDGET_GTK
   nsIFrame* thumbFrame = mFrames.FirstChild();
   if (thumbFrame) {
-    RefPtr<Element> thumb = thumbFrame->GetContent()->AsElement();
+    RefPtr<dom::Element> thumb = thumbFrame->GetContent()->AsElement();
     thumb->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, true);
   }
 #endif
 
   if (mChange) {
     StopRepeat();
     mChange = 0;
   }
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -34,16 +34,17 @@
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/MouseEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/PresShell.h"
 #include "mozilla/UniquePtr.h"
 
 using namespace mozilla;
 
+using mozilla::dom::Element;
 using mozilla::dom::Event;
 
 class nsSplitterInfo {
  public:
   nscoord min;
   nscoord max;
   nscoord current;
   nscoord changed;
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -186,17 +186,17 @@ bool nsTextBoxFrame::UpdateAccesskey(Wea
 
 void nsTextBoxFrame::UpdateAttributes(nsAtom* aAttribute, bool& aResize,
                                       bool& aRedraw) {
   bool doUpdateTitle = false;
   aResize = false;
   aRedraw = false;
 
   if (aAttribute == nullptr || aAttribute == nsGkAtoms::crop) {
-    static Element::AttrValuesArray strings[] = {
+    static dom::Element::AttrValuesArray strings[] = {
         nsGkAtoms::left,  nsGkAtoms::start, nsGkAtoms::center,
         nsGkAtoms::right, nsGkAtoms::end,   nsGkAtoms::none,
         nullptr};
     CroppingStyle cropType;
     switch (mContent->AsElement()->FindAttrValueIn(
         kNameSpaceID_None, nsGkAtoms::crop, strings, eCaseMatters)) {
       case 0:
       case 1:
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -168,19 +168,19 @@ class nsTreeBodyFrame final : public nsL
 
   virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
 
   friend nsIFrame* NS_NewTreeBodyFrame(mozilla::PresShell* aPresShell);
   friend class nsTreeColumn;
 
   struct ScrollParts {
     nsScrollbarFrame* mVScrollbar;
-    RefPtr<Element> mVScrollbarContent;
+    RefPtr<mozilla::dom::Element> mVScrollbarContent;
     nsScrollbarFrame* mHScrollbar;
-    RefPtr<Element> mHScrollbarContent;
+    RefPtr<mozilla::dom::Element> mHScrollbarContent;
     nsIFrame* mColumnsFrame;
     nsIScrollableFrame* mColumnsScrollFrame;
   };
 
   ImgDrawResult PaintTreeBody(gfxContext& aRenderingContext,
                               const nsRect& aDirtyRect, nsPoint aPt,
                               nsDisplayListBuilder* aBuilder);
 
--- a/toolkit/components/autocomplete/nsAutoCompleteController.h
+++ b/toolkit/components/autocomplete/nsAutoCompleteController.h
@@ -89,17 +89,17 @@ class nsAutoCompleteController final : p
    */
   already_AddRefed<nsIAutoCompletePopup> GetPopup() {
     nsCOMPtr<nsIAutoCompletePopup> popup;
     mInput->GetPopup(getter_AddRefs(popup));
     if (popup) {
       return popup.forget();
     }
 
-    nsCOMPtr<Element> popupEl;
+    nsCOMPtr<mozilla::dom::Element> popupEl;
     mInput->GetPopupElement(getter_AddRefs(popupEl));
     if (popupEl) {
       return popupEl->AsAutoCompletePopup();
     }
     return nullptr;
   }
 
  private:
--- a/xpfe/appshell/AppWindow.cpp
+++ b/xpfe/appshell/AppWindow.cpp
@@ -97,16 +97,17 @@
 //*****************************************************************************
 
 namespace mozilla {
 
 using dom::AutoNoJSAPI;
 using dom::BrowserHost;
 using dom::BrowsingContext;
 using dom::Document;
+using dom::Element;
 using dom::EventTarget;
 using dom::LoadURIOptions;
 
 AppWindow::AppWindow(uint32_t aChromeFlags)
     : mChromeTreeOwner(nullptr),
       mContentTreeOwner(nullptr),
       mPrimaryContentTreeOwner(nullptr),
       mModalStatus(NS_OK),
@@ -2075,17 +2076,17 @@ AppWindow::GetPrimaryContentSize(int32_t
     return GetPrimaryContentShellSize(aWidth, aHeight);
   }
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult AppWindow::GetPrimaryRemoteTabSize(int32_t* aWidth, int32_t* aHeight) {
   BrowserHost* host = BrowserHost::GetFrom(mPrimaryBrowserParent.get());
   // Need strong ref, since Client* can run script.
-  nsCOMPtr<Element> element = host->GetOwnerElement();
+  RefPtr<dom::Element> element = host->GetOwnerElement();
   NS_ENSURE_STATE(element);
 
   *aWidth = element->ClientWidth();
   *aHeight = element->ClientHeight();
   return NS_OK;
 }
 
 nsresult AppWindow::GetPrimaryContentShellSize(int32_t* aWidth,
--- a/xpfe/appshell/AppWindow.h
+++ b/xpfe/appshell/AppWindow.h
@@ -208,17 +208,17 @@ class AppWindow final : public nsIBaseWi
   void SyncAttributesToWidget();
   NS_IMETHOD SavePersistentAttributes();
 
   bool NeedsTooltipListener();
   void AddTooltipSupport();
   void RemoveTooltipSupport();
 
   NS_IMETHOD GetWindowDOMWindow(mozIDOMWindowProxy** aDOMWindow);
-  mozilla::dom::Element* GetWindowDOMElement() const;
+  dom::Element* GetWindowDOMElement() const;
 
   // See nsIDocShellTreeOwner for docs on next two methods
   nsresult ContentShellAdded(nsIDocShellTreeItem* aContentShell, bool aPrimary);
   nsresult ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
   NS_IMETHOD GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight);
   NS_IMETHOD SetPrimaryContentSize(int32_t aWidth, int32_t aHeight);
   nsresult GetRootShellSize(int32_t* aWidth, int32_t* aHeight);
   nsresult SetRootShellSize(int32_t aWidth, int32_t aHeight);