Bug 1676127 - Don't deactivate top-level remote browser twice when browser window is lowered; r=hsivonen

Differential Revision: https://phabricator.services.mozilla.com/D96404
This commit is contained in:
Edgar Chen 2020-11-09 14:57:54 +00:00
Родитель 097ee80074
Коммит 8c4c21dae9
1 изменённых файлов: 9 добавлений и 14 удалений

Просмотреть файл

@ -2226,26 +2226,21 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
// content // content
if (BrowserParent* remote = BrowserParent::GetFrom(element)) { if (BrowserParent* remote = BrowserParent::GetFrom(element)) {
MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(XRE_IsParentProcess());
// First, let's deactivate all out-of-process iframes. // Let's deactivate all remote browsers.
BrowsingContext* topLevelBrowsingContext = remote->GetBrowsingContext(); BrowsingContext* topLevelBrowsingContext = remote->GetBrowsingContext();
topLevelBrowsingContext->PreOrderWalk([&](BrowsingContext* aContext) { topLevelBrowsingContext->PreOrderWalk([&](BrowsingContext* aContext) {
WindowGlobalParent* windowGlobalParent = if (WindowGlobalParent* windowGlobalParent =
aContext->Canonical()->GetCurrentWindowGlobal(); aContext->Canonical()->GetCurrentWindowGlobal()) {
if (windowGlobalParent) { if (RefPtr<BrowserParent> browserParent =
RefPtr<BrowserParent> browserParent = windowGlobalParent->GetBrowserParent()) {
windowGlobalParent->GetBrowserParent();
if (browserParent) {
browserParent->Deactivate(windowBeingLowered); browserParent->Deactivate(windowBeingLowered);
LOGFOCUS(("OOP iframe remote browser deactivated %p, %d", remote, LOGFOCUS(("%s remote browser deactivated %p, %d",
windowBeingLowered)); aContext == topLevelBrowsingContext ? "Top-level"
: "OOP iframe",
browserParent.get(), windowBeingLowered));
} }
} }
}); });
// Now deactivate the top-level Web page.
remote->Deactivate(windowBeingLowered);
LOGFOCUS(("Top-level Remote browser deactivated %p, %d", remote,
windowBeingLowered));
} }
// Same as above but for out-of-process iframes // Same as above but for out-of-process iframes