Ladybird: Add the node properties tabs to the inspector

This now allows you to view the computed and resolved style values,
along with the CSS variables of a node.
This commit is contained in:
MacDue 2022-12-18 21:12:14 +00:00 committed by Andrew Kaster
parent aa85a88158
commit 33249c727a
Notes: sideshowbarker 2024-07-17 22:09:47 +09:00
5 changed files with 103 additions and 19 deletions

View file

@ -511,7 +511,7 @@ void WebContentView::ensure_inspector_widget()
};
m_inspector_widget->on_dom_node_inspected = [&](auto id, auto pseudo_element) {
inspect_dom_node(id, pseudo_element);
return inspect_dom_node(id, pseudo_element);
};
}
@ -531,15 +531,21 @@ void WebContentView::inspect_dom_tree()
client().async_inspect_dom_tree();
}
void WebContentView::inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element)
ErrorOr<Ladybird::DOMNodeProperties> WebContentView::inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element)
{
// TODO: Use and display response
(void)client().inspect_dom_node(node_id, pseudo_element);
auto response = client().inspect_dom_node(node_id, pseudo_element);
if (!response.has_style())
return Error::from_string_view("Inspected node returned no style"sv);
return Ladybird::DOMNodeProperties {
.computed_style_json = TRY(String::from_deprecated_string(response.take_computed_style())),
.resolved_style_json = TRY(String::from_deprecated_string(response.take_resolved_style())),
.custom_properties_json = TRY(String::from_deprecated_string(response.take_custom_properties())),
};
}
void WebContentView::clear_inspected_dom_node()
{
inspect_dom_node(0, {});
(void)inspect_dom_node(0, {});
}
void WebContentView::show_inspector()