Bug 1458174 - Remove nsIDOMElement from SeaMonkey. r=IanN BETA_BASE_20180507
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Mon, 07 May 2018 15:22:41 +0200
changeset 31881 e6f416a808eb
parent 31880 561427e43bfb
child 31882 0a6645934721
push id384
push userclokep@gmail.com
push dateTue, 26 Jun 2018 01:38:29 +0000
reviewersIanN
bugs1458174, 1455674
Bug 1458174 - Remove nsIDOMElement from SeaMonkey. r=IanN Port Bug 1455674 [Remove nsIDOMElement].
suite/browser/linkToolbarOverlay.js
suite/browser/navigator.js
suite/common/places/PlacesUIUtils.jsm
suite/common/places/content/browserPlacesViews.js
suite/common/places/content/controller.js
suite/components/shell/nsGNOMEShellService.cpp
suite/components/shell/nsIShellService.idl
suite/components/shell/nsMacShellService.cpp
suite/components/shell/nsWindowsShellService.cpp
--- a/suite/browser/linkToolbarOverlay.js
+++ b/suite/browser/linkToolbarOverlay.js
@@ -67,18 +67,17 @@ function()
 
       while(currentNode)
       {
         if (ChromeUtils.getClassName(currentNode) === "HTMLLinkElement")
           linkToolbarUI.linkAdded({originalTarget: currentNode});
         currentNode = currentNode.nextSibling;
       }
     }
