Bug 1455674 part 13. Remove remaining xpidl uses of nsIDOMElement. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 26 Apr 2018 23:37:29 -0400
changeset 416004 7f3223b376bb4f473b44e8d3d504df58b70652a0
parent 416003 5add57b9a0cc9a37590bbd970ad04ad1d2f3cf7e
child 416005 995b14b30559aab3736e11bdc1591cf50349c03b
push id33912
push usercsabou@mozilla.com
push dateFri, 27 Apr 2018 10:05:59 +0000
treeherdermozilla-central@d2d518b1f873 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1455674
milestone61.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 1455674 part 13. Remove remaining xpidl uses of nsIDOMElement. r=qdot
browser/components/shell/nsGNOMEShellService.cpp
browser/components/shell/nsIShellService.idl
browser/components/shell/nsMacShellService.cpp
browser/components/shell/nsWindowsShellService.cpp
docshell/base/LoadContext.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsILoadContext.idl
dom/base/nsContentUtils.cpp
dom/chrome-webidl/ChannelWrapper.webidl
dom/ipc/TabParent.cpp
netwerk/base/nsISecureBrowserUI.idl
parser/html/nsIParserUtils.idl
parser/html/nsIScriptableUnescapeHTML.idl
parser/html/nsParserUtils.cpp
toolkit/components/extensions/webrequest/ChannelWrapper.cpp
toolkit/components/extensions/webrequest/ChannelWrapper.h
uriloader/prefetch/OfflineCacheUpdateParent.cpp
widget/cocoa/nsStandaloneNativeMenu.mm
widget/cocoa/nsSystemStatusBarCocoa.mm
widget/nsIStandaloneNativeMenu.idl
widget/nsISystemStatusBar.idl
xpcom/system/nsIGeolocationProvider.idl
xpfe/appshell/nsContentTreeOwner.cpp
xpfe/appshell/nsIXULBrowserWindow.idl
--- a/browser/components/shell/nsGNOMEShellService.cpp
+++ b/browser/components/shell/nsGNOMEShellService.cpp
@@ -18,21 +18,21 @@
 #include "nsIGConfService.h"
 #include "nsIGIOService.h"
 #include "nsIGSettingsService.h"
 #include "nsIStringBundle.h"
 #include "nsIOutputStream.h"
 #include "nsIProcess.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
-#include "nsIDOMElement.h"
 #include "nsIImageLoadingContent.h"
 #include "imgIRequest.h"
 #include "imgIContainer.h"
 #include "mozilla/Sprintf.h"
+#include "mozilla/dom/Element.h"
 #if defined(MOZ_WIDGET_GTK)
 #include "nsIImageToPixbuf.h"
 #endif
 #include "nsXULAppAPI.h"
 #include "gfxPlatform.h"
 
 #include <glib.h>
 #include <glib-object.h>
@@ -406,17 +406,17 @@ WriteImage(const nsCString& aPath, imgIC
   gboolean res = gdk_pixbuf_save(pixbuf, aPath.get(), "png", nullptr, nullptr);
 
   g_object_unref(pixbuf);
   return res ? NS_OK : NS_ERROR_FAILURE;
 #endif
 }
 
 NS_IMETHODIMP
-nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
+nsGNOMEShellService::SetDesktopBackground(dom::Element* aElement,
                                           int32_t aPosition,
                                           const nsACString& aImageName)
 {
   nsresult rv;
   nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement, &rv);
   if (!imageContent) return rv;
 
   // get the image container
--- a/browser/components/shell/nsIShellService.idl
+++ b/browser/components/shell/nsIShellService.idl
@@ -1,18 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMElement;
 interface nsIFile;
 
