From 01cc14714ec5faa435f94fde241690e78acfd725 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 20 Aug 2023 00:41:55 +0200 Subject: [PATCH] LibWeb: Implement getting "inclusive ancestor navigables" of a document --- Userland/Libraries/LibWeb/DOM/Document.cpp | 13 +++++++++++++ Userland/Libraries/LibWeb/DOM/Document.h | 1 + 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 2b0969ef52..08b5a3d294 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -2584,6 +2584,19 @@ Vector> Document::ancestor_navigables() return ancestors; } +// https://html.spec.whatwg.org/multipage/document-sequences.html#inclusive-ancestor-navigables +Vector> Document::inclusive_ancestor_navigables() +{ + // 1. Let navigables be document's ancestor navigables. + auto navigables = ancestor_navigables(); + + // 2. Append document's node navigable to navigables. + navigables.append(*navigable()); + + // 3. Return navigables. + return navigables; +} + // https://html.spec.whatwg.org/multipage/browsers.html#list-of-the-descendant-browsing-contexts Vector> Document::list_of_descendant_browsing_contexts() const { diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 59c9aa09ee..68a5bcc4cc 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -463,6 +463,7 @@ public: Vector> descendant_navigables(); Vector> inclusive_descendant_navigables(); Vector> ancestor_navigables(); + Vector> inclusive_ancestor_navigables(); void destroy();