Bug 1650095 - Part 2 - Implement SessionHistoryEntry::Get/SetHasUserInteraction. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D93346
This commit is contained in:
@@ -702,8 +702,15 @@ void CanonicalBrowsingContext::RemoveFromSessionHistory() {
|
||||
}
|
||||
|
||||
void CanonicalBrowsingContext::HistoryGo(
|
||||
int32_t aOffset, uint64_t aHistoryEpoch, Maybe<ContentParentId> aContentId,
|
||||
int32_t aOffset, uint64_t aHistoryEpoch, bool aRequireUserInteraction,
|
||||
Maybe<ContentParentId> aContentId,
|
||||
std::function<void(int32_t&&)>&& aResolver) {
|
||||
if (aRequireUserInteraction && aOffset != -1 && aOffset != 1) {
|
||||
NS_ERROR(
|
||||
"aRequireUserInteraction may only be used with an offset of -1 or 1");
|
||||
return;
|
||||
}
|
||||
|
||||
nsSHistory* shistory = static_cast<nsSHistory*>(GetSessionHistory());
|
||||
if (!shistory) {
|
||||
return;
|
||||
@@ -716,13 +723,25 @@ void CanonicalBrowsingContext::HistoryGo(
|
||||
("HistoryGo(%d->%d) epoch %" PRIu64 "/id %" PRIu64, aOffset,
|
||||
(index + aOffset).value(), aHistoryEpoch,
|
||||
(uint64_t)(aContentId.isSome() ? aContentId.value() : 0)));
|
||||
index += aOffset;
|
||||
if (!index.isValid()) {
|
||||
MOZ_LOG(gSHLog, LogLevel::Debug, ("Invalid index"));
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME userinteraction bits may needs tweaks here.
|
||||
while (true) {
|
||||
index += aOffset;
|
||||
if (!index.isValid()) {
|
||||
MOZ_LOG(gSHLog, LogLevel::Debug, ("Invalid index"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for user interaction if desired, except for the first and last
|
||||
// history entries. We compare with >= to account for the case where
|
||||
// aOffset >= length.
|
||||
if (!aRequireUserInteraction || index.value() >= shistory->Length() - 1 ||
|
||||
index.value() <= 0) {
|
||||
break;
|
||||
}
|
||||
if (shistory->HasUserInteractionAtIndex(index.value())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Implement aborting additional history navigations from within the same
|
||||
// event spin of the content process.
|
||||
|
||||
Reference in New Issue
Block a user