+webidl Element;
+
 [scriptable, uuid(2d1a95e4-5bd8-4eeb-b0a8-c1455fd2a357)]
 interface nsIShellService : nsISupports
 {
   /**
    * Determines whether or not Firefox is the "Default Browser."
    * This is simply whether or not Firefox is registered to handle
    * http links.
    *
@@ -53,17 +54,17 @@ interface nsIShellService : nsISupports
      *
      * @param aImageElement Either a HTML <IMG> element or an element with
      *                      a background image from which to source the
      *                      background image. 
      * @param aPosition     How to place the image on the desktop
      * @param aImageName    The image name. Equivalent to the leaf name of the
      *                      location.href.
      */
-  void setDesktopBackground(in nsIDOMElement aElement,
+  void setDesktopBackground(in Element aElement,
                             in long aPosition,
                             in ACString aImageName);
 
   /**
    * Constants identifying applications that can be opened with
    * openApplication.
    */
   const long APPLICATION_MAIL        = 0;
--- a/browser/components/shell/nsMacShellService.cpp
+++ b/browser/components/shell/nsMacShellService.cpp
@@ -17,20 +17,23 @@
 #include "nsIWebBrowserPersist.h"
 #include "nsMacShellService.h"
 #include "nsIProperties.h"
 #include "nsServiceManagerUtils.h"
 #include "nsShellService.h"
 #include "nsString.h"
 #include "nsIDocShell.h"
 #include "nsILoadContext.h"
+#include "mozilla/dom/Element.h"
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <ApplicationServices/ApplicationServices.h>
 
+using mozilla::dom::Element;
+
 #define NETWORK_PREFPANE NS_LITERAL_CSTRING("/System/Library/PreferencePanes/Network.prefPane")
 #define DESKTOP_PREFPANE NS_LITERAL_CSTRING("/System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane")
 
 #define SAFARI_BUNDLE_IDENTIFIER "com.apple.Safari"
 
 NS_IMPL_ISUPPORTS(nsMacShellService, nsIMacShellService, nsIShellService, nsIWebProgressListener)
 
 NS_IMETHODIMP
@@ -92,36 +95,32 @@ nsMacShellService::SetDefaultBrowser(boo
     // before it is silenced.
     (void) prefs->SetIntPref(PREF_DEFAULTBROWSERCHECKCOUNT, 0);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement,
+nsMacShellService::SetDesktopBackground(Element* aElement,
                                         int32_t aPosition,
                                         const nsACString& aImageName)
 {
   // Note: We don't support aPosition on OS X.
 
   // Get the image URI:
   nsresult rv;
   nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement,
                                                                     &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIURI> imageURI;
   rv = imageContent->GetCurrentURI(getter_AddRefs(imageURI));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // We need the referer URI for nsIWebBrowserPersist::saveURI
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsIURI *docURI = content->OwnerDoc()->GetDocumentURI();
+  nsIURI *docURI = aElement->OwnerDoc()->GetDocumentURI();
   if (!docURI)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIProperties> fileLocator
     (do_GetService("@mozilla.org/file/directory_service;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the current user's "Pictures" folder (That's ~/Pictures):
@@ -144,24 +143,24 @@ nsMacShellService::SetDesktopBackground(
   uint32_t flags = nsIWebBrowserPersist::PERSIST_FLAGS_NO_CONVERSION |
                    nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES |
                    nsIWebBrowserPersist::PERSIST_FLAGS_FROM_CACHE;
 
   wbp->SetPersistFlags(flags);
   wbp->SetProgressListener(this);
 
   nsCOMPtr<nsILoadContext> loadContext;
-  nsCOMPtr<nsISupports> container = content->OwnerDoc()->GetContainer();
+  nsCOMPtr<nsISupports> container = aElement->OwnerDoc()->GetContainer();
   nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
   if (docShell) {
     loadContext = do_QueryInterface(docShell);
   }
 
   return wbp->SaveURI(imageURI, 0,
-                      docURI, content->OwnerDoc()->GetReferrerPolicy(),
+                      docURI, aElement->OwnerDoc()->GetReferrerPolicy(),
                       nullptr, nullptr,
                       mBackgroundFile, loadContext);
 }
 
 NS_IMETHODIMP
 nsMacShellService::OnProgressChange(nsIWebProgress* aWebProgress,
                                     nsIRequest* aRequest,
                                     int32_t aCurSelfProgress,
--- a/browser/components/shell/nsWindowsShellService.cpp
+++ b/browser/components/shell/nsWindowsShellService.cpp
@@ -28,16 +28,17 @@
 #include "nsDirectoryServiceUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIWindowsRegKey.h"
 #include "nsUnicharUtils.h"
 #include "nsIURLFormatter.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/WindowsVersion.h"
+#include "mozilla/dom/Element.h"
 
 #include "windows.h"
 #include "shellapi.h"
 
 #ifdef _WIN32_WINNT
 #undef _WIN32_WINNT
 #endif
 #define _WIN32_WINNT 0x0600
@@ -570,22 +571,21 @@ WriteBitmap(nsIFile* aFile, imgIContaine
   }
 
   dataSurface->Unmap();
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
+nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
                                             int32_t aPosition,
                                             const nsACString& aImageName)
 {
-  nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
-  if (!content || !content->IsHTMLElement(nsGkAtoms::img)) {
+  if (!aElement || !aElement->IsHTMLElement(nsGkAtoms::img)) {
     // XXX write background loading stuff!
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsresult rv;
   nsCOMPtr<nsIImageLoadingContent> imageContent =
     do_QueryInterface(aElement, &rv);
   if (!imageContent)
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Assertions.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/LoadContext.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/dom/Element.h"
 #include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
 #include "nsContentUtils.h"
 #include "xpcpublic.h"
 
 namespace mozilla {
 
 NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
 
@@ -55,19 +56,19 @@ LoadContext::GetTopWindow(mozIDOMWindowP
 {
   MOZ_ASSERT(mIsNotNull);
 
   // can't support this in the parent process
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
-LoadContext::GetTopFrameElement(nsIDOMElement** aElement)
+LoadContext::GetTopFrameElement(dom::Element** aElement)
 {
-  nsCOMPtr<nsIDOMElement> element = do_QueryReferent(mTopFrameElement);
+  nsCOMPtr<dom::Element> element = do_QueryReferent(mTopFrameElement);
   element.forget(aElement);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 LoadContext::GetNestedFrameId(uint64_t* aId)
 {
   NS_ENSURE_ARG(aId);
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -13074,32 +13074,31 @@ nsDocShell::GetTopWindow(mozIDOMWindowPr
   if (win) {
     win = win->GetTop();
   }
   win.forget(aWindow);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
+nsDocShell::GetTopFrameElement(Element** aElement)
 {
   *aElement = nullptr;
   nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
   if (!win) {
     return NS_OK;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> top = win->GetScriptableTop();
   NS_ENSURE_TRUE(top, NS_ERROR_FAILURE);
 
   // GetFrameElementInternal, /not/ GetScriptableFrameElement -- if |top| is
   // inside <iframe mozbrowser>, we want to return the iframe, not null.
   // And we want to cross the content/chrome boundary.
-  nsCOMPtr<nsIDOMElement> elt =
-    do_QueryInterface(top->GetFrameElementInternal());
+  RefPtr<Element> elt = top->GetFrameElementInternal();
   elt.forget(aElement);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetNestedFrameId(uint64_t* aId)
 {
   *aId = 0;
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -227,17 +227,17 @@ public:
                         nsIURI* aURI,
                         const char16_t* aTargetSpec) override;
   NS_IMETHOD OnLeaveLink() override;
 
   // Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
   // are shared with nsIDocShell (appID, etc.) and can't be declared twice.
   NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) override;
   NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) override;
-  NS_IMETHOD GetTopFrameElement(nsIDOMElement**) override;
+  NS_IMETHOD GetTopFrameElement(mozilla::dom::Element**) override;
   NS_IMETHOD GetNestedFrameId(uint64_t*) override;
   NS_IMETHOD GetIsContent(bool*) override;
   NS_IMETHOD GetUsePrivateBrowsing(bool*) override;
   NS_IMETHOD SetUsePrivateBrowsing(bool) override;
   NS_IMETHOD SetPrivateBrowsing(bool) override;
   NS_IMETHOD GetUseRemoteTabs(bool*) override;
   NS_IMETHOD SetRemoteTabs(bool) override;
   NS_IMETHOD GetScriptableOriginAttributes(JS::MutableHandle<JS::Value>) override;
--- a/docshell/base/nsILoadContext.idl
+++ b/docshell/base/nsILoadContext.idl
@@ -2,17 +2,18 @@
  * vim: ft=cpp tw=78 sw=2 et ts=2 sts=2 cin
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface mozIDOMWindowProxy;
-interface nsIDOMElement;
+
+webidl Element;
 
 [ref] native OriginAttributes(mozilla::OriginAttributes);
 
 %{C++
 #ifdef MOZILLA_INTERNAL_API
 #include "mozilla/BasePrincipal.h" // for OriginAttributes
 #endif
 %}
@@ -47,17 +48,17 @@ interface nsILoadContext : nsISupports
    * contains the topWindow with which the load is associated.
    *
    * Note that we may have a topFrameElement even when we don't have an
    * associatedWindow, if the topFrameElement's content lives out of process.
    * topFrameElement is available in single-process and multiprocess contexts.
    * Note that topFrameElement may be in chrome even when the nsILoadContext is
    * associated with content.
    */
-  readonly attribute nsIDOMElement topFrameElement;
+  readonly attribute Element topFrameElement;
 
   /**
    * If this LoadContext corresponds to a nested remote iframe, we don't have
    * access to the topFrameElement.  Instead, we must use this id to send
    * messages. A return value of 0 signifies that this load context is not for
    * a nested frame.
    */
   readonly attribute unsigned long long nestedFrameId;
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -9695,23 +9695,22 @@ nsContentUtils::GetPresentationURL(nsIDo
       if (tabChild) {
         aPresentationUrl = tabChild->PresentationURL();
       }
       return;
     }
   }
 
   nsCOMPtr<nsILoadContext> loadContext(do_QueryInterface(aDocShell));
-  nsCOMPtr<nsIDOMElement> topFrameElement;
-  loadContext->GetTopFrameElement(getter_AddRefs(topFrameElement));
-  if (!topFrameElement) {
+  RefPtr<Element> topFrameElt;
+  loadContext->GetTopFrameElement(getter_AddRefs(topFrameElt));
+  if (!topFrameElt) {
     return;
   }
 
-  nsCOMPtr<Element> topFrameElt = do_QueryInterface(topFrameElement);
   topFrameElt->GetAttribute(NS_LITERAL_STRING("mozpresentation"), aPresentationUrl);
 }
 
 /* static */ nsIDocShell*
 nsContentUtils::GetDocShellForEventTarget(EventTarget* aTarget)
 {
   nsCOMPtr<nsPIDOMWindowInner> innerWindow;
 
--- a/dom/chrome-webidl/ChannelWrapper.webidl
+++ b/dom/chrome-webidl/ChannelWrapper.webidl
@@ -289,16 +289,19 @@ interface ChannelWrapper : EventTarget {
    */
   [Cached, Constant]
   readonly attribute long long parentWindowId;
 
   /**
    * For cross-process requests, the <browser> or <iframe> element to which the
    * content loading this request belongs. For requests that don't originate
    * from a remote browser, this is null.
+   *
+   * This is not an Element because those are by default only exposed in
+   * Window, but we're exposed in System.
    */
   [Cached, Pure]
   readonly attribute nsISupports? browserElement;
 
   /**
    * Returns an array of objects that combine the url and frameId from the
    * ancestorPrincipals and ancestorOuterWindowIDs on loadInfo.
    * The immediate parent is the first entry, the last entry is always the top
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3220,19 +3220,19 @@ public:
   NS_IMETHOD OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo) override;
   NS_IMETHOD OnAuthCancelled(nsISupports *aContext, bool userCancel) override;
   NS_IMETHOD GetInterface(const nsIID & uuid, void **result) override
   {
     return QueryInterface(uuid, result);
   }
   NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) NO_IMPL
   NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) NO_IMPL
-  NS_IMETHOD GetTopFrameElement(nsIDOMElement** aElement) override
+  NS_IMETHOD GetTopFrameElement(Element** aElement) override
   {
-    nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(mElement);
+    nsCOMPtr<Element> elem = mElement;
     elem.forget(aElement);
     return NS_OK;
   }
   NS_IMETHOD GetNestedFrameId(uint64_t*) NO_IMPL
   NS_IMETHOD GetIsContent(bool*) NO_IMPL
   NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL
   NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL
   NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL
--- a/netwerk/base/nsISecureBrowserUI.idl
+++ b/netwerk/base/nsISecureBrowserUI.idl
@@ -2,17 +2,16 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface mozIDOMWindowProxy;
-interface nsIDOMElement;
 interface nsIDocShell;
 
 [scriptable, uuid(718c662a-f810-4a80-a6c9-0b1810ecade2)]
 interface nsISecureBrowserUI : nsISupports
 {
     void init(in mozIDOMWindowProxy window);
     void setDocShell(in nsIDocShell docShell);
 
--- a/parser/html/nsIParserUtils.idl
+++ b/parser/html/nsIParserUtils.idl
@@ -1,18 +1,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/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMElement;
 interface nsIURI;
 
 webidl DocumentFragment;
+webidl Element;
 
 /**
  * Non-Web HTML parser functionality to Firefox extensions and XULRunner apps. 
  * Don't use this from within Gecko--use nsContentUtils, nsTreeSanitizer, etc.
  * directly instead.
  */
 [scriptable, uuid(a1101145-0025-411e-8873-fdf57bf28128)]
 interface nsIParserUtils : nsISupports
@@ -120,17 +120,17 @@ interface nsIParserUtils : nsISupports
    * @param isXML true if |fragment| is XML and false if HTML
    * @param baseURI the base URL for this fragment
    * @param element the context node for the fragment parsing algorithm
    */
   DocumentFragment parseFragment(in AString fragment,
 				 in unsigned long flags,
 				 in boolean isXML,
 				 in nsIURI baseURI,
-				 in nsIDOMElement element);
+				 in Element element);
 
 };
 
 %{ C++
 #define NS_PARSERUTILS_CONTRACTID \
     "@mozilla.org/parserutils;1"
 #define NS_PARSERUTILS_CID  \
 { 0xaf7b24cb, 0x893f, 0x41bb, { 0x96, 0x1f, 0x5a, 0x69, 0x38, 0x8e, 0x27, 0xc3 } }
--- a/parser/html/nsIScriptableUnescapeHTML.idl
+++ b/parser/html/nsIScriptableUnescapeHTML.idl
@@ -1,19 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMElement;
 interface nsIURI;
 
 webidl DocumentFragment;
+webidl Element;
 
 /**
  * This interface is OBSOLETE and exists solely for legacy extensions.
  */
 [scriptable, uuid(3ab244a9-f09d-44da-9e3f-ee4d67367f2d)]
 interface nsIScriptableUnescapeHTML : nsISupports 
 {
   /** 
@@ -39,17 +39,17 @@ interface nsIScriptableUnescapeHTML : ns
    * @param fragment the input markup
    * @param isXML true if |fragment| is XML and false if HTML
    * @param baseURI the base URL for this fragment
    * @param element the context node for the fragment parsing algorithm
    */
   DocumentFragment parseFragment(in AString fragment,
                                  in boolean isXML,
                                  in nsIURI baseURI,
-                                 in nsIDOMElement element);
+                                 in Element element);
 };
 
 %{ C++
 #define NS_SCRIPTABLEUNESCAPEHTML_CONTRACTID \
   "@mozilla.org/feed-unescapehtml;1"
 #define NS_SCRIPTABLEUNESCAPEHTML_CID  \
 { 0x10f2f5f0, 0xf103, 0x4901, { 0x98, 0x0f, 0xba, 0x11, 0xbd, 0x70, 0xd6, 0x0d} }
 %}
--- a/parser/html/nsParserUtils.cpp
+++ b/parser/html/nsParserUtils.cpp
@@ -1,30 +1,30 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsParserUtils.h"
 #include "NullPrincipal.h"
 #include "mozilla/dom/DocumentFragment.h"
+#include "mozilla/dom/Element.h"
 #include "mozilla/dom/ScriptLoader.h"
 #include "nsAttrName.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsContentCID.h"
 #include "nsContentUtils.h"
 #include "nsEscape.h"
 #include "nsHTMLParts.h"
 #include "nsHtml5Module.h"
 #include "nsIComponentManager.h"
 #include "nsIContent.h"
 #include "nsIContentSink.h"
 #include "nsIDOMDocument.h"
-#include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
 #include "nsIDTD.h"
 #include "nsIDocument.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIFragmentContentSink.h"
 #include "nsIParser.h"
 #include "nsIScriptableUnescapeHTML.h"
 #include "nsISupportsPrimitives.h"
@@ -102,38 +102,36 @@ nsParserUtils::Sanitize(const nsAString&
 
   return encoder->EncodeToString(aToStr);
 }
 
 NS_IMETHODIMP
 nsParserUtils::ParseFragment(const nsAString& aFragment,
                              bool aIsXML,
                              nsIURI* aBaseURI,
-                             nsIDOMElement* aContextElement,
+                             Element* aContextElement,
                              DocumentFragment** aReturn)
 {
   return nsParserUtils::ParseFragment(
     aFragment, 0, aIsXML, aBaseURI, aContextElement, aReturn);
 }
 
 NS_IMETHODIMP
 nsParserUtils::ParseFragment(const nsAString& aFragment,
                              uint32_t aFlags,
                              bool aIsXML,
                              nsIURI* aBaseURI,
-                             nsIDOMElement* aContextElement,
+                             Element* aContextElement,
                              DocumentFragment** aReturn)
 {
   NS_ENSURE_ARG(aContextElement);
   *aReturn = nullptr;
 
   nsCOMPtr<nsIDocument> document;
-  nsCOMPtr<nsINode> contextNode;
-  contextNode = do_QueryInterface(aContextElement);
-  document = contextNode->OwnerDoc();
+  document = aContextElement->OwnerDoc();
 
   nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
 
   // stop scripts
   RefPtr<ScriptLoader> loader;
   bool scripts_enabled = false;
   if (document) {
     loader = document->ScriptLoader();
--- a/toolkit/components/extensions/webrequest/ChannelWrapper.cpp
+++ b/toolkit/components/extensions/webrequest/ChannelWrapper.cpp
@@ -14,16 +14,17 @@
 
 #include "NSSErrorsService.h"
 #include "nsITransportSecurityInfo.h"
 
 #include "mozilla/AddonManagerWebAPI.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/Unused.h"
+#include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/TabParent.h"
 #include "nsIContentPolicy.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIHttpHeaderVisitor.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsILoadContext.h"
@@ -329,21 +330,21 @@ ChannelWrapper::GetLoadContext() const
   if (nsCOMPtr<nsIChannel> chan = MaybeChannel()) {
     nsCOMPtr<nsILoadContext> ctxt;
     NS_QueryNotificationCallbacks(chan, ctxt);
     return ctxt.forget();
   }
   return nullptr;
 }
 
-already_AddRefed<nsIDOMElement>
+already_AddRefed<Element>
 ChannelWrapper::GetBrowserElement() const
 {
   if (nsCOMPtr<nsILoadContext> ctxt = GetLoadContext()) {
-    nsCOMPtr<nsIDOMElement> elem;
+    RefPtr<Element> elem;
     if (NS_SUCCEEDED(ctxt->GetTopFrameElement(getter_AddRefs(elem)))) {
       return elem.forget();
     }
   }
   return nullptr;
 }
 
 static inline bool
--- a/toolkit/components/extensions/webrequest/ChannelWrapper.h
+++ b/toolkit/components/extensions/webrequest/ChannelWrapper.h
@@ -31,24 +31,24 @@
 #include "nsInterfaceHashtable.h"
 #include "nsWeakPtr.h"
 #include "nsWrapperCache.h"
 
 #define NS_CHANNELWRAPPER_IID \
 { 0xc06162d2, 0xb803, 0x43b4, \
   { 0xaa, 0x31, 0xcf, 0x69, 0x7f, 0x93, 0x68, 0x1c } }
 
-class nsIDOMElement;
 class nsILoadContext;
 class nsITraceableChannel;
 
 namespace mozilla {
 namespace dom {
   class nsIContentParent;
-}
+  class Element;
+} // namespace dom
 namespace extensions {
 
 namespace detail {
 
   // We need to store our wrapped channel as a weak reference, since channels
   // are not cycle collected, and we're going to be hanging this wrapper
   // instance off the channel in order to ensure the same channel always has
   // the same wrapper.
@@ -201,17 +201,17 @@ public:
 
   already_AddRefed<nsIURI> GetOriginURI() const;
 
   already_AddRefed<nsIURI> GetDocumentURI() const;
 
 
   already_AddRefed<nsILoadContext> GetLoadContext() const;
 
-  already_AddRefed<nsIDOMElement> GetBrowserElement() const;
+  already_AddRefed<dom::Element> GetBrowserElement() const;
 
 
   bool CanModify() const;
   bool GetCanModify(ErrorResult& aRv) const
   {
     return CanModify();
   }
 
--- a/uriloader/prefetch/OfflineCacheUpdateParent.cpp
+++ b/uriloader/prefetch/OfflineCacheUpdateParent.cpp
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "OfflineCacheUpdateParent.h"
 
 #include "BackgroundUtils.h"
 #include "mozilla/BasePrincipal.h"
+#include "mozilla/dom/Element.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h"
 #include "nsOfflineCacheUpdate.h"
 #include "nsIApplicationCache.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNetUtil.h"
@@ -204,17 +205,17 @@ OfflineCacheUpdateParent::GetAssociatedW
 
 NS_IMETHODIMP
 OfflineCacheUpdateParent::GetTopWindow(mozIDOMWindowProxy** aTopWindow)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-OfflineCacheUpdateParent::GetTopFrameElement(nsIDOMElement** aElement)
+OfflineCacheUpdateParent::GetTopFrameElement(dom::Element** aElement)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 OfflineCacheUpdateParent::GetNestedFrameId(uint64_t* aId)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
--- a/widget/cocoa/nsStandaloneNativeMenu.mm
+++ b/widget/cocoa/nsStandaloneNativeMenu.mm
@@ -2,20 +2,22 @@
 /* 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/. */
 
 #import <Cocoa/Cocoa.h>
 
 #include "nsStandaloneNativeMenu.h"
 #include "nsMenuUtilsX.h"
-#include "nsIDOMElement.h"
 #include "nsIMutationObserver.h"
 #include "nsGkAtoms.h"
 #include "nsObjCExceptions.h"
+#include "mozilla/dom/Element.h"
+
+using mozilla::dom::Element;
 
 
 NS_IMPL_ISUPPORTS_INHERITED(nsStandaloneNativeMenu, nsMenuGroupOwnerX,
                             nsIMutationObserver, nsIStandaloneNativeMenu)
 
 nsStandaloneNativeMenu::nsStandaloneNativeMenu()
 : mMenu(nullptr)
 , mContainerStatusBarItem(nil)
@@ -23,34 +25,31 @@ nsStandaloneNativeMenu::nsStandaloneNati
 }
 
 nsStandaloneNativeMenu::~nsStandaloneNativeMenu()
 {
   if (mMenu) delete mMenu;
 }
 
 NS_IMETHODIMP
-nsStandaloneNativeMenu::Init(nsIDOMElement * aDOMElement)
+nsStandaloneNativeMenu::Init(Element* aElement)
 {
   NS_ASSERTION(mMenu == nullptr, "nsNativeMenu::Init - mMenu not null!");
 
-  nsresult rv;
+  NS_ENSURE_ARG(aElement);
 
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMElement, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!content->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menupopup))
+  if (!aElement->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menupopup))
     return NS_ERROR_FAILURE;
 
-  rv = nsMenuGroupOwnerX::Create(content->AsElement());
+  nsresult rv = nsMenuGroupOwnerX::Create(aElement);
   if (NS_FAILED(rv))
     return rv;
 
   mMenu = new nsMenuX();
-  rv = mMenu->Create(this, this, content);
+  rv = mMenu->Create(this, this, aElement);
   if (NS_FAILED(rv)) {
     delete mMenu;
     mMenu = nullptr;
     return rv;
   }
 
   mMenu->SetupIcon();
 
--- a/widget/cocoa/nsSystemStatusBarCocoa.mm
+++ b/widget/cocoa/nsSystemStatusBarCocoa.mm
@@ -4,45 +4,47 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #import <Cocoa/Cocoa.h>
 
 #include "nsComponentManagerUtils.h"
 #include "nsSystemStatusBarCocoa.h"
 #include "nsStandaloneNativeMenu.h"
 #include "nsObjCExceptions.h"
-#include "nsIDOMElement.h"
+#include "mozilla/dom/Element.h"
+
+using mozilla::dom::Element;
 
 NS_IMPL_ISUPPORTS(nsSystemStatusBarCocoa, nsISystemStatusBar)
 
 NS_IMETHODIMP
-nsSystemStatusBarCocoa::AddItem(nsIDOMElement* aDOMElement)
+nsSystemStatusBarCocoa::AddItem(Element* aElement)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   RefPtr<nsStandaloneNativeMenu> menu = new nsStandaloneNativeMenu();
-  nsresult rv = menu->Init(aDOMElement);
+  nsresult rv = menu->Init(aElement);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsCOMPtr<nsISupports> keyPtr = aDOMElement;
+  nsCOMPtr<nsISupports> keyPtr = aElement;
   mItems.Put(keyPtr, new StatusItem(menu));
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
-nsSystemStatusBarCocoa::RemoveItem(nsIDOMElement* aDOMElement)
+nsSystemStatusBarCocoa::RemoveItem(Element* aElement)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  mItems.Remove(aDOMElement);
+  mItems.Remove(aElement);
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 nsSystemStatusBarCocoa::StatusItem::StatusItem(nsStandaloneNativeMenu* aMenu)
   : mMenu(aMenu)
--- a/widget/nsIStandaloneNativeMenu.idl
+++ b/widget/nsIStandaloneNativeMenu.idl
@@ -1,29 +1,29 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMElement;
+webidl Element;
 
 /**
  * Platform-independent interface to platform native menu objects.
  */
 
 [scriptable, uuid(7F7201EB-510C-4CEF-BDF0-04A15A7A4A8C)]
 interface nsIStandaloneNativeMenu : nsISupports
 {
   /**
    * Initialize the native menu using given XUL DOM element.
    *
    * @param aDOMElement A XUL DOM element of tag type |menu| or |menupopup|.
    */
-  void init(in nsIDOMElement aDOMElement);
+  void init(in Element aElement);
 
   /**
    * This method must be called before the menu is opened and displayed to the
    * user. It allows the platform code to update the menu and also determine
    * whether the menu should even be shown.
    *
    * @return true if the menu can be shown, false if it should not be shown
    */
--- a/widget/nsISystemStatusBar.idl
+++ b/widget/nsISystemStatusBar.idl
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMElement;
+webidl Element;
 
 /**
  * Allow applications to interface with the Mac OS X system status bar.
  */
 
 [scriptable, uuid(24493180-ee81-4b7c-8b17-9e69480b7b8a)]
 interface nsISystemStatusBar : nsISupports
 {
@@ -20,17 +20,17 @@ interface nsISystemStatusBar : nsISuppor
    * element and the item will stay in the status bar until it is removed via
    * a call to removeItem, or until the process shuts down.
    * @param aDOMMenuElement A XUL menu element that contains a XUL menupopup
    *                        with regular menu content. The menu's icon is put
    *                        into the system status bar; clicking it will open
    *                        a menu with the contents of the menupopup.
    *                        The menu label is not shown.
    */
-  void addItem(in nsIDOMElement aDOMMenuElement);
+  void addItem(in Element aMenuElement);
 
   /**
    * Remove a previously-added item from the menu bar. Calling this with an
    * element that has not been added before will be silently ignored.
    * @param aDOMMenuElement The XUL menu element that you called addItem with.
    */
-  void removeItem(in nsIDOMElement aDOMMenuElement);
+  void removeItem(in Element aMenuElement);
 };
--- a/xpcom/system/nsIGeolocationProvider.idl
+++ b/xpcom/system/nsIGeolocationProvider.idl
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 
 #include "nsISupports.idl"
 
 interface nsIURI;
 interface nsIDOMWindow;
-interface nsIDOMElement;
 interface nsIDOMGeoPosition;
 interface nsIGeolocationPrompt;
 
 /**
 
  * Interface provides a way for a geolocation provider to
  * notify the system that a new location is available.
  */
--- a/xpfe/appshell/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/nsContentTreeOwner.cpp
@@ -446,17 +446,17 @@ NS_IMETHODIMP nsContentTreeOwner::SetSta
   mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
 
   if (xulBrowserWindow)
   {
     switch(aStatusType)
     {
     case STATUS_LINK:
       {
-        nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aStatusContext);
+        nsCOMPtr<dom::Element> element = do_QueryInterface(aStatusContext);
         xulBrowserWindow->SetOverLink(aStatusText, element);
         break;
       }
     }
   }
 
   return NS_OK;
 }
--- a/xpfe/appshell/nsIXULBrowserWindow.idl
+++ b/xpfe/appshell/nsIXULBrowserWindow.idl
@@ -5,37 +5,38 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIURI.idl"
 #include "nsIDOMNode.idl"
 
 interface nsIBrowser;
 interface nsIRequest;
-interface nsIDOMElement;
 interface nsIInputStream;
 interface nsIDocShell;
 interface nsIFrameLoaderOwner;
 interface nsITabParent;
 interface nsIPrincipal;
 interface mozIDOMWindowProxy;
 
+webidl Element;
+
 /**
  * The nsIXULBrowserWindow supplies the methods that may be called from the
  * internals of the browser area to tell the containing xul window to update
  * its ui. 
  */
 [scriptable, uuid(a8675fa9-c8b4-4350-9803-c38f344a9e38)]
 interface nsIXULBrowserWindow : nsISupports
 {
   /**
    * Tells the object implementing this function what link we are currently
    * over.
    */
-  void setOverLink(in AString link, in nsIDOMElement element);
+  void setOverLink(in AString link, in Element element);
 
   /**
    * Determines the appropriate target for a link.
    */
   AString onBeforeLinkTraversal(in AString originalTarget,
                                 in nsIURI linkURI,
                                 in nsIDOMNode linkNode,
                                 in boolean isAppTab);