LibWeb+LibWebView+WebContent: Support both inspecting/highlighting nodes

Our own Inspector differs from most other DevTools implementations with
regard to highlighting DOM nodes as you hover elements in the inspected
DOM tree. In other implementations, as you change the hovered node, the
browser will render a box model overlay onto the page for that node. We
currently don't do this; we wait until you click the node, at which
point we both paint the overlay and inspect the node's properties.

This patch does not change that behavior, but separates the IPCs and
internal tracking of inspected nodes to support the standard DevTools
behavior. So the DOM document now stores an inspected node and a
highlighted node. The former is used for features such as "$0" in the
JavaScript console, and the latter is used for the box model overlay.
Our Inspector continues to set these to the same node.
This commit is contained in:
Timothy Flynn 2025-02-21 09:34:02 -05:00 committed by Tim Flynn
parent d4b7dd88b7
commit 72905c84d5
Notes: github-actions[bot] 2025-02-24 17:07:12 +00:00
10 changed files with 83 additions and 34 deletions

View file

@ -303,24 +303,34 @@ void ViewImplementation::inspect_dom_tree()
client().async_inspect_dom_tree(page_id());
}
void ViewImplementation::inspect_dom_node(Web::UniqueNodeID node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element)
{
client().async_inspect_dom_node(page_id(), node_id, move(pseudo_element));
}
void ViewImplementation::inspect_accessibility_tree()
{
client().async_inspect_accessibility_tree(page_id());
}
void ViewImplementation::get_hovered_node_id()
{
client().async_get_hovered_node_id(page_id());
}
void ViewImplementation::inspect_dom_node(Web::UniqueNodeID node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element)
{
client().async_inspect_dom_node(page_id(), node_id, move(pseudo_element));
}
void ViewImplementation::clear_inspected_dom_node()
{
inspect_dom_node(0, {});
}
void ViewImplementation::get_hovered_node_id()
void ViewImplementation::highlight_dom_node(Web::UniqueNodeID node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element)
{
client().async_get_hovered_node_id(page_id());
client().async_highlight_dom_node(page_id(), node_id, move(pseudo_element));
}
void ViewImplementation::clear_highlighted_dom_node()
{
highlight_dom_node(0, {});
}
void ViewImplementation::set_dom_node_text(Web::UniqueNodeID node_id, String text)