Bug 1509060 - Port bug 1489833: Remove use of nsIWindowMediator::GetZOrderDOMWindowEnumerator. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Wed, 21 Nov 2018 21:17:47 +0100
changeset 33752 aa31b79e0b50b35696312451bb25664b3e998a81
parent 33751 8429a12e23afdc625af4543a64113d995529e43a
child 33753 4ddaece5b9625bc57152af84385bd4f66d0c6195
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersbustage-fix
bugs1509060, 1489833
Bug 1509060 - Port bug 1489833: Remove use of nsIWindowMediator::GetZOrderDOMWindowEnumerator. rs=bustage-fix
mail/base/content/mailCore.js
mail/base/content/msgMail3PaneWindow.js
mail/components/devtools/tb-root-actor.js
mail/components/extensions/parent/ext-mail.js
mailnews/base/src/nsMsgMailSession.cpp
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -629,42 +629,28 @@ function safeModeRestart() {
                         .getService(Ci.nsIEnvironment);
     environment.set("MOZ_SAFE_MODE_RESTART", "1");
     BrowserUtils.restartApplication();
   }
 }
 
 function getMostRecentMailWindow() {
   let win = null;
-  if (AppConstants.platform != "win") {
-    // Platforms other than Windows have a broken z-order...
-    win = Services.wm.getMostRecentWindow("mail:3pane", true);
+
+  win = Services.wm.getMostRecentWindow("mail:3pane", true);
 
-    // If we're lucky, this isn't a popup, and we can just return this.
-    if (win && win.document.documentElement.getAttribute("chromehidden")) {
-      win = null;
-      let windowList = Services.wm.getEnumerator("mail:3pane", true);
-      // This is oldest to newest, so this gets a bit ugly.
-      while (windowList.hasMoreElements()) {
-        let nextWin = windowList.getNext();
-        if (!nextWin.document.documentElement.getAttribute("chromehidden"))
-          win = nextWin;
-      }
-    }
-  } else {
-    let windowList = Services.wm.getZOrderDOMWindowEnumerator("mail:3pane", true);
-    if (!windowList.hasMoreElements())
-      return null;
-
-    win = windowList.getNext();
-    while (win.document.documentElement.getAttribute("chromehidden")) {
-      if (!windowList.hasMoreElements())
-        return null;
-
-      win = windowList.getNext();
+  // If we're lucky, this isn't a popup, and we can just return this.
+  if (win && win.document.documentElement.getAttribute("chromehidden")) {
+    win = null;
+    let windowList = Services.wm.getEnumerator("mail:3pane", true);
+    // This is oldest to newest, so this gets a bit ugly.
+    while (windowList.hasMoreElements()) {
+      let nextWin = windowList.getNext();
+      if (!nextWin.document.documentElement.getAttribute("chromehidden"))
+        win = nextWin;
     }
   }
 
   return win;
 }
 
 /**
  * Create a sanitized display name for an attachment in order to help prevent
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -662,18 +662,16 @@ function HandleAppCommandEvent(evt) {
       break;
   }
 }
 
 /**
  * Look for another 3-pane window.
  */
 function FindOther3PaneWindow() {
-  // XXX We'd like to use getZOrderDOMWindowEnumerator here, but it doesn't work
-  // on Linux
   let enumerator = Services.wm.getEnumerator("mail:3pane");
   while (enumerator.hasMoreElements()) {
     let win = enumerator.getNext();
     if (win != window)
       return win;
   }
   return null;
 }
--- a/mail/components/devtools/tb-root-actor.js
+++ b/mail/components/devtools/tb-root-actor.js
@@ -150,17 +150,17 @@ TBTabList.prototype = {
   _notifyListChanged() {
     if (this._onListChanged && this._mustNotify) {
       this._onListChanged();
       this._mustNotify = false;
     }
   },
 
   _getTopWindow() {
-    let winIter = Services.wm.getZOrderDOMWindowEnumerator(null, true);
+    let winIter = Services.wm.getEnumerator(null, true);
     while (winIter.hasMoreElements()) {
       let win = winIter.getNext();
       if (this._checkedWindows.has(appShellDOMWindowType(win))) {
         // This is one of our windows, return it
         return win;
       }
     }
     return null;
--- a/mail/components/extensions/parent/ext-mail.js
+++ b/mail/components/extensions/parent/ext-mail.js
@@ -123,44 +123,28 @@ class WindowTracker extends WindowTracke
    * The currently active, or topmost, mail window, or null if no mail window is currently open.
    * Will only return the topmost "normal" (i.e., not popup) window.
    *
    * @property {?DOMWindow} topNormalWindow
    * @readonly
    */
   get topNormalWindow() {
     let win = null;
-    if (AppConstants.platform == "win") {
-      let windowList = Services.wm.getZOrderDOMWindowEnumerator("mail:3pane", true);
-      if (!windowList.hasMoreElements()) {
-        return null;
-      }
 
-      win = windowList.getNext();
-      while (win.document.documentElement.getAttribute("chromehidden")) {
-        if (!windowList.hasMoreElements()) {
-          return null;
-        }
+    win = Services.wm.getMostRecentWindow("mail:3pane", true);
 
-        win = windowList.getNext();
-      }
-    } else {
-      // Platforms other than Windows have a broken z-order...
-      win = Services.wm.getMostRecentWindow("mail:3pane", true);
-
-      // If we're lucky, this isn't a popup, and we can just return this.
-      if (win && win.document.documentElement.getAttribute("chromehidden")) {
-        win = null;
-        let windowList = Services.wm.getEnumerator("mail:3pane", true);
-        // This is oldest to newest, so this gets a bit ugly.
-        while (windowList.hasMoreElements()) {
-          let nextWin = windowList.getNext();
-          if (!nextWin.document.documentElement.getAttribute("chromehidden")) {
-            win = nextWin;
-          }
+    // If we're lucky, this isn't a popup, and we can just return this.
+    if (win && win.document.documentElement.getAttribute("chromehidden")) {
+      win = null;
+      let windowList = Services.wm.getEnumerator("mail:3pane", true);
+      // This is oldest to newest, so this gets a bit ugly.
+      while (windowList.hasMoreElements()) {
+        let nextWin = windowList.getNext();
+        if (!nextWin.document.documentElement.getAttribute("chromehidden")) {
+          win = nextWin;
         }
       }
     }
 
     return win;
   }
 }
 
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -260,25 +260,17 @@ nsresult nsMsgMailSession::GetTopmostMsg
     // The msgWindows array does not hold z-order info. Use mediator to get
     // the top most window then match that with the msgWindows array.
     nsCOMPtr<nsIWindowMediator> windowMediator =
       do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsISimpleEnumerator> windowEnum;
 
-#if defined (XP_UNIX)
-    // The window managers under Unix/X11 do not support ZOrder information,
-    // so we have to use the normal enumeration call here.
     rv = windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnum));
-#else
-    rv = windowMediator->GetZOrderDOMWindowEnumerator(nullptr, true,
-                                                      getter_AddRefs(windowEnum));
-#endif
-
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsISupports> windowSupports;
     nsCOMPtr<nsPIDOMWindowOuter> topMostWindow;
     nsAutoString windowType;
     bool more;
 
     // loop to get the top most with attribute "mail:3pane" or "mail:messageWindow"