Bug 1698601 - Part 2: Carry over restore data to new context after a process swap, r=smaug

Also, make sure we update layout history state from docshell before we load a
new URI, as it might be our last chance to do so before a process swap.

Differential Revision: https://phabricator.services.mozilla.com/D110994
This commit is contained in:
Anny Gakhokidze 2021-04-09 17:46:52 +00:00
Родитель 2bf10938e6
Коммит 0985861202
2 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -175,14 +175,13 @@ void CanonicalBrowsingContext::ReplacedBy(
}
aNewContext->mWebProgress = std::move(mWebProgress);
// Bug 1698601 - We'll eventually want to copy this data over to the new
// context instead of clearing it completely.
bool hasRestoreData = !!mRestoreData && !mRestoreData->IsEmpty();
aNewContext->mRestoreData = std::move(mRestoreData);
aNewContext->mRequestedContentRestores = mRequestedContentRestores;
aNewContext->mCompletedContentRestores = mCompletedContentRestores;
SetRestoreData(nullptr);
mRequestedContentRestores = 0;
mCompletedContentRestores = 0;
aNewContext->mRestoreData = nullptr;
aNewContext->mRequestedContentRestores = 0;
aNewContext->mCompletedContentRestores = 0;
// Use the Transaction for the fields which need to be updated whether or not
// the new context has been attached before.
@ -191,7 +190,7 @@ void CanonicalBrowsingContext::ReplacedBy(
txn.SetBrowserId(GetBrowserId());
txn.SetHistoryID(GetHistoryID());
txn.SetExplicitActive(GetExplicitActive());
txn.SetHasRestoreData(false);
txn.SetHasRestoreData(hasRestoreData);
if (aNewContext->EverAttached()) {
MOZ_ALWAYS_SUCCEEDS(txn.Commit(aNewContext));
} else {

Просмотреть файл

@ -10215,6 +10215,11 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
return NS_ERROR_UNEXPECTED;
}
// Persist and sync layout history state before we load a new uri, as this
// might be our last chance to do so, in the content process.
PersistLayoutHistoryState();
SynchronizeLayoutHistoryState();
nsresult rv;
nsContentPolicyType contentPolicyType = DetermineContentType();