tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit cb52781342cc905eda923d009fc0b678f3a8c8c6
parent d61558f581f35261dee00d26a1fe2ac56f212148
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Tue,  4 Nov 2025 19:11:17 +0000

Bug 1998202 - Don't use views in nsDocShell::GetVisibility. r=jwatt

We have a better function to compute pres shell visibility.

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

Diffstat:
Mdocshell/base/nsDocShell.cpp | 52+++-------------------------------------------------
1 file changed, 3 insertions(+), 49 deletions(-)

diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp @@ -4791,58 +4791,12 @@ nsDocShell::GetVisibility(bool* aVisibility) { } PresShell* presShell = GetPresShell(); - if (!presShell) { - return NS_OK; - } - - // get the view manager - nsViewManager* vm = presShell->GetViewManager(); - NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); - - // get the root view - nsView* view = vm->GetRootView(); // views are not ref counted - NS_ENSURE_TRUE(view, NS_ERROR_FAILURE); - - // if our root view is hidden, we are not visible - if (view->GetVisibility() == ViewVisibility::Hide) { + if (!presShell || presShell->IsUnderHiddenEmbedderElement()) { + // NOTE(emilio): IsUnderHiddenEmbedderElement() accounts for ancestors as + // well. return NS_OK; } - // otherwise, we must walk up the document and view trees checking - // for a hidden view, unless we're an off screen browser, which - // would make this test meaningless. - - RefPtr<nsDocShell> docShell = this; - RefPtr<nsDocShell> parentItem = docShell->GetInProcessParentDocshell(); - while (parentItem) { - // Null-check for crash in bug 267804 - if (!parentItem->GetPresShell()) { - MOZ_ASSERT_UNREACHABLE("parent docshell has null pres shell"); - return NS_OK; - } - - vm = docShell->GetPresShell()->GetViewManager(); - if (vm) { - view = vm->GetRootView(); - } - - if (view) { - view = view->GetParent(); // anonymous inner view - if (view) { - view = view->GetParent(); // subdocumentframe's view - } - } - - nsIFrame* frame = view ? view->GetFrame() : nullptr; - if (frame && !frame->IsVisibleConsideringAncestors( - nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY)) { - return NS_OK; - } - - docShell = parentItem; - parentItem = docShell->GetInProcessParentDocshell(); - } - nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_QueryInterface(mTreeOwner)); if (!treeOwnerAsWin) { *aVisibility = true;