mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibDevTools: Support highlighting DOM nodes hovered in the inspector
This commit is contained in:
parent
2386859e4b
commit
6e8d77ff7f
Notes:
github-actions[bot]
2025-02-24 17:07:00 +00:00
Author: https://github.com/trflynn89
Commit: 6e8d77ff7f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3666
Reviewed-by: https://github.com/AtkinsSJ
10 changed files with 116 additions and 9 deletions
|
@ -228,6 +228,28 @@ JsonValue WalkerActor::serialize_node(JsonObject const& node) const
|
|||
return serialized;
|
||||
}
|
||||
|
||||
Optional<WalkerActor::DOMNode> WalkerActor::dom_node(StringView actor)
|
||||
{
|
||||
auto maybe_dom_node = m_actor_to_dom_node_map.get(actor);
|
||||
if (!maybe_dom_node.has_value() || !maybe_dom_node.value())
|
||||
return {};
|
||||
|
||||
auto const& dom_node = *maybe_dom_node.value();
|
||||
|
||||
auto pseudo_element = dom_node.get_integer<UnderlyingType<Web::CSS::Selector::PseudoElement::Type>>("pseudo-element"sv).map([](auto value) {
|
||||
VERIFY(value < to_underlying(Web::CSS::Selector::PseudoElement::Type::KnownPseudoElementCount));
|
||||
return static_cast<Web::CSS::Selector::PseudoElement::Type>(value);
|
||||
});
|
||||
|
||||
Web::UniqueNodeID node_id { 0 };
|
||||
if (pseudo_element.has_value())
|
||||
node_id = dom_node.get_integer<Web::UniqueNodeID::Type>("parent-id"sv).value();
|
||||
else
|
||||
node_id = dom_node.get_integer<Web::UniqueNodeID::Type>("id"sv).value();
|
||||
|
||||
return DOMNode { .node = dom_node, .id = node_id, .pseudo_element = pseudo_element };
|
||||
}
|
||||
|
||||
Optional<JsonObject const&> WalkerActor::find_node_by_selector(JsonObject const& node, StringView selector)
|
||||
{
|
||||
auto matches = [&](auto const& candidate) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue