mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Add supporting method to get navigables whose SHE will change
Implements https://html.spec.whatwg.org/multipage/browsing-the-web.html#get-all-navigables-whose-current-session-history-entry-will-change-or-reload
This commit is contained in:
parent
9c1087de8c
commit
caf7fd4f19
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/caf7fd4f19 Pull-request: https://github.com/SerenityOS/serenity/pull/19490
@ -190,6 +190,38 @@ int TraversableNavigable::get_the_used_step(int step) const
|
||||
return result.value();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#get-all-navigables-whose-current-session-history-entry-will-change-or-reload
|
||||
Vector<JS::Handle<Navigable>> TraversableNavigable::get_all_navigables_whose_current_session_history_entry_will_change_or_reload(int target_step) const
|
||||
{
|
||||
// 1. Let results be an empty list.
|
||||
Vector<JS::Handle<Navigable>> results;
|
||||
|
||||
// 2. Let navigablesToCheck be « traversable ».
|
||||
Vector<JS::Handle<Navigable>> navigables_to_check;
|
||||
navigables_to_check.append(const_cast<TraversableNavigable&>(*this));
|
||||
|
||||
// 3. For each navigable of navigablesToCheck:
|
||||
while (!navigables_to_check.is_empty()) {
|
||||
auto navigable = navigables_to_check.take_first();
|
||||
|
||||
// 1. Let targetEntry be the result of getting the target history entry given navigable and targetStep.
|
||||
auto target_entry = navigable->get_the_target_history_entry(target_step);
|
||||
|
||||
// 2. If targetEntry is not navigable's current session history entry or targetEntry's document state's reload pending is true, then append navigable to results.
|
||||
if (target_entry != navigable->current_session_history_entry() || target_entry->document_state->reload_pending()) {
|
||||
results.append(*navigable);
|
||||
}
|
||||
|
||||
// 3. If targetEntry's document is navigable's document, and targetEntry's document state's reload pending is false, then extend navigablesToCheck with the child navigables of navigable.
|
||||
if (target_entry->document_state->document() == navigable->active_document() && !target_entry->document_state->reload_pending()) {
|
||||
navigables_to_check.extend(navigable->child_navigables());
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Return results.
|
||||
return results;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#clear-the-forward-session-history
|
||||
void TraversableNavigable::clear_the_forward_session_history()
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
HistoryObjectLengthAndIndex get_the_history_object_length_and_index(int) const;
|
||||
|
||||
int get_the_used_step(int step) const;
|
||||
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user