-    else if (currentNode instanceof Ci.nsIDOMElement)
-    {
+    else if (currentNode.nodeType == currentNode.ELEMENT_NODE) {
       // head is supposed to be the first element inside html.
       // Got something else instead. returning
        return;
     }
     else
     {
       // Got a comment node or something like that. Moving on.
       currentNode = currentNode.nextSibling;
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -853,17 +853,17 @@ function WindowFocusTimerCallback(elemen
     element.focus();
   } else {
     // set the element in command dispatcher so focus will restore properly
     // when the window does become active
 
     if (element instanceof Ci.nsIDOMWindow) {
       document.commandDispatcher.focusedWindow = element;
       document.commandDispatcher.focusedElement = null;
-    } else if (element instanceof Ci.nsIDOMElement) {
+    } else if (Element.isInstance(element)) {
       document.commandDispatcher.focusedWindow = element.ownerDocument.defaultView;
       document.commandDispatcher.focusedElement = element;
     }
   }
 }
 
 function Shutdown()
 {
--- a/suite/common/places/PlacesUIUtils.jsm
+++ b/suite/common/places/PlacesUIUtils.jsm
@@ -4,16 +4,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 this.EXPORTED_SYMBOLS = ["PlacesUIUtils"];
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Timer.jsm");
 
+Cu.importGlobalProperties(["Element"]);
+
 XPCOMUtils.defineLazyModuleGetters(this, {
   PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
   PluralForm: "resource://gre/modules/PluralForm.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   RecentWindow: "resource:///modules/RecentWindow.jsm",
   PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
   PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
 });
@@ -385,17 +387,17 @@ this.PlacesUIUtils = {
     }
 
     // The view for a <menu> of which its associated menupopup is a places
     // view, is the menupopup.
     if (node.localName == "menu" && !node._placesNode &&
         node.lastChild._placesView)
       return node.lastChild._placesView;
 
-    while (node instanceof Ci.nsIDOMElement) {
+    while (Element.isInstance(node)) {
       if (node._placesView)
         return node._placesView;
       if (node.localName == "tree" && node.getAttribute("type") == "places")
         return node;
 
       node = node.parentNode;
     }
 
--- a/suite/common/places/content/browserPlacesViews.js
+++ b/suite/common/places/content/browserPlacesViews.js
@@ -735,17 +735,17 @@ PlacesViewBase.prototype = {
         }
       }, Cu.reportError);
   },
 
   /**
    * Checks whether the popup associated with the provided element is open.
    * This method may be overridden by classes that extend this base class.
    *
-   * @param  {nsIDOMElement} elt
+   * @param  {Element} elt
    * @return {Boolean}
    */
   _isPopupOpen(elt) {
     return !!elt.parentNode.open;
   },
 
   invalidateContainer: function PVB_invalidateContainer(aPlacesNode) {
     let elt = this._getDOMNodeForPlacesNode(aPlacesNode);
--- a/suite/common/places/content/controller.js
+++ b/suite/common/places/content/controller.js
@@ -1569,17 +1569,17 @@ function goDoPlacesCommand(aCommand) {
  * For example, if it detects the left-hand library pane, then it will look for
  * and return the reference to the right-hand pane.
  *
  * @param {Object} viewOrElement The item to check.
  * @return {Object} Will return the best result node to batch, or null
  *                  if one could not be found.
  */
 function getResultForBatching(viewOrElement) {
-  if (viewOrElement && viewOrElement instanceof Ci.nsIDOMElement &&
+  if (viewOrElement && Element.isInstance(viewOrElement) &&
       viewOrElement.id === "placesList") {
     // Note: fall back to the existing item if we can't find the right-hane pane.
     viewOrElement = document.getElementById("placeContent") || viewOrElement;
   }
 
   if (viewOrElement && viewOrElement.result) {
     return viewOrElement.result;
   }
--- a/suite/components/shell/nsGNOMEShellService.cpp
+++ b/suite/components/shell/nsGNOMEShellService.cpp
@@ -17,21 +17,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"
 #include "nsIImageToPixbuf.h"
 #include "nsXULAppAPI.h"
 
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -47,16 +47,18 @@
 #define DGB_COLOR DG_BACKGROUND "/primary_color"
 
 #define OGDB_SCHEMA "org.gnome.desktop.background"
 #define OGDB_OPTIONS "picture-options"
 #define OGDB_IMAGE "picture-uri"
 #define OGDB_DRAWBG "draw-background"
 #define OGDB_COLOR "primary-color"
 
+using namespace mozilla;
+
 struct ProtocolAssociation {
   uint16_t app;
   const char* protocol;
 };
 
 struct MimeTypeAssociation {
   uint16_t app;
   const char* mimeType;
@@ -309,17 +311,17 @@ NS_IMETHODIMP
 nsGNOMEShellService::GetCanSetDesktopBackground(bool* aResult)
 {
   nsCOMPtr<nsIGConfService> gconf(do_GetService(NS_GCONFSERVICE_CONTRACTID));
   *aResult = gconf && getenv("GNOME_DESKTOP_SESSION_ID");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
+nsGNOMEShellService::SetDesktopBackground(dom::Element* aElement,
                                           int32_t aPosition)
 {
   nsCString brandName;
   nsresult rv = GetBrandName(brandName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // build the file name
   nsCString filePath(PR_GetEnv("HOME"));
--- a/suite/components/shell/nsIShellService.idl
+++ b/suite/components/shell/nsIShellService.idl
@@ -1,19 +1,20 @@
 /* -*- Mode: IDL; 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(4244d99e-0fbf-4cf3-903a-893634704e84)]
 interface nsIShellService : nsISupports
 {
   /**
    * app types we can be registered to handle
    */
   const unsigned short BROWSER = 0x0001;
   const unsigned short MAIL    = 0x0002;
@@ -73,17 +74,18 @@ interface nsIShellService : nsISupports
    * element supplied or the background image of the element supplied.
    *
    * @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
    */
 
-  void setDesktopBackground(in nsIDOMElement aElement, in long aPosition);
+  void setDesktopBackground(in Element aElement,
+                            in long aPosition);
 
   /**
    * Flags for positioning/sizing of the Desktop Background image.
    */
   const long BACKGROUND_TILE      = 1;
   const long BACKGROUND_STRETCH   = 2;
   const long BACKGROUND_CENTER    = 3;
   const long BACKGROUND_FILL      = 4;
--- a/suite/components/shell/nsMacShellService.cpp
+++ b/suite/components/shell/nsMacShellService.cpp
@@ -1,15 +1,14 @@
 /* -*- 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 "nsDirectoryServiceDefs.h"
-#include "nsIDOMElement.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsILocalFileMac.h"
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
@@ -17,21 +16,24 @@
 #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 <ApplicationServices/ApplicationServices.h>
 
 #define SAFARI_BUNDLE_IDENTIFIER "com.apple.Safari"
 
+using mozilla::dom::Element;
+
 NS_IMPL_ISUPPORTS(nsMacShellService, nsIShellService, nsIWebProgressListener)
 
 NS_IMETHODIMP
 nsMacShellService::IsDefaultClient(bool aStartupCheck, uint16_t aApps, bool *aIsDefaultClient)
 {
   // If this is the first window, maintain internal state that we've
   // checked this session (so that subsequent window opens don't show the
   // default client dialog).
@@ -170,33 +172,30 @@ nsMacShellService::SetShouldBeDefaultCli
 NS_IMETHODIMP
 nsMacShellService::GetCanSetDesktopBackground(bool* aResult)
 {
   *aResult = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement, int32_t aPosition)
+nsMacShellService::SetDesktopBackground(Element* aElement,
+                                        int32_t aPosition)
 {
   // 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;
 
   // Get the desired image file name:
   nsCOMPtr<nsIURL> imageURL(do_QueryInterface(imageURI));
   if (!imageURL)
   {
     // XXXmano (bug 300293): Non-URL images (e.g. the data: protocol) are not
@@ -230,25 +229,25 @@ 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/suite/components/shell/nsWindowsShellService.cpp
+++ b/suite/components/shell/nsWindowsShellService.cpp
@@ -5,17 +5,16 @@
 
 #include "nsWindowsShellService.h"
 
 #include "imgIContainer.h"
 #include "imgIRequest.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "nsIContent.h"
-#include "nsIDOMElement.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIOutputStream.h"
 #include "nsIPrefService.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
@@ -28,16 +27,17 @@
 #include "nsIWindowsRegKey.h"
 #include "nsUnicharUtils.h"
 #include "nsIWinTaskbar.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIURLFormatter.h"
 #include "nsThreadUtils.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
@@ -733,21 +733,21 @@ WriteBitmap(nsIFile* aFile, imgIContaine
   }
 
   dataSurface->Unmap();
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
+nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
                                             int32_t aPosition)
 {
   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)