From 5f2128533764dc9b758505500659f8cbf2dab171 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 22 Aug 2023 15:50:49 +0200 Subject: [PATCH] LibWeb: Add `Window::navigable()` --- Userland/Libraries/LibWeb/HTML/Window.cpp | 7 +++++++ Userland/Libraries/LibWeb/HTML/Window.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 6b1fbc9e94e..cb6d30caff9 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -703,6 +703,13 @@ BrowsingContext* Window::browsing_context() return m_associated_document->browsing_context(); } +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#window-navigable +JS::GCPtr Window::navigable() const +{ + // A Window's navigable is the navigable whose active document is the Window's associated Document's, or null if there is no such navigable. + return Navigable::navigable_with_active_document(*m_associated_document); +} + // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-plugin-objects Vector> Window::pdf_viewer_plugin_objects() { diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 5f5f12baed5..dcdbf161f03 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,8 @@ public: BrowsingContext const* browsing_context() const; BrowsingContext* browsing_context(); + JS::GCPtr navigable() const; + size_t document_tree_child_browsing_context_count() const; ImportMap const& import_map() const { return m_import_map; }