Bug 827976 - Improve usage of the hidden window for nsXULWindow::Destroy. r=aklotz
☠☠ backed out by bf3cbcc82527 ☠ ☠
authorFelipe Gomes <felipc@gmail.com>
Fri, 01 Mar 2019 21:06:48 +0000
changeset 519896 3b64368cff52c1393816a40e7ccb9cc545f08e7a
parent 519895 69d0378e0c098473f288d02557b7871f0eb685ff
child 519897 eed600ceb6064d5f47b7bf74024fd4849c7b9e15
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz
bugs827976
milestone67.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 827976 - Improve usage of the hidden window for nsXULWindow::Destroy. r=aklotz Differential Revision: https://phabricator.services.mozilla.com/D21075
xpfe/appshell/nsXULWindow.cpp
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -457,29 +457,38 @@ NS_IMETHODIMP nsXULWindow::Destroy() {
 
 #if defined(XP_WIN)
   // We need to explicitly set the focus on Windows, but
   // only if the parent is visible.
   nsCOMPtr<nsIBaseWindow> parent(do_QueryReferent(mParentWindow));
   if (parent) {
     nsCOMPtr<nsIWidget> parentWidget;
     parent->GetMainWidget(getter_AddRefs(parentWidget));
-    if (!parentWidget || parentWidget->IsVisible()) {
-      nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
+
+    if (parentWidget && parentWidget->IsVisible()) {
+      bool isParentHiddenWindow = false;
+
       if (appShell) {
-        nsCOMPtr<nsIXULWindow> hiddenWindow;
-        appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
-        if (hiddenWindow) baseHiddenWindow = do_GetInterface(hiddenWindow);
+        bool hasHiddenWindow = false;
+        appShell->GetHasHiddenWindow(&hasHiddenWindow);
+        if (hasHiddenWindow) {
+          nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
+          nsCOMPtr<nsIXULWindow> hiddenWindow;
+          appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
+          if (hiddenWindow) {
+            baseHiddenWindow = do_GetInterface(hiddenWindow);
+            isParentHiddenWindow = (baseHiddenWindow == parent);
+          }
+        }
       }
+
       // somebody screwed up somewhere. hiddenwindow shouldn't be anybody's
       // parent. still, when it happens, skip activating it.
-      if (baseHiddenWindow != parent) {
-        nsCOMPtr<nsIWidget> parentWidget;
-        parent->GetMainWidget(getter_AddRefs(parentWidget));
-        if (parentWidget) parentWidget->PlaceBehind(eZPlacementTop, 0, true);
+      if (!isParentHiddenWindow) {
+        parentWidget->PlaceBehind(eZPlacementTop, 0, true);
       }
     }
   }
 #endif
 
   RemoveTooltipSupport();
 
   mDOMWindow = nullptr;