mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1664329 - Make HandleSameDocumentNavigation handle loads from session history, r=peterv
Need to mark entries as being loading sooner, since HandleSameDocumentNavigation case doesn't do the round trip through parent again. And HandleSameDocumentNavigation needs to update active entry and inform parent that is has dealt with the load. Differential Revision: https://phabricator.services.mozilla.com/D89837
This commit is contained in:
parent
c94da127a2
commit
ea62e522c0
@ -303,6 +303,12 @@ void CanonicalBrowsingContext::SwapHistoryEntries(nsISHEntry* aOldEntry,
|
||||
}
|
||||
}
|
||||
|
||||
void CanonicalBrowsingContext::AddLoadingSessionHistoryEntry(
|
||||
uint64_t aLoadId, SessionHistoryEntry* aEntry) {
|
||||
Unused << SetHistoryID(aEntry->DocshellID());
|
||||
mLoadingEntries.AppendElement(LoadingSessionHistoryEntry{aLoadId, aEntry});
|
||||
}
|
||||
|
||||
UniquePtr<LoadingSessionHistoryInfo>
|
||||
CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
|
||||
nsDocShellLoadState* aLoadState, nsIChannel* aChannel) {
|
||||
@ -311,7 +317,6 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
|
||||
aLoadState->GetLoadingSessionHistoryInfo();
|
||||
if (existingLoadingInfo) {
|
||||
entry = SessionHistoryEntry::GetByLoadId(existingLoadingInfo->mLoadId);
|
||||
Unused << SetHistoryID(entry->DocshellID());
|
||||
} else {
|
||||
entry = new SessionHistoryEntry(aLoadState, aChannel);
|
||||
entry->SetDocshellID(GetHistoryID());
|
||||
@ -324,11 +329,12 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
|
||||
loadingInfo = MakeUnique<LoadingSessionHistoryInfo>(*existingLoadingInfo);
|
||||
} else {
|
||||
loadingInfo = MakeUnique<LoadingSessionHistoryInfo>(entry);
|
||||
mLoadingEntries.AppendElement(
|
||||
LoadingSessionHistoryEntry{loadingInfo->mLoadId, entry});
|
||||
}
|
||||
|
||||
MOZ_ASSERT(SessionHistoryEntry::GetByLoadId(loadingInfo->mLoadId) == entry);
|
||||
mLoadingEntries.AppendElement(
|
||||
LoadingSessionHistoryEntry{loadingInfo->mLoadId, entry});
|
||||
|
||||
return loadingInfo;
|
||||
}
|
||||
|
||||
|
@ -221,6 +221,9 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||
|
||||
void SwapHistoryEntries(nsISHEntry* aOldEntry, nsISHEntry* aNewEntry);
|
||||
|
||||
void AddLoadingSessionHistoryEntry(uint64_t aLoadId,
|
||||
SessionHistoryEntry* aEntry);
|
||||
|
||||
protected:
|
||||
// Called when the browsing context is being discarded.
|
||||
void CanonicalDiscard();
|
||||
|
@ -8656,6 +8656,12 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
// buttons.
|
||||
SetHistoryEntryAndUpdateBC(Some<nsISHEntry*>(aLoadState->SHEntry()),
|
||||
Nothing());
|
||||
UniquePtr<mozilla::dom::LoadingSessionHistoryInfo> oldLoadingEntry;
|
||||
mLoadingEntry.swap(oldLoadingEntry);
|
||||
if (aLoadState->GetLoadingSessionHistoryInfo()) {
|
||||
mLoadingEntry = MakeUnique<LoadingSessionHistoryInfo>(
|
||||
*aLoadState->GetLoadingSessionHistoryInfo());
|
||||
}
|
||||
|
||||
// Set the doc's URI according to the new history entry's URI.
|
||||
RefPtr<Document> doc = GetDocument();
|
||||
@ -8787,6 +8793,26 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
SetCacheKeyOnHistoryEntry(mOSHE, cacheKey);
|
||||
}
|
||||
}
|
||||
if (StaticPrefs::fission_sessionHistoryInParent() && mLoadingEntry) {
|
||||
mActiveEntry = MakeUnique<SessionHistoryInfo>(mLoadingEntry->mInfo);
|
||||
nsID changeID = {};
|
||||
if (XRE_IsParentProcess()) {
|
||||
mBrowsingContext->Canonical()->SessionHistoryCommit(
|
||||
mLoadingEntry->mLoadId, changeID);
|
||||
} else {
|
||||
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||
if (rootSH) {
|
||||
// This is a load from session history, so we can update
|
||||
// index and length immediately.
|
||||
rootSH->SetIndexAndLength(mLoadingEntry->mRequestedIndex,
|
||||
mLoadingEntry->mSessionHistoryLength,
|
||||
changeID);
|
||||
}
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
mozilla::Unused << cc->SendHistoryCommit(
|
||||
mBrowsingContext, mLoadingEntry->mLoadId, changeID);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the title for the SH entry for this target url so that
|
||||
* SH menus in go/back/forward buttons won't be empty for this.
|
||||
@ -8801,6 +8827,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
* while same document navigation was initiated.
|
||||
*/
|
||||
SetHistoryEntryAndUpdateBC(Some<nsISHEntry*>(oldLSHE), Nothing());
|
||||
mLoadingEntry.swap(oldLoadingEntry);
|
||||
|
||||
/* Set the title for the Global History entry for this anchor url.
|
||||
*/
|
||||
|
@ -1839,6 +1839,12 @@ void nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry,
|
||||
loadState->SetLoadIsFromSessionHistory(mRequestedIndex, Length(),
|
||||
loadingFromActiveEntry);
|
||||
|
||||
if (StaticPrefs::fission_sessionHistoryInParent()) {
|
||||
nsCOMPtr<SessionHistoryEntry> she = do_QueryInterface(aFrameEntry);
|
||||
aFrameBC->Canonical()->AddLoadingSessionHistoryEntry(
|
||||
loadState->GetLoadingSessionHistoryInfo()->mLoadId, she);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> originalURI = aFrameEntry->GetOriginalURI();
|
||||
loadState->SetOriginalURI(originalURI);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user