Bug 1649131 - Implement history.pushState/.replaceState for session history in the parent. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D87039
This commit is contained in:
Peter Van der Beken
2020-08-23 17:41:03 +00:00
parent 90788d6b37
commit bcaca89c59
14 changed files with 642 additions and 181 deletions

View File

@@ -51,6 +51,7 @@
#include "nsFocusManager.h"
#include "nsGlobalWindowOuter.h"
#include "nsIObserverService.h"
#include "nsISHistory.h"
#include "nsContentUtils.h"
#include "nsQueryObject.h"
#include "nsSandboxFlags.h"
@@ -2595,6 +2596,50 @@ bool BrowsingContext::IsPopupAllowed() {
return false;
}
void BrowsingContext::SetActiveSessionHistoryEntryForTop(
const Maybe<nsPoint>& aPreviousScrollPos, SessionHistoryInfo* aInfo,
uint32_t aLoadType) {
if (XRE_IsContentProcess()) {
nsID changeID = {};
RefPtr<ChildSHistory> shistory = GetChildSessionHistory();
if (shistory) {
changeID = shistory->AddPendingHistoryChange(1, 1);
}
ContentChild::GetSingleton()->SendSetActiveSessionHistoryEntryForTop(
this, aPreviousScrollPos, *aInfo, aLoadType, changeID);
} else {
Canonical()->SetActiveSessionHistoryEntryForTop(aPreviousScrollPos, aInfo,
aLoadType, nsID());
}
}
void BrowsingContext::SetActiveSessionHistoryEntryForFrame(
const Maybe<nsPoint>& aPreviousScrollPos, SessionHistoryInfo* aInfo,
int32_t aChildOffset) {
if (XRE_IsContentProcess()) {
nsID changeID = {};
RefPtr<ChildSHistory> shistory = GetChildSessionHistory();
if (shistory) {
changeID = shistory->AddPendingHistoryChange(1, 1);
}
ContentChild::GetSingleton()->SendSetActiveSessionHistoryEntryForFrame(
this, aPreviousScrollPos, *aInfo, aChildOffset, changeID);
} else {
Canonical()->SetActiveSessionHistoryEntryForFrame(aPreviousScrollPos, aInfo,
aChildOffset, nsID());
}
}
void BrowsingContext::ReplaceActiveSessionHistoryEntry(
SessionHistoryInfo* aInfo) {
if (XRE_IsContentProcess()) {
ContentChild::GetSingleton()->SendReplaceActiveSessionHistoryEntry(this,
*aInfo);
} else {
Canonical()->ReplaceActiveSessionHistoryEntry(aInfo);
}
}
} // namespace dom
namespace ipc {