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-06-24 20:50:10 +00:00
parent 6e0e42e04d
commit 889fc1efd2
4 changed files with 77 additions and 71 deletions

View File

@@ -4795,9 +4795,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
@@ -8064,7 +8064,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) {
@@ -8076,7 +8075,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);
@@ -8121,9 +8119,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()