mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
LibWeb: Implement getting "descendant navigables" of a document
This commit is contained in:
parent
21e383c24f
commit
7af09481f5
2 changed files with 42 additions and 0 deletions
|
@ -2316,6 +2316,45 @@ HTML::PolicyContainer Document::policy_container() const
|
||||||
return m_policy_container;
|
return m_policy_container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#descendant-navigables
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> Document::descendant_navigables()
|
||||||
|
{
|
||||||
|
// 1. Let navigables be new list.
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> navigables;
|
||||||
|
|
||||||
|
// 2. Let navigableContainers be a list of all shadow-including descendants of document that are navigable containers, in shadow-including tree order.
|
||||||
|
// 3. For each navigableContainer of navigableContainers:
|
||||||
|
for_each_shadow_including_descendant([&](DOM::Node& node) {
|
||||||
|
if (is<HTML::NavigableContainer>(node)) {
|
||||||
|
auto& navigable_container = static_cast<HTML::NavigableContainer&>(node);
|
||||||
|
// 1. If navigableContainer's content navigable is null, then continue.
|
||||||
|
if (!navigable_container.content_navigable())
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
|
||||||
|
// 2. Extend navigables with navigableContainer's content navigable's active document's inclusive descendant navigables.
|
||||||
|
navigables.extend(navigable_container.content_navigable()->active_document()->inclusive_descendant_navigables());
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 4. Return navigables.
|
||||||
|
return navigables;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#inclusive-descendant-navigables
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> Document::inclusive_descendant_navigables()
|
||||||
|
{
|
||||||
|
// 1. Let navigables be « document's node navigable ».
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> navigables;
|
||||||
|
navigables.append(*navigable());
|
||||||
|
|
||||||
|
// 2. Extend navigables with document's descendant navigables.
|
||||||
|
navigables.extend(descendant_navigables());
|
||||||
|
|
||||||
|
// 3. Return navigables.
|
||||||
|
return navigables;
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
{
|
{
|
||||||
|
|
|
@ -445,6 +445,9 @@ public:
|
||||||
// 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>> list_of_descendant_browsing_contexts() const;
|
Vector<JS::Handle<HTML::BrowsingContext>> list_of_descendant_browsing_contexts() const;
|
||||||
|
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> descendant_navigables();
|
||||||
|
Vector<JS::Handle<HTML::Navigable>> inclusive_descendant_navigables();
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/window-object.html#discard-a-document
|
// https://html.spec.whatwg.org/multipage/window-object.html#discard-a-document
|
||||||
void discard();
|
void discard();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue