Bug 1668577 - Make child process to send offset to parent process, not index, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D92074
This commit is contained in:
Olli Pettay 2020-10-02 16:15:47 +00:00
Родитель 0b9c307bbe
Коммит 1c44b2f115
7 изменённых файлов: 27 добавлений и 13 удалений

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

@ -2742,15 +2742,15 @@ void BrowsingContext::RemoveFromSessionHistory() {
}
}
void BrowsingContext::HistoryGo(int32_t aIndex,
void BrowsingContext::HistoryGo(int32_t aOffset,
std::function<void(int32_t&&)>&& aResolver) {
if (XRE_IsContentProcess()) {
ContentChild::GetSingleton()->SendHistoryGo(
this, aIndex, std::move(aResolver),
this, aOffset, std::move(aResolver),
[](mozilla::ipc::
ResponseRejectReason) { /* FIXME Is ignoring this fine? */ });
} else {
Canonical()->HistoryGo(aIndex, std::move(aResolver));
Canonical()->HistoryGo(aOffset, std::move(aResolver));
}
}

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

@ -707,7 +707,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
Tuple<nsCOMPtr<nsIPrincipal>, nsCOMPtr<nsIPrincipal>>
GetTriggeringAndInheritPrincipalsForCurrentLoad();
void HistoryGo(int32_t aIndex, std::function<void(int32_t&&)>&& aResolver);
void HistoryGo(int32_t aOffset, std::function<void(int32_t&&)>&& aResolver);
bool ShouldUpdateSessionHistory(uint32_t aLoadType);

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

@ -6,6 +6,7 @@
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/EventForwards.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/dom/BrowserParent.h"
@ -654,14 +655,25 @@ void CanonicalBrowsingContext::RemoveFromSessionHistory() {
}
void CanonicalBrowsingContext::HistoryGo(
int32_t aIndex, std::function<void(int32_t&&)>&& aResolver) {
int32_t aOffset, std::function<void(int32_t&&)>&& aResolver) {
nsSHistory* shistory = static_cast<nsSHistory*>(GetSessionHistory());
if (!shistory) {
return;
}
CheckedInt<int32_t> index = shistory->GetRequestedIndex() >= 0
? shistory->GetRequestedIndex()
: shistory->Index();
index += aOffset;
if (!index.isValid()) {
return;
}
// FIXME userinteraction bits may needs tweaks here.
// GoToIndex checks that index is >= 0 and < length.
nsTArray<nsSHistory::LoadEntryResult> loadResults;
nsresult rv = shistory->GotoIndex(aIndex, loadResults);
nsresult rv = shistory->GotoIndex(index.value(), loadResults);
if (NS_FAILED(rv)) {
return;
}

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

@ -3362,7 +3362,7 @@ nsDocShell::GotoIndex(int32_t aIndex) {
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
ErrorResult rv;
rootSH->GotoIndex(aIndex, rv);
rootSH->GotoIndex(aIndex, aIndex - rootSH->Index(), rv);
return rv.StealNSResult();
}

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

@ -166,7 +166,7 @@ void ChildSHistory::Go(int32_t aOffset, bool aRequireUserInteraction,
}
}
GotoIndex(index.value(), aRv);
GotoIndex(index.value(), aOffset, aRv);
}
void ChildSHistory::AsyncGo(int32_t aOffset, bool aRequireUserInteraction,
@ -187,10 +187,11 @@ void ChildSHistory::AsyncGo(int32_t aOffset, bool aRequireUserInteraction,
NS_DispatchToCurrentThread(asyncNav.forget());
}
void ChildSHistory::GotoIndex(int32_t aIndex, ErrorResult& aRv) {
void ChildSHistory::GotoIndex(int32_t aIndex, int32_t aOffset,
ErrorResult& aRv) {
if (mozilla::SessionHistoryInParent()) {
nsCOMPtr<nsISHistory> shistory = mHistory;
mBrowsingContext->HistoryGo(aIndex, [shistory](int32_t&& aRequestedIndex) {
mBrowsingContext->HistoryGo(aOffset, [shistory](int32_t&& aRequestedIndex) {
// FIXME Should probably only do this for non-fission.
if (shistory) {
shistory->InternalSetRequestedIndex(aRequestedIndex);

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

@ -70,7 +70,8 @@ class ChildSHistory : public nsISupports, public nsWrapperCache {
void AsyncGo(int32_t aOffset, bool aRequireUserInteraction,
CallerType aCallerType, ErrorResult& aRv);
void GotoIndex(int32_t aIndex, ErrorResult& aRv);
// aIndex is the new index, and aOffset is the offset between new and current.
void GotoIndex(int32_t aIndex, int32_t aOffset, ErrorResult& aRv);
void RemovePendingHistoryNavigations();

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

@ -6913,10 +6913,10 @@ mozilla::ipc::IPCResult ContentParent::RecvHistoryCommit(
}
mozilla::ipc::IPCResult ContentParent::RecvHistoryGo(
const MaybeDiscarded<BrowsingContext>& aContext, int32_t aIndex,
const MaybeDiscarded<BrowsingContext>& aContext, int32_t aOffset,
HistoryGoResolver&& aResolveRequestedIndex) {
if (!aContext.IsDiscarded()) {
aContext.get_canonical()->HistoryGo(aIndex,
aContext.get_canonical()->HistoryGo(aOffset,
std::move(aResolveRequestedIndex));
}
return IPC_OK();