Bug 1658280 - nsISHEntry.scrollRestorationIsManual setter for session-history-in-parent, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D86547
This commit is contained in:
Olli Pettay
2020-08-13 19:18:06 +00:00
parent 6dffb11c62
commit f0b7a8b7c9
6 changed files with 58 additions and 4 deletions

View File

@@ -8508,11 +8508,18 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
// Link our new SHEntry to the old SHEntry's back/forward // Link our new SHEntry to the old SHEntry's back/forward
// cache data, since the two SHEntries correspond to the // cache data, since the two SHEntries correspond to the
// same document. // same document.
if (mLoadingEntry && !mLoadingEntry->mIsLoadFromSessionHistory) {
// If we're not doing a history load, scroll restoration
// should be inherited from the previous session history entry.
SetScrollRestorationIsManualOnHistoryEntry(
nullptr, &mLoadingEntry->mInfo, scrollRestorationIsManual);
}
if (mLSHE) { if (mLSHE) {
if (!aLoadState->SHEntry()) { if (!aLoadState->SHEntry()) {
// If we're not doing a history load, scroll restoration // If we're not doing a history load, scroll restoration
// should be inherited from the previous session history entry. // should be inherited from the previous session history entry.
mLSHE->SetScrollRestorationIsManual(scrollRestorationIsManual); SetScrollRestorationIsManualOnHistoryEntry(mLSHE, nullptr,
scrollRestorationIsManual);
} }
mLSHE->AdoptBFCacheEntry(mOSHE); mLSHE->AdoptBFCacheEntry(mOSHE);
} }
@@ -10787,13 +10794,35 @@ nsDocShell::GetCurrentScrollRestorationIsManual(bool* aIsManual) {
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetCurrentScrollRestorationIsManual(bool aIsManual) { nsDocShell::SetCurrentScrollRestorationIsManual(bool aIsManual) {
if (mOSHE) { SetScrollRestorationIsManualOnHistoryEntry(mOSHE, mActiveEntry.get(),
mOSHE->SetScrollRestorationIsManual(aIsManual); aIsManual);
}
return NS_OK; return NS_OK;
} }
void nsDocShell::SetScrollRestorationIsManualOnHistoryEntry(
nsISHEntry* aSHEntry, mozilla::dom::SessionHistoryInfo* aInfo,
bool aIsManual) {
if (aSHEntry) {
aSHEntry->SetScrollRestorationIsManual(aIsManual);
}
if (aInfo) {
aInfo->SetScrollRestorationIsManual(aIsManual);
if (XRE_IsParentProcess()) {
SessionHistoryEntry* entry =
SessionHistoryEntry::GetByInfoId(aInfo->Id());
if (entry) {
entry->SetScrollRestorationIsManual(aIsManual);
}
} else {
mozilla::Unused << ContentChild::GetSingleton()
->SendSessionHistoryEntryScrollRestorationIsManual(
aInfo->Id(), aIsManual);
}
}
}
bool nsDocShell::ShouldAddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel) { bool nsDocShell::ShouldAddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel) {
// I believe none of the about: urls should go in the history. But then // I believe none of the about: urls should go in the history. But then
// that could just be me... If the intent is only deny about:blank then we // that could just be me... If the intent is only deny about:blank then we

View File

@@ -1050,6 +1050,10 @@ class nsDocShell final : public nsDocLoader,
void SetTitleOnHistoryEntry(); void SetTitleOnHistoryEntry();
void SetScrollRestorationIsManualOnHistoryEntry(
nsISHEntry* aSHEntry, mozilla::dom::SessionHistoryInfo* aInfo,
bool aIsManual);
private: // data members private: // data members
nsID mHistoryID; nsID mHistoryID;
nsString mTitle; nsString mTitle;

View File

@@ -49,6 +49,10 @@ class SessionHistoryInfo {
const nsAString& GetTitle() { return mTitle; } const nsAString& GetTitle() { return mTitle; }
void SetTitle(const nsAString& aTitle) { mTitle = aTitle; } void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
void SetScrollRestorationIsManual(bool aIsManual) {
mScrollRestorationIsManual = aIsManual;
}
nsIURI* GetURI() const { return mURI; } nsIURI* GetURI() const { return mURI; }
bool GetURIWasModified() const { return mURIWasModified; } bool GetURIWasModified() const { return mURIWasModified; }

View File

@@ -6977,6 +6977,17 @@ mozilla::ipc::IPCResult ContentParent::RecvSessionHistoryEntryTitle(
return IPC_OK(); return IPC_OK();
} }
mozilla::ipc::IPCResult
ContentParent::RecvSessionHistoryEntryScrollRestorationIsManual(
const uint64_t& aSessionHistoryEntryID, const bool& aIsManual) {
SessionHistoryEntry* entry =
SessionHistoryEntry::GetByInfoId(aSessionHistoryEntryID);
if (entry) {
entry->SetScrollRestorationIsManual(aIsManual);
}
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvCommitWindowContextTransaction( mozilla::ipc::IPCResult ContentParent::RecvCommitWindowContextTransaction(
const MaybeDiscarded<WindowContext>& aContext, const MaybeDiscarded<WindowContext>& aContext,
WindowContext::BaseTransaction&& aTransaction, uint64_t aEpoch) { WindowContext::BaseTransaction&& aTransaction, uint64_t aEpoch) {

View File

@@ -1343,6 +1343,9 @@ class ContentParent final
mozilla::ipc::IPCResult RecvSessionHistoryEntryTitle( mozilla::ipc::IPCResult RecvSessionHistoryEntryTitle(
const uint64_t& aSessionHistoryEntryID, const nsString& aTitle); const uint64_t& aSessionHistoryEntryID, const nsString& aTitle);
mozilla::ipc::IPCResult RecvSessionHistoryEntryScrollRestorationIsManual(
const uint64_t& aSessionHistoryEntryID, const bool& aIsManual);
// Notify the ContentChild to enable the input event prioritization when // Notify the ContentChild to enable the input event prioritization when
// initializing. // initializing.
void MaybeEnableRemoteInputEventQueue(); void MaybeEnableRemoteInputEventQueue();

View File

@@ -928,6 +928,9 @@ parent:
async SessionHistoryEntryTitle(uint64_t aSessionHistoryEntryID, async SessionHistoryEntryTitle(uint64_t aSessionHistoryEntryID,
nsString aTitle); nsString aTitle);
async SessionHistoryEntryScrollRestorationIsManual(uint64_t aSessionHistoryEntryID,
bool aIsManual);
async InitBackground(Endpoint<PBackgroundParent> aEndpoint); async InitBackground(Endpoint<PBackgroundParent> aEndpoint);
async CreateGMPService(); async CreateGMPService();