1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:07:45 +00:00

LibWeb+WebContent: Add inspect_dom_node() IPC call

This is the IPC version of `Document::set_inspected_node()`, using a
node ID.

We return the inspected node's style properties as JSON, so that the DOM
Inspector can immediately display them.
This commit is contained in:
Sam Atkins 2021-08-27 12:31:55 +01:00 committed by Andreas Kling
parent e824454ab4
commit f381f8d63e
5 changed files with 64 additions and 0 deletions

View file

@ -402,6 +402,22 @@ void OutOfProcessWebView::inspect_dom_tree()
client().async_inspect_dom_tree();
}
Optional<OutOfProcessWebView::DOMNodeProperties> OutOfProcessWebView::inspect_dom_node(i32 node_id)
{
auto response = client().inspect_dom_node(node_id);
if (!response.has_style())
return {};
return DOMNodeProperties {
.specified_values_json = response.specified_style(),
.computed_values_json = response.computed_style()
};
}
void OutOfProcessWebView::clear_inspected_dom_node()
{
client().inspect_dom_node(0);
}
void OutOfProcessWebView::js_console_initialize()
{
client().async_js_console_initialize();

View file

@ -31,7 +31,15 @@ public:
void debug_request(const String& request, const String& argument = {});
void get_source();
void inspect_dom_tree();
struct DOMNodeProperties {
String specified_values_json;
String computed_values_json;
};
Optional<DOMNodeProperties> inspect_dom_node(i32 node_id);
void clear_inspected_dom_node();
void js_console_initialize();
void js_console_input(const String& js_source);