Bug 1717983 - Improve PresShell active flag handling. r=nika

This moves the logic of whether a pres shell should be active to a
single place to make it sane to reason about, and fixes the
subdocument propagation when a BrowserChild becomes visible.

Differential Revision: https://phabricator.services.mozilla.com/D118703
This commit is contained in:
Emilio Cobos Álvarez
2021-07-05 17:31:48 +00:00
parent 76e9f0ae2f
commit 1af5e8922e
4 changed files with 78 additions and 71 deletions

View File

@@ -4721,9 +4721,9 @@ nsDocShell::GetVisibility(bool* aVisibility) {
}
void nsDocShell::ActivenessMaybeChanged() {
bool isActive = mBrowsingContext->IsActive();
const bool isActive = mBrowsingContext->IsActive();
if (RefPtr<PresShell> presShell = GetPresShell()) {
presShell->SetIsActive(isActive);
presShell->ActivenessMaybeChanged();
}
// Tell the window about it
@@ -7990,7 +7990,6 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
}
nscolor bgcolor = NS_RGBA(0, 0, 0, 0);
bool isActive = false;
// Ensure that the content viewer is destroyed *after* the GC - bug 71515
nsCOMPtr<nsIContentViewer> contentViewer = mContentViewer;
if (contentViewer) {
@@ -8002,7 +8001,6 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
// presentation shell, so we can use it for the next document.
if (PresShell* presShell = contentViewer->GetPresShell()) {
bgcolor = presShell->GetCanvasBackground();
isActive = presShell->IsActive();
}
contentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
@@ -8047,9 +8045,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
// pres shell. This improves page load continuity.
if (RefPtr<PresShell> presShell = mContentViewer->GetPresShell()) {
presShell->SetCanvasBackground(bgcolor);
if (isActive) {
presShell->SetIsActive(isActive);
}
presShell->ActivenessMaybeChanged();
}
// XXX: It looks like the LayoutState gets restored again in Embed()