Bug 1618117 - Use BrowsingContext for activeness check in FocusOuter. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D64299

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2020-02-27 13:01:49 +00:00
parent a1b1d6ff88
commit 0ca10cda09

View File

@ -4835,15 +4835,22 @@ void nsGlobalWindowOuter::FocusOuter(CallerType aCallerType) {
RevisePopupAbuseLevel(PopupBlocker::GetPopupControlState()) <
PopupBlocker::openBlocked);
nsCOMPtr<mozIDOMWindowProxy> activeDOMWindow;
fm->GetActiveWindow(getter_AddRefs(activeDOMWindow));
bool isActive = false;
if (XRE_IsParentProcess()) {
nsCOMPtr<nsPIDOMWindowOuter> activeWindow = fm->GetActiveWindow();
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsPIDOMWindowOuter> rootWin =
rootItem ? rootItem->GetWindow() : nullptr;
auto* activeWindow = nsPIDOMWindowOuter::From(activeDOMWindow);
bool isActive = (rootWin == activeWindow);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsPIDOMWindowOuter> rootWin =
rootItem ? rootItem->GetWindow() : nullptr;
isActive = (rootWin == activeWindow);
} else {
BrowsingContext* activeBrowsingContext = fm->GetActiveBrowsingContext();
BrowsingContext* bc = GetBrowsingContext();
if (bc) {
isActive = (activeBrowsingContext == bc->Top());
}
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
if (treeOwnerAsWin && (canFocus || isActive)) {