From 27a678322f16249faa2b0127c821cf76888e2c0e Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 3 Nov 2024 21:07:49 -0500 Subject: [PATCH] LibWebView: Inspect elements the same as elements We track this node ID to navigate to a default element when opening the Inspector. So for all intents and purposes, and should be treated the same. --- Userland/Libraries/LibWebView/InspectorClient.cpp | 10 +++++----- Userland/Libraries/LibWebView/InspectorClient.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWebView/InspectorClient.cpp b/Userland/Libraries/LibWebView/InspectorClient.cpp index ed2de52108b..52d463695b4 100644 --- a/Userland/Libraries/LibWebView/InspectorClient.cpp +++ b/Userland/Libraries/LibWebView/InspectorClient.cpp @@ -313,7 +313,7 @@ void InspectorClient::reset() static constexpr auto script = "inspector.reset();"sv; m_inspector_web_view.run_javascript(script); - m_body_node_id.clear(); + m_body_or_frameset_node_id.clear(); m_pending_selection.clear(); m_dom_tree_loaded = false; @@ -331,8 +331,8 @@ void InspectorClient::select_hovered_node() void InspectorClient::select_default_node() { - if (m_body_node_id.has_value()) - select_node(*m_body_node_id); + if (m_body_or_frameset_node_id.has_value()) + select_node(*m_body_or_frameset_node_id); } void InspectorClient::clear_selection() @@ -633,8 +633,8 @@ String InspectorClient::generate_dom_tree(JsonObject const& dom_tree) return; } - if (name.equals_ignoring_ascii_case("BODY"sv)) - m_body_node_id = node_id; + if (name.equals_ignoring_ascii_case("BODY"sv) || name.equals_ignoring_ascii_case("FRAMESET"sv)) + m_body_or_frameset_node_id = node_id; auto tag = name.to_lowercase(); diff --git a/Userland/Libraries/LibWebView/InspectorClient.h b/Userland/Libraries/LibWebView/InspectorClient.h index 4761bfc2745..09514d83c4a 100644 --- a/Userland/Libraries/LibWebView/InspectorClient.h +++ b/Userland/Libraries/LibWebView/InspectorClient.h @@ -72,7 +72,7 @@ private: ViewImplementation& m_content_web_view; ViewImplementation& m_inspector_web_view; - Optional m_body_node_id; + Optional m_body_or_frameset_node_id; Optional m_pending_selection; bool m_inspector_loaded { false };