Bug 1657757 - nsISHEntry.title setter for session-history-in-parent, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D86275
This commit is contained in:
Olli Pettay 2020-08-13 19:17:38 +00:00
Родитель ab723a1ca1
Коммит 83814cae84
6 изменённых файлов: 53 добавлений и 16 удалений

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

@ -4739,14 +4739,34 @@ nsDocShell::SetTitle(const nsAString& aTitle) {
}
// Update SessionHistory with the document's title.
if (mOSHE && mLoadType != LOAD_BYPASS_HISTORY &&
mLoadType != LOAD_ERROR_PAGE) {
mOSHE->SetTitle(mTitle);
if (mLoadType != LOAD_BYPASS_HISTORY && mLoadType != LOAD_ERROR_PAGE) {
SetTitleOnHistoryEntry();
}
return NS_OK;
}
void nsDocShell::SetTitleOnHistoryEntry() {
if (mOSHE) {
mOSHE->SetTitle(mTitle);
}
if (mActiveEntry) {
mActiveEntry->SetTitle(mTitle);
if (XRE_IsParentProcess()) {
SessionHistoryEntry* entry =
SessionHistoryEntry::GetByInfoId(mActiveEntry->Id());
if (entry) {
entry->SetTitle(mTitle);
}
} else {
mozilla::Unused
<< ContentChild::GetSingleton()->SendSessionHistoryEntryTitle(
mActiveEntry->Id(), mTitle);
}
}
}
nsPoint nsDocShell::GetCurScrollPos() {
nsPoint scrollPos;
if (nsIScrollableFrame* sf = GetRootScrollFrame()) {
@ -8528,21 +8548,19 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
}
}
/* 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.
* Note, this happens on mOSHE (and mActiveEntry in the future) because of
* the code above.
* XXX HandleSameDocumentNavigation needs to be made work with
* session-history-in-parent
*/
SetTitleOnHistoryEntry();
/* Restore the original LSHE if we were loading something
* while same document navigation was initiated.
*/
SetHistoryEntryAndUpdateBC(Some<nsISHEntry*>(oldLSHE), Nothing());
/* 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.
*/
ChildSHistory* shistory = GetSessionHistory();
if (shistory) {
int32_t index = shistory->Index();
nsCOMPtr<nsISHEntry> shEntry;
shistory->LegacySHistory()->GetEntryAtIndex(index, getter_AddRefs(shEntry));
NS_ENSURE_TRUE(shEntry, NS_ERROR_FAILURE);
shEntry->SetTitle(mTitle);
}
/* Set the title for the Global History entry for this anchor url.
*/

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

@ -1048,6 +1048,8 @@ class nsDocShell final : public nsDocLoader,
// LoadGroup.
void SetLoadGroupDefaultLoadFlags(nsLoadFlags aLoadFlags);
void SetTitleOnHistoryEntry();
private: // data members
nsID mHistoryID;
nsString mTitle;

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

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

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

@ -6962,11 +6962,21 @@ mozilla::ipc::IPCResult ContentParent::RecvSessionHistoryUpdate(
}
mozilla::ipc::IPCResult ContentParent::RecvSynchronizeLayoutHistoryState(
uint64_t aSessionHistoryEntryID, nsILayoutHistoryState* aState) {
const uint64_t& aSessionHistoryEntryID, nsILayoutHistoryState* aState) {
SessionHistoryEntry::UpdateLayoutHistoryState(aSessionHistoryEntryID, aState);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvSessionHistoryEntryTitle(
const uint64_t& aSessionHistoryEntryID, const nsString& aTitle) {
SessionHistoryEntry* entry =
SessionHistoryEntry::GetByInfoId(aSessionHistoryEntryID);
if (entry) {
entry->SetTitle(aTitle);
}
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvCommitWindowContextTransaction(
const MaybeDiscarded<WindowContext>& aContext,
WindowContext::BaseTransaction&& aTransaction, uint64_t aEpoch) {

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

@ -1338,7 +1338,10 @@ class ContentParent final
const int32_t& aLength, const nsID& aChangeID);
mozilla::ipc::IPCResult RecvSynchronizeLayoutHistoryState(
uint64_t aSessionHistoryEntryID, nsILayoutHistoryState* aState);
const uint64_t& aSessionHistoryEntryID, nsILayoutHistoryState* aState);
mozilla::ipc::IPCResult RecvSessionHistoryEntryTitle(
const uint64_t& aSessionHistoryEntryID, const nsString& aTitle);
// Notify the ContentChild to enable the input event prioritization when
// initializing.

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

@ -925,6 +925,8 @@ parent:
async SynchronizeLayoutHistoryState(uint64_t aSessionHistoryEntryID,
nsILayoutHistoryState aState);
async SessionHistoryEntryTitle(uint64_t aSessionHistoryEntryID,
nsString aTitle);
async InitBackground(Endpoint<PBackgroundParent> aEndpoint);