Bug 1697564 - Suspend/resume refresh URI list when bfcache lives in the parent process, r=peterv

The old setup is a tad fragile since it relies on Stop to happen at a particular moment.

The name RefreshURIToQueue is just trying to be consistent with RefreshURIFromQueue

Differential Revision: https://phabricator.services.mozilla.com/D107930
This commit is contained in:
Olli Pettay
2021-03-21 21:46:25 +00:00
parent b52ffcb906
commit 404ea9a9f5
5 changed files with 112 additions and 2 deletions

View File

@@ -1208,6 +1208,8 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
// For pagehide, set mFiredUnloadEvent to true, so that unload doesn't fire.
nsCOMPtr<nsIContentViewer> contentViewer(mContentViewer);
if (aShow) {
mRefreshURIList = std::move(mBFCachedRefreshURIList);
RefreshURIFromQueue();
mFiredUnloadEvent = false;
RefPtr<Document> doc = contentViewer->GetDocument();
if (doc) {
@@ -1247,6 +1249,16 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
} else if (!mFiredUnloadEvent) {
// XXXBFCache check again that the page can enter bfcache.
// XXXBFCache should mTiming->NotifyUnloadEventStart()/End() be called here?
if (mRefreshURIList) {
RefreshURIToQueue();
mBFCachedRefreshURIList = std::move(mRefreshURIList);
} else {
// If Stop was called, the list was moved to mSavedRefreshURIList after
// calling SuspendRefreshURIs, which calls RefreshURIToQueue.
mBFCachedRefreshURIList = std::move(mSavedRefreshURIList);
}
mFiredUnloadEvent = true;
contentViewer->PageHide(false);
@@ -5677,8 +5689,10 @@ NS_IMETHODIMP
nsDocShell::CancelRefreshURITimers() {
DoCancelRefreshURITimers(mRefreshURIList);
DoCancelRefreshURITimers(mSavedRefreshURIList);
DoCancelRefreshURITimers(mBFCachedRefreshURIList);
mRefreshURIList = nullptr;
mSavedRefreshURIList = nullptr;
mBFCachedRefreshURIList = nullptr;
return NS_OK;
}
@@ -5698,8 +5712,7 @@ nsDocShell::GetRefreshPending(bool* aResult) {
return rv;
}
NS_IMETHODIMP
nsDocShell::SuspendRefreshURIs() {
void nsDocShell::RefreshURIToQueue() {
if (mRefreshURIList) {
uint32_t n = 0;
mRefreshURIList->GetLength(&n);
@@ -5719,6 +5732,11 @@ nsDocShell::SuspendRefreshURIs() {
mRefreshURIList->ReplaceElementAt(callback, i);
}
}
}
NS_IMETHODIMP
nsDocShell::SuspendRefreshURIs() {
RefreshURIToQueue();
// Suspend refresh URIs for our child shells as well.
for (auto* child : mChildList.ForwardRange()) {