mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +00:00
LibWeb: Implement "get the target history entry" for navigables
This commit is contained in:
parent
d9d8896380
commit
6ec88b36b9
2 changed files with 22 additions and 0 deletions
|
@ -77,6 +77,26 @@ ErrorOr<void> Navigable::initialize_navigable(JS::NonnullGCPtr<DocumentState> do
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#getting-the-target-history-entry
|
||||||
|
JS::GCPtr<SessionHistoryEntry> Navigable::get_the_target_history_entry(int target_step) const
|
||||||
|
{
|
||||||
|
// 1. Let entries be the result of getting session history entries for navigable.
|
||||||
|
auto& entries = get_session_history_entries();
|
||||||
|
|
||||||
|
// 2. Return the item in entries that has the greatest step less than or equal to step.
|
||||||
|
JS::GCPtr<SessionHistoryEntry> result = nullptr;
|
||||||
|
for (auto& entry : entries) {
|
||||||
|
auto entry_step = entry->step.get<int>();
|
||||||
|
if (entry_step <= target_step) {
|
||||||
|
if (!result || result->step.get<int>() < entry_step) {
|
||||||
|
result = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document
|
||||||
JS::GCPtr<DOM::Document> Navigable::active_document()
|
JS::GCPtr<DOM::Document> Navigable::active_document()
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
JS::GCPtr<WindowProxy> active_window_proxy();
|
JS::GCPtr<WindowProxy> active_window_proxy();
|
||||||
JS::GCPtr<Window> active_window();
|
JS::GCPtr<Window> active_window();
|
||||||
|
|
||||||
|
JS::GCPtr<SessionHistoryEntry> get_the_target_history_entry(int target_step) const;
|
||||||
|
|
||||||
String target_name() const;
|
String target_name() const;
|
||||||
|
|
||||||
JS::GCPtr<NavigableContainer> container() const;
|
JS::GCPtr<NavigableContainer> container() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue