tor-browser

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

commit 89469a79a9f89be7ad7abc7cde55f3f88dc1cb89
parent 56149b17a6bc4f1afafdbf1999edec1bd00991ce
Author: Andreas Farre <farre@mozilla.com>
Date:   Thu, 23 Oct 2025 14:01:39 +0000

Bug 1995956 - Don't re-create contiguous entry list in bfcache navigations. r=jjaschke

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

Diffstat:
Mdocshell/base/CanonicalBrowsingContext.cpp | 10++++------
Mdocshell/base/CanonicalBrowsingContext.h | 2+-
Mdocshell/shistory/nsSHistory.cpp | 4++--
3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp @@ -359,7 +359,7 @@ void CanonicalBrowsingContext::ReplacedBy( mActiveEntry.swap(aNewContext->mActiveEntry); if (Navigation::IsAPIEnabled()) { MOZ_ASSERT(aNewContext->mActiveEntryList.isEmpty()); - aNewContext->mActiveEntryList.extendBack(std::move(mActiveEntryList)); + aNewContext->mActiveEntryList = std::move(mActiveEntryList); } aNewContext->mPermanentKey = mPermanentKey; @@ -482,14 +482,12 @@ SessionHistoryEntry* CanonicalBrowsingContext::GetActiveSessionHistoryEntry() { return mActiveEntry; } -void CanonicalBrowsingContext::SetActiveSessionHistoryEntry( +void CanonicalBrowsingContext::SetActiveSessionHistoryEntryFromBFCache( SessionHistoryEntry* aEntry) { mActiveEntry = aEntry; if (Navigation::IsAPIEnabled()) { - mActiveEntryList.clear(); - if (mActiveEntry) { - mActiveEntryList.insertBack(mActiveEntry); - } + MOZ_DIAGNOSTIC_ASSERT(!aEntry || mActiveEntryList.contains(aEntry)); + MOZ_DIAGNOSTIC_ASSERT(aEntry || mActiveEntryList.isEmpty()); } } diff --git a/docshell/base/CanonicalBrowsingContext.h b/docshell/base/CanonicalBrowsingContext.h @@ -128,7 +128,7 @@ class CanonicalBrowsingContext final : public BrowsingContext { nsISHistory* GetSessionHistory(); SessionHistoryEntry* GetActiveSessionHistoryEntry(); - void SetActiveSessionHistoryEntry(SessionHistoryEntry* aEntry); + void SetActiveSessionHistoryEntryFromBFCache(SessionHistoryEntry* aEntry); bool ManuallyManagesActiveness() const; diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp @@ -1319,8 +1319,8 @@ static void FinishRestore(CanonicalBrowsingContext* aBrowsingContext, } // ReplacedBy will swap the entry back. - aBrowsingContext->SetActiveSessionHistoryEntry(aEntry); - loadingBC->SetActiveSessionHistoryEntry(nullptr); + aBrowsingContext->SetActiveSessionHistoryEntryFromBFCache(aEntry); + loadingBC->SetActiveSessionHistoryEntryFromBFCache(nullptr); NavigationIsolationOptions options; aBrowsingContext->ReplacedBy(loadingBC, options);