Bug 827976 - Improve usage of the hidden window for nsXULWindow::Destroy. r=aklotz
authorFelipe Gomes <felipc@gmail.com>
Mon, 04 Mar 2019 18:52:49 +0000
changeset 520347 3a2cf44afaa30fad24b970e7b129b341ce47a949
parent 520346 3606e7bc5406e202e814abd09d7d463ada1e32f6
child 520348 8e41627afd1ddaf646079a048698f40bf88608ae
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;