LibWeb+WebContent: Add query for hovered DOM node to OOPWV

This is needed for the "Inspect Element" context menu action.
This commit is contained in:
Sam Atkins 2021-08-27 17:33:10 +01:00 committed by Andreas Kling
parent 3b07f49d48
commit 1ccf10789e
Notes: sideshowbarker 2024-07-18 04:51:46 +09:00
5 changed files with 18 additions and 0 deletions

View file

@ -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();

View file

@ -39,6 +39,7 @@ public:
};
Optional<DOMNodeProperties> 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);

View file

@ -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()) {

View file

@ -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;

View file

@ -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) =|