mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Implement "traverse the history by delta" for traversables
This commit is contained in:
parent
0e2684b10f
commit
aafa09e7a5
Notes:
sideshowbarker
2024-07-17 02:37:08 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/aafa09e7a5 Pull-request: https://github.com/SerenityOS/serenity/pull/19507
2 changed files with 29 additions and 0 deletions
|
@ -470,4 +470,32 @@ void TraversableNavigable::clear_the_forward_session_history()
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history-by-a-delta
|
||||
void TraversableNavigable::traverse_the_history_by_delta(int delta)
|
||||
{
|
||||
// FIXME: 1. Let sourceSnapshotParams and initiatorToCheck be null.
|
||||
|
||||
// FIXME: 2. If sourceDocument is given, then:
|
||||
|
||||
// 3. Append the following session history traversal steps to traversable:
|
||||
|
||||
// 1. Let allSteps be the result of getting all used history steps for traversable.
|
||||
auto all_steps = get_all_used_history_steps();
|
||||
|
||||
// 2. Let currentStepIndex be the index of traversable's current session history step within allSteps.
|
||||
auto current_step_index = *all_steps.find_first_index(current_session_history_step());
|
||||
|
||||
// 3. Let targetStepIndex be currentStepIndex plus delta
|
||||
auto target_step_index = current_step_index + delta;
|
||||
|
||||
// 4. If allSteps[targetStepIndex] does not exist, then abort these steps.
|
||||
if (target_step_index >= all_steps.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. Apply the history step allSteps[targetStepIndex] to traversable, with checkForUserCancelation set to true,
|
||||
// sourceSnapshotParams set to sourceSnapshotParams, and initiatorToCheck set to initiatorToCheck.
|
||||
apply_the_history_step(all_steps[target_step_index]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
Vector<JS::Handle<Navigable>> get_all_navigables_whose_current_session_history_entry_will_change_or_reload(int) const;
|
||||
Vector<int> get_all_used_history_steps() const;
|
||||
void clear_the_forward_session_history();
|
||||
void traverse_the_history_by_delta(int delta);
|
||||
|
||||
private:
|
||||
TraversableNavigable();
|
||||
|
|
Loading…
Reference in a new issue