tor-browser

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

commit 2daf4952091c5a6c5405a2dd7e60d145d9d21406
parent 5b32901920558ad4d7545add824ee76120192a86
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Mon,  3 Nov 2025 13:41:02 +0000

Bug 1997763 - Factor document viewer destruction into its own function. r=dom-core,smaug

No behavior change but noticed while looking / poking at this code for
bug 1994942.

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

Diffstat:
Mdocshell/base/nsDocShell.cpp | 21+++++++++++----------
Mdocshell/base/nsDocShell.h | 1+
2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp @@ -392,17 +392,22 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext, #endif } +void nsDocShell::DestroyDocumentViewer() { + if (!mDocumentViewer) { + return; + } + mDocumentViewer->Close(nullptr); + mDocumentViewer->Destroy(); + mDocumentViewer = nullptr; +} + nsDocShell::~nsDocShell() { // Avoid notifying observers while we're in the dtor. mIsBeingDestroyed = true; Destroy(); - if (mDocumentViewer) { - mDocumentViewer->Close(nullptr); - mDocumentViewer->Destroy(); - mDocumentViewer = nullptr; - } + DestroyDocumentViewer(); MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p destroyed\n", this)); @@ -4564,11 +4569,7 @@ nsDocShell::Destroy() { docShellParentAsItem->RemoveChild(this); } - if (mDocumentViewer) { - mDocumentViewer->Close(nullptr); - mDocumentViewer->Destroy(); - mDocumentViewer = nullptr; - } + DestroyDocumentViewer(); nsDocLoader::Destroy(); diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h @@ -577,6 +577,7 @@ class nsDocShell final : public nsDocLoader, // nsresult EnsureDocumentViewer(); + void DestroyDocumentViewer(); // aPrincipal can be passed in if the caller wants. If null is // passed in, the about:blank principal will end up being used.