LibWeb: Implement child_navigables() for navigables
This commit is contained in:
parent
5f8b9f7936
commit
eb4db6057d
Notes:
sideshowbarker
2024-07-16 18:14:21 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/eb4db6057d Pull-request: https://github.com/SerenityOS/serenity/pull/19490
2 changed files with 14 additions and 0 deletions
|
@ -28,6 +28,18 @@ static HashTable<Navigable*>& all_navigables()
|
|||
return set;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#child-navigable
|
||||
Vector<JS::Handle<Navigable>> Navigable::child_navigables() const
|
||||
{
|
||||
Vector<JS::Handle<Navigable>> results;
|
||||
for (auto& entry : all_navigables()) {
|
||||
if (entry->parent() == this)
|
||||
results.append(entry);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
Navigable::Navigable()
|
||||
{
|
||||
all_navigables().set(this);
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
|
||||
ErrorOr<void> initialize_navigable(JS::NonnullGCPtr<DocumentState> document_state, JS::GCPtr<Navigable> parent);
|
||||
|
||||
Vector<JS::Handle<Navigable>> child_navigables() const;
|
||||
|
||||
String const& id() const { return m_id; };
|
||||
JS::GCPtr<Navigable> parent() const { return m_parent; };
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue