mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:58:11 +00:00
LibWeb: Implement child_navigables() for navigables
This commit is contained in:
parent
5f8b9f7936
commit
eb4db6057d
2 changed files with 14 additions and 0 deletions
|
@ -28,6 +28,18 @@ static HashTable<Navigable*>& all_navigables()
|
||||||
return set;
|
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()
|
Navigable::Navigable()
|
||||||
{
|
{
|
||||||
all_navigables().set(this);
|
all_navigables().set(this);
|
||||||
|
|
|
@ -29,6 +29,8 @@ public:
|
||||||
|
|
||||||
ErrorOr<void> initialize_navigable(JS::NonnullGCPtr<DocumentState> document_state, JS::GCPtr<Navigable> parent);
|
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; };
|
String const& id() const { return m_id; };
|
||||||
JS::GCPtr<Navigable> parent() const { return m_parent; };
|
JS::GCPtr<Navigable> parent() const { return m_parent; };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue