зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1696923 - [SHIP] Update SaveLayoutStateFlag after page load similarly to in-process session history, r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D107479
This commit is contained in:
Родитель
ca10096bc9
Коммит
a2d036fda6
|
@ -953,7 +953,7 @@ class nsDocShell final : public nsDocLoader,
|
||||||
bool IsFrame() { return mBrowsingContext->IsFrame(); }
|
bool IsFrame() { return mBrowsingContext->IsFrame(); }
|
||||||
bool CanSetOriginAttributes();
|
bool CanSetOriginAttributes();
|
||||||
bool ShouldBlockLoadingForBackButton();
|
bool ShouldBlockLoadingForBackButton();
|
||||||
bool ShouldDiscardLayoutState(nsIHttpChannel* aChannel);
|
static bool ShouldDiscardLayoutState(nsIHttpChannel* aChannel);
|
||||||
bool HasUnloadedParent();
|
bool HasUnloadedParent();
|
||||||
bool JustStartedNetworkLoad();
|
bool JustStartedNetworkLoad();
|
||||||
bool NavigationBlockedByPrinting(bool aDisplayErrorDialog = true);
|
bool NavigationBlockedByPrinting(bool aDisplayErrorDialog = true);
|
||||||
|
|
|
@ -199,6 +199,12 @@ bool SessionHistoryInfo::IsSubFrame() const {
|
||||||
return mSharedState.Get()->mIsFrameNavigation;
|
return mSharedState.Get()->mIsFrameNavigation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionHistoryInfo::SetSaveLayoutStateFlag(bool aSaveLayoutStateFlag) {
|
||||||
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
static_cast<SHEntrySharedParentState*>(mSharedState.Get())->mSaveLayoutState =
|
||||||
|
aSaveLayoutStateFlag;
|
||||||
|
}
|
||||||
|
|
||||||
void SessionHistoryInfo::FillLoadInfo(nsDocShellLoadState& aLoadState) const {
|
void SessionHistoryInfo::FillLoadInfo(nsDocShellLoadState& aLoadState) const {
|
||||||
aLoadState.SetOriginalURI(mOriginalURI);
|
aLoadState.SetOriginalURI(mOriginalURI);
|
||||||
aLoadState.SetMaybeResultPrincipalURI(Some(mResultPrincipalURI));
|
aLoadState.SetMaybeResultPrincipalURI(Some(mResultPrincipalURI));
|
||||||
|
|
|
@ -135,6 +135,8 @@ class SessionHistoryInfo {
|
||||||
|
|
||||||
uint32_t LoadType() { return mLoadType; }
|
uint32_t LoadType() { return mLoadType; }
|
||||||
|
|
||||||
|
void SetSaveLayoutStateFlag(bool aSaveLayoutStateFlag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SessionHistoryEntry;
|
friend class SessionHistoryEntry;
|
||||||
friend struct mozilla::ipc::IPDLParamTraits<SessionHistoryInfo>;
|
friend struct mozilla::ipc::IPDLParamTraits<SessionHistoryInfo>;
|
||||||
|
|
|
@ -1199,20 +1199,8 @@ void nsSHistory::LoadURIOrBFCache(LoadEntryResult& aLoadEntry) {
|
||||||
RefPtr<nsFrameLoader> frameLoader = she->GetFrameLoader();
|
RefPtr<nsFrameLoader> frameLoader = she->GetFrameLoader();
|
||||||
if (canonicalBC->Group()->Toplevels().Length() == 1 && frameLoader &&
|
if (canonicalBC->Group()->Toplevels().Length() == 1 && frameLoader &&
|
||||||
(!currentShe || she->SharedInfo() != currentShe->SharedInfo())) {
|
(!currentShe || she->SharedInfo() != currentShe->SharedInfo())) {
|
||||||
nsTArray<RefPtr<PContentParent::CanSavePresentationPromise>>
|
auto restore = [canonicalBC, loadState,
|
||||||
canSavePromises;
|
she](const nsTArray<bool> aCanSaves) {
|
||||||
canonicalBC->Group()->EachParent([&](ContentParent* aParent) {
|
|
||||||
RefPtr<PContentParent::CanSavePresentationPromise> canSave =
|
|
||||||
aParent->SendCanSavePresentation(canonicalBC, Nothing());
|
|
||||||
canSavePromises.AppendElement(canSave);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check if the current page can enter bfcache.
|
|
||||||
PContentParent::CanSavePresentationPromise::All(
|
|
||||||
GetCurrentSerialEventTarget(), canSavePromises)
|
|
||||||
->Then(
|
|
||||||
GetMainThreadSerialEventTarget(), __func__,
|
|
||||||
[canonicalBC, loadState, she](const nsTArray<bool> aCanSaves) {
|
|
||||||
bool canSave = !aCanSaves.Contains(false);
|
bool canSave = !aCanSaves.Contains(false);
|
||||||
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug,
|
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug,
|
||||||
("nsSHistory::LoadURIOrBFCache "
|
("nsSHistory::LoadURIOrBFCache "
|
||||||
|
@ -1232,17 +1220,15 @@ void nsSHistory::LoadURIOrBFCache(LoadEntryResult& aLoadEntry) {
|
||||||
frameLoaderOwner->GetFrameLoader();
|
frameLoaderOwner->GetFrameLoader();
|
||||||
// The current page can be bfcached, store the
|
// The current page can be bfcached, store the
|
||||||
// nsFrameLoader in the current SessionHistoryEntry.
|
// nsFrameLoader in the current SessionHistoryEntry.
|
||||||
if (canSave &&
|
if (canSave && canonicalBC->GetActiveSessionHistoryEntry()) {
|
||||||
canonicalBC->GetActiveSessionHistoryEntry()) {
|
canonicalBC->GetActiveSessionHistoryEntry()->SetFrameLoader(
|
||||||
canonicalBC->GetActiveSessionHistoryEntry()
|
currentFrameLoader);
|
||||||
->SetFrameLoader(currentFrameLoader);
|
|
||||||
Unused << canonicalBC->SetIsInBFCache(true);
|
Unused << canonicalBC->SetIsInBFCache(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplacedBy will swap the entry back.
|
// ReplacedBy will swap the entry back.
|
||||||
canonicalBC->SetActiveSessionHistoryEntry(she);
|
canonicalBC->SetActiveSessionHistoryEntry(she);
|
||||||
loadingBC->Canonical()->SetActiveSessionHistoryEntry(
|
loadingBC->Canonical()->SetActiveSessionHistoryEntry(nullptr);
|
||||||
nullptr);
|
|
||||||
RemotenessChangeOptions options;
|
RemotenessChangeOptions options;
|
||||||
canonicalBC->ReplacedBy(loadingBC->Canonical(), options);
|
canonicalBC->ReplacedBy(loadingBC->Canonical(), options);
|
||||||
frameLoaderOwner->ReplaceFrameLoader(fl);
|
frameLoaderOwner->ReplaceFrameLoader(fl);
|
||||||
|
@ -1254,9 +1240,7 @@ void nsSHistory::LoadURIOrBFCache(LoadEntryResult& aLoadEntry) {
|
||||||
}
|
}
|
||||||
// The current active entry should not store
|
// The current active entry should not store
|
||||||
// nsFrameLoader.
|
// nsFrameLoader.
|
||||||
loadingBC->Canonical()
|
loadingBC->Canonical()->GetSessionHistory()->UpdateIndex();
|
||||||
->GetSessionHistory()
|
|
||||||
->UpdateIndex();
|
|
||||||
loadingBC->Canonical()->HistoryCommitIndexAndLength();
|
loadingBC->Canonical()->HistoryCommitIndexAndLength();
|
||||||
Unused << loadingBC->SetIsInBFCache(false);
|
Unused << loadingBC->SetIsInBFCache(false);
|
||||||
// ResetSHEntryHasUserInteractionCache(); ?
|
// ResetSHEntryHasUserInteractionCache(); ?
|
||||||
|
@ -1269,7 +1253,29 @@ void nsSHistory::LoadURIOrBFCache(LoadEntryResult& aLoadEntry) {
|
||||||
|
|
||||||
// Fall back to do a normal load.
|
// Fall back to do a normal load.
|
||||||
canonicalBC->LoadURI(loadState, false);
|
canonicalBC->LoadURI(loadState, false);
|
||||||
},
|
};
|
||||||
|
|
||||||
|
if (currentShe && !currentShe->GetSaveLayoutStateFlag()) {
|
||||||
|
// Current page can't enter bfcache because of
|
||||||
|
// SaveLayoutStateFlag, just run the restore immediately.
|
||||||
|
nsTArray<bool> canSaves;
|
||||||
|
canSaves.AppendElement(false);
|
||||||
|
restore(std::move(canSaves));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsTArray<RefPtr<PContentParent::CanSavePresentationPromise>>
|
||||||
|
canSavePromises;
|
||||||
|
canonicalBC->Group()->EachParent([&](ContentParent* aParent) {
|
||||||
|
RefPtr<PContentParent::CanSavePresentationPromise> canSave =
|
||||||
|
aParent->SendCanSavePresentation(canonicalBC, Nothing());
|
||||||
|
canSavePromises.AppendElement(canSave);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if the current page can enter bfcache.
|
||||||
|
PContentParent::CanSavePresentationPromise::All(
|
||||||
|
GetCurrentSerialEventTarget(), canSavePromises)
|
||||||
|
->Then(GetMainThreadSerialEventTarget(), __func__, std::move(restore),
|
||||||
[canonicalBC, loadState](mozilla::ipc::ResponseRejectReason) {
|
[canonicalBC, loadState](mozilla::ipc::ResponseRejectReason) {
|
||||||
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug,
|
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug,
|
||||||
("nsSHistory::LoadURIOrBFCache "
|
("nsSHistory::LoadURIOrBFCache "
|
||||||
|
|
|
@ -1634,7 +1634,10 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
|
||||||
(mLoadStateLoadType == LOAD_NORMAL ||
|
(mLoadStateLoadType == LOAD_NORMAL ||
|
||||||
mLoadStateLoadType == LOAD_HISTORY || mLoadStateLoadType == LOAD_LINK ||
|
mLoadStateLoadType == LOAD_HISTORY || mLoadStateLoadType == LOAD_LINK ||
|
||||||
mLoadStateLoadType == LOAD_STOP_CONTENT ||
|
mLoadStateLoadType == LOAD_STOP_CONTENT ||
|
||||||
mLoadStateLoadType == LOAD_STOP_CONTENT_AND_REPLACE)) {
|
mLoadStateLoadType == LOAD_STOP_CONTENT_AND_REPLACE) &&
|
||||||
|
(!browsingContext->GetActiveSessionHistoryEntry() ||
|
||||||
|
browsingContext->GetActiveSessionHistoryEntry()
|
||||||
|
->GetSaveLayoutStateFlag())) {
|
||||||
options.mReplaceBrowsingContext = true;
|
options.mReplaceBrowsingContext = true;
|
||||||
options.mTryUseBFCache = true;
|
options.mTryUseBFCache = true;
|
||||||
}
|
}
|
||||||
|
@ -2134,6 +2137,11 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
|
||||||
httpsOnlyStatus |= nsILoadInfo::HTTPS_ONLY_TOP_LEVEL_LOAD_IN_PROGRESS;
|
httpsOnlyStatus |= nsILoadInfo::HTTPS_ONLY_TOP_LEVEL_LOAD_IN_PROGRESS;
|
||||||
loadInfo->SetHttpsOnlyStatus(httpsOnlyStatus);
|
loadInfo->SetHttpsOnlyStatus(httpsOnlyStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mLoadingSessionHistoryInfo &&
|
||||||
|
nsDocShell::ShouldDiscardLayoutState(httpChannel)) {
|
||||||
|
mLoadingSessionHistoryInfo->mInfo.SetSaveLayoutStateFlag(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* loadingContext = GetLoadingBrowsingContext();
|
auto* loadingContext = GetLoadingBrowsingContext();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче