/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void ChildSHistory::SetIsInProcess(bool aIsInProcess) { if (!aIsInProcess) {
MOZ_ASSERT_IF(mozilla::SessionHistoryInParent(), !mHistory); if (!mozilla::SessionHistoryInParent()) {
RemovePendingHistoryNavigations(); if (mHistory) { static_cast<nsSHistory*>(mHistory.get())->SetBrowsingContext(nullptr);
mHistory = nullptr;
}
}
return;
}
if (mHistory || mozilla::SessionHistoryInParent()) { return;
}
mHistory = new nsSHistory(mBrowsingContext);
}
int32_t ChildSHistory::Count() { if (mozilla::SessionHistoryInParent()) {
uint32_t length = mLength; for (uint32_t i = 0; i < mPendingSHistoryChanges.Length(); ++i) {
length += mPendingSHistoryChanges[i].mLengthDelta;
}
return length;
} return mHistory->GetCount();
}
int32_t ChildSHistory::Index() { if (mozilla::SessionHistoryInParent()) {
uint32_t index = mIndex; for (uint32_t i = 0; i < mPendingSHistoryChanges.Length(); ++i) {
index += mPendingSHistoryChanges[i].mIndexDelta;
}
void ChildSHistory::Go(int32_t aOffset, bool aRequireUserInteraction, bool aUserActivation, ErrorResult& aRv) {
CheckedInt<int32_t> index = Index();
MOZ_LOG(
gSHLog, LogLevel::Debug,
("ChildSHistory::Go(%d), current index = %d", aOffset, index.value())); if (aRequireUserInteraction && aOffset != -1 && aOffset != 1) {
NS_ERROR( "aRequireUserInteraction may only be used with an offset of -1 or 1");
aRv.Throw(NS_ERROR_INVALID_ARG); return;
}
while (true) {
index += aOffset; if (!index.isValid()) {
aRv.Throw(NS_ERROR_FAILURE); 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 >= Count(). if (!StaticPrefs::browser_navigation_requireUserInteraction() ||
!aRequireUserInteraction || index.value() >= Count() - 1 ||
index.value() <= 0) { break;
} if (mHistory && mHistory->HasUserInteractionAtIndex(index.value())) { break;
}
}
nsCOMPtr<nsISHistory> shistory = mHistory;
RefPtr<BrowsingContext> bc = mBrowsingContext;
bc->HistoryGo(
aOffset, mHistoryEpoch, aRequireUserInteraction, aUserActivation,
[shistory](Maybe<int32_t>&& aRequestedIndex) { // FIXME Should probably only do this for non-fission. if (aRequestedIndex.isSome() && shistory) {
shistory->InternalSetRequestedIndex(aRequestedIndex.value());
}
});
} else {
nsCOMPtr<nsISHistory> shistory = mHistory;
aRv = shistory->GotoIndex(aIndex, aUserActivation);
}
}
void ChildSHistory::RemovePendingHistoryNavigations() { // Per the spec, this generally shouldn't remove all navigations - it // depends if they're in the same document family or not. We don't do // that. Also with SessionHistoryInParent, this can only abort AsyncGo's // that have not yet been sent to the parent - see discussion of point // 2.2 in comments in nsDocShell::UpdateURLAndHistory()
MOZ_LOG(gSHLog, LogLevel::Debug,
("ChildSHistory::RemovePendingHistoryNavigations: %zu",
mPendingNavigations.length()));
mPendingNavigations.clear();
}
void ChildSHistory::EvictLocalDocumentViewers() { if (!mozilla::SessionHistoryInParent()) {
mHistory->EvictAllDocumentViewers();
}
}
nsISHistory* ChildSHistory::GetLegacySHistory(ErrorResult& aError) { if (mozilla::SessionHistoryInParent()) {
aError.ThrowTypeError( "legacySHistory is not available with session history in the parent."); return nullptr;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.