From 8c4c21dae92f58ef457b6f0c98b79dd7ccf96c3c Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 9 Nov 2020 14:57:54 +0000 Subject: [PATCH] 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 --- dom/base/nsFocusManager.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index bf73fe8482b5..419fa14a68bb 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -2226,26 +2226,21 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear, // content if (BrowserParent* remote = BrowserParent::GetFrom(element)) { MOZ_ASSERT(XRE_IsParentProcess()); - // First, let's deactivate all out-of-process iframes. + // Let's deactivate all remote browsers. BrowsingContext* topLevelBrowsingContext = remote->GetBrowsingContext(); topLevelBrowsingContext->PreOrderWalk([&](BrowsingContext* aContext) { - WindowGlobalParent* windowGlobalParent = - aContext->Canonical()->GetCurrentWindowGlobal(); - if (windowGlobalParent) { - RefPtr browserParent = - windowGlobalParent->GetBrowserParent(); - if (browserParent) { + if (WindowGlobalParent* windowGlobalParent = + aContext->Canonical()->GetCurrentWindowGlobal()) { + if (RefPtr browserParent = + windowGlobalParent->GetBrowserParent()) { browserParent->Deactivate(windowBeingLowered); - LOGFOCUS(("OOP iframe remote browser deactivated %p, %d", remote, - windowBeingLowered)); + LOGFOCUS(("%s remote browser deactivated %p, %d", + 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