Bug 1661317 - Make loading session history entries for iframes work when session history lives in the parent process (step 1.5), r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D88450
This commit is contained in:
Olli Pettay 2020-08-31 10:05:53 +00:00
Родитель b07cfb3c72
Коммит 7d2b65e50b
4 изменённых файлов: 20 добавлений и 13 удалений

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

@ -295,7 +295,7 @@ void CanonicalBrowsingContext::SwapHistoryEntries(nsISHEntry* aOldEntry,
// XXX Should we check also loading entries?
if (mActiveEntry == aOldEntry) {
nsCOMPtr<SessionHistoryEntry> newEntry = do_QueryInterface(aNewEntry);
mActiveEntry = newEntry;
mActiveEntry = newEntry.forget();
}
}
@ -310,6 +310,7 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
} else {
entry = new SessionHistoryEntry(aLoadState, aChannel);
entry->SetDocshellID(GetHistoryID());
entry->SetForInitialLoad(true);
}
MOZ_DIAGNOSTIC_ASSERT(entry);
@ -340,13 +341,8 @@ void CanonicalBrowsingContext::SessionHistoryCommit(uint64_t aLoadId,
RefPtr<SessionHistoryEntry> oldActiveEntry = mActiveEntry;
RefPtr<SessionHistoryEntry> newActiveEntry = mLoadingEntries[i].mEntry;
bool loadFromSessionHistory = false;
nsCOMPtr<nsISHistory> existingHistory = newActiveEntry->GetShistory();
loadFromSessionHistory = (existingHistory == shistory);
if (!loadFromSessionHistory) {
newActiveEntry->SetShistory(shistory);
}
bool loadFromSessionHistory = !newActiveEntry->ForInitialLoad();
newActiveEntry->SetForInitialLoad(false);
SessionHistoryEntry::RemoveLoadId(aLoadId);
mLoadingEntries.RemoveElementAt(i);
if (IsTop()) {
@ -449,6 +445,7 @@ void CanonicalBrowsingContext::SetActiveSessionHistoryEntryForTop(
aPreviousScrollPos.ref().y);
}
RefPtr<SessionHistoryEntry> newEntry = new SessionHistoryEntry(aInfo);
newEntry->SetDocshellID(GetHistoryID());
mActiveEntry = newEntry;
Maybe<int32_t> previousEntryIndex, loadedEntryIndex;
nsISHistory* shistory = GetSessionHistory();
@ -476,6 +473,7 @@ void CanonicalBrowsingContext::SetActiveSessionHistoryEntryForFrame(
aPreviousScrollPos.ref().y);
}
RefPtr<SessionHistoryEntry> newEntry = new SessionHistoryEntry(aInfo);
newEntry->SetDocshellID(GetHistoryID());
mActiveEntry = newEntry;
nsISHistory* shistory = GetSessionHistory();
if (oldActiveEntry) {

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

@ -233,6 +233,11 @@ class SessionHistoryEntry : public nsISHEntry {
void SetInfo(SessionHistoryInfo* aInfo);
bool ForInitialLoad() { return mForInitialLoad; }
void SetForInitialLoad(bool aForInitialLoad) {
mForInitialLoad = aForInitialLoad;
}
// Get an entry based on LoadingSessionHistoryInfo's mLoadId. Parent process
// only.
static SessionHistoryEntry* GetByLoadId(uint64_t aLoadId);
@ -249,6 +254,8 @@ class SessionHistoryEntry : public nsISHEntry {
uint32_t mID;
nsTArray<RefPtr<SessionHistoryEntry>> mChildren;
bool mForInitialLoad = false;
static nsDataHashtable<nsUint64HashKey, SessionHistoryEntry*>* sLoadIdToEntry;
};

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

@ -225,7 +225,7 @@ interface nsISHEntry : nsISupports
[infallible] readonly attribute boolean loadedInThisProcess;
/**
* The session history it belongs to.
* The session history it belongs to. This is set only on the root entries.
*/
[noscript, infallible] attribute nsISHistory shistory;

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

@ -429,24 +429,24 @@ nsresult nsSHistory::WalkHistoryEntries(nsISHEntry* aRootEntry,
for (BrowsingContext* child : aBC->Children()) {
// If the SH pref is on and we are in the parent process, update
// canonical BC directly
bool shouldBreak = false;
bool foundChild = false;
if (StaticPrefs::fission_sessionHistoryInParent() &&
XRE_IsParentProcess()) {
if (child->Canonical()->HasHistoryEntry(childEntry)) {
childBC = child;
shouldBreak = true;
foundChild = true;
}
}
nsDocShell* docshell = static_cast<nsDocShell*>(child->GetDocShell());
if (docshell && docshell->HasHistoryEntry(childEntry)) {
childBC = docshell->GetBrowsingContext();
shouldBreak = true;
foundChild = true;
}
// XXX Simplify this once the old and new session history
// implementations don't run at the same time.
if (shouldBreak) {
if (foundChild) {
break;
}
}
@ -635,6 +635,8 @@ void nsSHistory::HandleEntriesToSwapInDocShell(
if (docshell) {
docshell->SwapHistoryEntries(aOldEntry, aNewEntry);
}
} else {
// FIXME Bug 1633988: Need to update entries?
}
// XXX Simplify this once the old and new session history implementations