From 22572c39e05734340258b7b8e302bb753e81646e Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 23 Apr 2023 00:21:59 +0300 Subject: [PATCH] LibWeb: Implement Node::navigable() https://html.spec.whatwg.org/multipage/document-sequences.html#node-navigable --- Userland/Libraries/LibWeb/DOM/Node.cpp | 9 +++++++++ Userland/Libraries/LibWeb/DOM/Node.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index cd8eebeac9..49125b36a4 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,14 @@ void Node::set_node_value(DeprecatedString const& value) // Otherwise, do nothing. } +// https://html.spec.whatwg.org/multipage/document-sequences.html#node-navigable +JS::GCPtr Node::navigable() const +{ + // To get the node navigable of a node node, return the navigable whose active document is node's node document, + // or null if there is no such navigable. + return HTML::Navigable::navigable_with_active_document(const_cast(document())); +} + void Node::invalidate_style() { if (is_document()) { diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 4685402fff..6fe2a5c2de 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -135,6 +135,8 @@ public: DeprecatedString node_value() const; void set_node_value(DeprecatedString const&); + JS::GCPtr navigable() const; + Document& document() { return *m_document; } Document const& document() const { return *m_document; }