mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibWeb: Implement getting "ancestor navigables" of a document
This commit is contained in:
parent
c8271ac9e6
commit
e211f6c925
Notes:
sideshowbarker
2024-07-16 23:55:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e211f6c925 Pull-request: https://github.com/SerenityOS/serenity/pull/20680
@ -2561,6 +2561,29 @@ Vector<JS::Handle<HTML::Navigable>> Document::inclusive_descendant_navigables()
|
||||
return navigables;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#ancestor-navigables
|
||||
Vector<JS::Handle<HTML::Navigable>> Document::ancestor_navigables()
|
||||
{
|
||||
// 1. Let navigable be document's node navigable's parent.
|
||||
VERIFY(navigable());
|
||||
auto navigable = this->navigable()->parent();
|
||||
|
||||
// 2. Let ancestors be an empty list.
|
||||
Vector<JS::Handle<HTML::Navigable>> ancestors;
|
||||
|
||||
// 3. While navigable is not null:
|
||||
while (navigable) {
|
||||
// 1. Prepend navigable to ancestors.
|
||||
ancestors.prepend(*navigable);
|
||||
|
||||
// 2. Set navigable to navigable's parent.
|
||||
navigable = navigable->parent();
|
||||
}
|
||||
|
||||
// 4. Return ancestors.
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#list-of-the-descendant-browsing-contexts
|
||||
Vector<JS::Handle<HTML::BrowsingContext>> Document::list_of_descendant_browsing_contexts() const
|
||||
{
|
||||
|
@ -462,6 +462,7 @@ public:
|
||||
|
||||
Vector<JS::Handle<HTML::Navigable>> descendant_navigables();
|
||||
Vector<JS::Handle<HTML::Navigable>> inclusive_descendant_navigables();
|
||||
Vector<JS::Handle<HTML::Navigable>> ancestor_navigables();
|
||||
|
||||
void destroy();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user