mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibWeb: Implement getting the top-level traversable of a navigable
This commit is contained in:
parent
05dc1da321
commit
54e01824c7
Notes:
sideshowbarker
2024-07-16 21:34:08 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/54e01824c7 Pull-request: https://github.com/SerenityOS/serenity/pull/18471
@ -95,4 +95,18 @@ JS::GCPtr<TraversableNavigable> Navigable::traversable_navigable()
|
||||
return static_cast<TraversableNavigable*>(navigable);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-top
|
||||
JS::GCPtr<TraversableNavigable> Navigable::top_level_traversable()
|
||||
{
|
||||
// 1. Let navigable be inputNavigable.
|
||||
auto navigable = this;
|
||||
|
||||
// 2. While navigable's parent is not null, set navigable to navigable's parent.
|
||||
while (navigable->parent())
|
||||
navigable = navigable->parent();
|
||||
|
||||
// 3. Return navigable.
|
||||
return verify_cast<TraversableNavigable>(navigable);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
void set_container(JS::GCPtr<NavigableContainer>);
|
||||
|
||||
JS::GCPtr<TraversableNavigable> traversable_navigable();
|
||||
JS::GCPtr<TraversableNavigable> top_level_traversable();
|
||||
|
||||
protected:
|
||||
Navigable();
|
||||
|
Loading…
Reference in New Issue
Block a user