Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0335f94

Browse files
committed
Bug 827976 - Improve usage of the hidden window for nsXULWindow::Destroy. r=aklotz
Differential Revision: https://phabricator.services.mozilla.com/D21075 --HG-- extra : moz-landing-system : lando
1 parent f499de8 commit 0335f94

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

xpfe/appshell/nsXULWindow.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,28 @@ NS_IMETHODIMP nsXULWindow::Destroy() {
462462
if (parent) {
463463
nsCOMPtr<nsIWidget> parentWidget;
464464
parent->GetMainWidget(getter_AddRefs(parentWidget));
465-
if (!parentWidget || parentWidget->IsVisible()) {
466-
nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
465+
466+
if (parentWidget && parentWidget->IsVisible()) {
467+
bool isParentHiddenWindow = false;
468+
467469
if (appShell) {
468-
nsCOMPtr<nsIXULWindow> hiddenWindow;
469-
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
470-
if (hiddenWindow) baseHiddenWindow = do_GetInterface(hiddenWindow);
470+
bool hasHiddenWindow = false;
471+
appShell->GetHasHiddenWindow(&hasHiddenWindow);
472+
if (hasHiddenWindow) {
473+
nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
474+
nsCOMPtr<nsIXULWindow> hiddenWindow;
475+
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
476+
if (hiddenWindow) {
477+
baseHiddenWindow = do_GetInterface(hiddenWindow);
478+
isParentHiddenWindow = (baseHiddenWindow == parent);
479+
}
480+
}
471481
}
482+
472483
// somebody screwed up somewhere. hiddenwindow shouldn't be anybody's
473484
// parent. still, when it happens, skip activating it.
474-
if (baseHiddenWindow != parent) {
475-
nsCOMPtr<nsIWidget> parentWidget;
476-
parent->GetMainWidget(getter_AddRefs(parentWidget));
477-
if (parentWidget) parentWidget->PlaceBehind(eZPlacementTop, 0, true);
485+
if (!isParentHiddenWindow) {
486+
parentWidget->PlaceBehind(eZPlacementTop, 0, true);
478487
}
479488
}
480489
}

0 commit comments

Comments
 (0)