mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
LibWeb: Implement getting "ancestor navigables" of a document
This commit is contained in:
parent
c8271ac9e6
commit
e211f6c925
2 changed files with 24 additions and 0 deletions
|
@ -2561,6 +2561,29 @@ Vector<JS::Handle<HTML::Navigable>> Document::inclusive_descendant_navigables()
|
||||||
return 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
|
// 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
|
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>> descendant_navigables();
|
||||||
Vector<JS::Handle<HTML::Navigable>> inclusive_descendant_navigables();
|
Vector<JS::Handle<HTML::Navigable>> inclusive_descendant_navigables();
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> ancestor_navigables();
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue