diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index c76f004aa59..5e642df6e9e 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -424,6 +424,11 @@ void OutOfProcessWebView::clear_inspected_dom_node() client().inspect_dom_node(0); } +i32 OutOfProcessWebView::get_hovered_node_id() +{ + return client().get_hovered_node_id(); +} + void OutOfProcessWebView::js_console_initialize() { client().async_js_console_initialize(); diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h index 5a34d524787..f3a997bf798 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h @@ -39,6 +39,7 @@ public: }; Optional inspect_dom_node(i32 node_id); void clear_inspected_dom_node(); + i32 get_hovered_node_id(); void js_console_initialize(); void js_console_input(const String& js_source); diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp index 85a5b553844..f4a051a693d 100644 --- a/Userland/Services/WebContent/ClientConnection.cpp +++ b/Userland/Services/WebContent/ClientConnection.cpp @@ -261,6 +261,16 @@ Messages::WebContentServer::InspectDomNodeResponse ClientConnection::inspect_dom return { false, "", "" }; } +Messages::WebContentServer::GetHoveredNodeIdResponse ClientConnection::get_hovered_node_id() +{ + if (auto* document = page().top_level_browsing_context().document()) { + auto hovered_node = document->hovered_node(); + if (hovered_node) + return hovered_node->id(); + } + return (i32)0; +} + void ClientConnection::js_console_initialize() { if (auto* document = page().top_level_browsing_context().document()) { diff --git a/Userland/Services/WebContent/ClientConnection.h b/Userland/Services/WebContent/ClientConnection.h index 99d39e82772..8dba21858c4 100644 --- a/Userland/Services/WebContent/ClientConnection.h +++ b/Userland/Services/WebContent/ClientConnection.h @@ -50,6 +50,7 @@ private: virtual void get_source() override; virtual void inspect_dom_tree() override; virtual Messages::WebContentServer::InspectDomNodeResponse inspect_dom_node(i32) override; + virtual Messages::WebContentServer::GetHoveredNodeIdResponse get_hovered_node_id() override; virtual void js_console_initialize() override; virtual void js_console_input(String const&) override; virtual void run_javascript(String const&) override; diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 729287f0016..fd84e456c0b 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -28,6 +28,7 @@ endpoint WebContentServer get_source() =| inspect_dom_tree() =| inspect_dom_node(i32 node_id) => (bool has_style, String specified_style, String computed_style) + get_hovered_node_id() => (i32 node_id) js_console_initialize() =| js_console_input(String js_source) =|