@@ -2316,6 +2316,45 @@ HTML::PolicyContainer Document::policy_container() const
2316
2316
return m_policy_container;
2317
2317
}
2318
2318
2319
+ // https://html.spec.whatwg.org/multipage/document-sequences.html#descendant-navigables
2320
+ Vector<JS::Handle<HTML::Navigable>> Document::descendant_navigables ()
2321
+ {
2322
+ // 1. Let navigables be new list.
2323
+ Vector<JS::Handle<HTML::Navigable>> navigables;
2324
+
2325
+ // 2. Let navigableContainers be a list of all shadow-including descendants of document that are navigable containers, in shadow-including tree order.
2326
+ // 3. For each navigableContainer of navigableContainers:
2327
+ for_each_shadow_including_descendant ([&](DOM::Node& node) {
2328
+ if (is<HTML::NavigableContainer>(node)) {
2329
+ auto & navigable_container = static_cast <HTML::NavigableContainer&>(node);
2330
+ // 1. If navigableContainer's content navigable is null, then continue.
2331
+ if (!navigable_container.content_navigable ())
2332
+ return IterationDecision::Continue;
2333
+
2334
+ // 2. Extend navigables with navigableContainer's content navigable's active document's inclusive descendant navigables.
2335
+ navigables.extend (navigable_container.content_navigable ()->active_document ()->inclusive_descendant_navigables ());
2336
+ }
2337
+ return IterationDecision::Continue;
2338
+ });
2339
+
2340
+ // 4. Return navigables.
2341
+ return navigables;
2342
+ }
2343
+
2344
+ // https://html.spec.whatwg.org/multipage/document-sequences.html#inclusive-descendant-navigables
2345
+ Vector<JS::Handle<HTML::Navigable>> Document::inclusive_descendant_navigables ()
2346
+ {
2347
+ // 1. Let navigables be « document's node navigable ».
2348
+ Vector<JS::Handle<HTML::Navigable>> navigables;
2349
+ navigables.append (*navigable ());
2350
+
2351
+ // 2. Extend navigables with document's descendant navigables.
2352
+ navigables.extend (descendant_navigables ());
2353
+
2354
+ // 3. Return navigables.
2355
+ return navigables;
2356
+ }
2357
+
2319
2358
// https://html.spec.whatwg.org/multipage/browsers.html#list-of-the-descendant-browsing-contexts
2320
2359
Vector<JS::Handle<HTML::BrowsingContext>> Document::list_of_descendant_browsing_contexts () const
2321
2360
{
0 commit comments