mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:37:43 +00:00
LibWeb: Implement get_the_history_object_length_and_index()
This commit is contained in:
parent
09cb266cb8
commit
5b06e43938
2 changed files with 28 additions and 0 deletions
|
@ -149,6 +149,28 @@ Vector<int> TraversableNavigable::get_all_used_history_steps() const
|
||||||
return sorted_steps;
|
return sorted_steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#getting-the-history-object-length-and-index
|
||||||
|
TraversableNavigable::HistoryObjectLengthAndIndex TraversableNavigable::get_the_history_object_length_and_index(int step) const
|
||||||
|
{
|
||||||
|
// 1. Let steps be the result of getting all used history steps within traversable.
|
||||||
|
auto steps = get_all_used_history_steps();
|
||||||
|
|
||||||
|
// 2. Let scriptHistoryLength be the size of steps.
|
||||||
|
auto script_history_length = steps.size();
|
||||||
|
|
||||||
|
// 3. Assert: steps contains step.
|
||||||
|
VERIFY(steps.contains_slow(step));
|
||||||
|
|
||||||
|
// 4. Let scriptHistoryIndex be the index of step in steps.
|
||||||
|
auto script_history_index = *steps.find_first_index(step);
|
||||||
|
|
||||||
|
// 5. Return (scriptHistoryLength, scriptHistoryIndex).
|
||||||
|
return HistoryObjectLengthAndIndex {
|
||||||
|
.script_history_length = script_history_length,
|
||||||
|
.script_history_index = script_history_index
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#clear-the-forward-session-history
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#clear-the-forward-session-history
|
||||||
void TraversableNavigable::clear_the_forward_session_history()
|
void TraversableNavigable::clear_the_forward_session_history()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,12 @@ public:
|
||||||
bool running_nested_apply_history_step() const { return m_running_nested_apply_history_step; };
|
bool running_nested_apply_history_step() const { return m_running_nested_apply_history_step; };
|
||||||
VisibilityState system_visibility_state() const { return m_system_visibility_state; };
|
VisibilityState system_visibility_state() const { return m_system_visibility_state; };
|
||||||
|
|
||||||
|
struct HistoryObjectLengthAndIndex {
|
||||||
|
size_t script_history_length;
|
||||||
|
size_t script_history_index;
|
||||||
|
};
|
||||||
|
HistoryObjectLengthAndIndex get_the_history_object_length_and_index(int) const;
|
||||||
|
|
||||||
Vector<int> get_all_used_history_steps() const;
|
Vector<int> get_all_used_history_steps() const;
|
||||||
void clear_the_forward_session_history();
|
void clear_the_forward_session_history();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue