mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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
|
@ -51,7 +51,7 @@ void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
|||
}
|
||||
|
||||
auto highlighter = m_highlighters.ensure(*type_name, [&]() -> NonnullRefPtr<HighlighterActor> {
|
||||
return devtools().register_actor<HighlighterActor>();
|
||||
return devtools().register_actor<HighlighterActor>(*this);
|
||||
});
|
||||
|
||||
response.set("highlighter"sv, highlighter->serialize_highlighter());
|
||||
|
@ -82,12 +82,19 @@ void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "supportsHighlighters"sv) {
|
||||
response.set("value"sv, true);
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
}
|
||||
|
||||
void InspectorActor::received_dom_tree(JsonObject dom_tree, BlockToken block_token)
|
||||
{
|
||||
auto& walker_actor = devtools().register_actor<WalkerActor>(m_tab, move(dom_tree));
|
||||
m_walker = walker_actor;
|
||||
|
||||
JsonObject walker;
|
||||
walker.set("actor"sv, walker_actor.name());
|
||||
|
@ -99,4 +106,18 @@ void InspectorActor::received_dom_tree(JsonObject dom_tree, BlockToken block_tok
|
|||
send_message(move(message), move(block_token));
|
||||
}
|
||||
|
||||
RefPtr<TabActor> InspectorActor::tab_for(WeakPtr<InspectorActor> const& weak_inspector)
|
||||
{
|
||||
if (auto inspector = weak_inspector.strong_ref())
|
||||
return inspector->m_tab.strong_ref();
|
||||
return {};
|
||||
}
|
||||
|
||||
RefPtr<WalkerActor> InspectorActor::walker_for(WeakPtr<InspectorActor> const& weak_inspector)
|
||||
{
|
||||
if (auto inspector = weak_inspector.strong_ref())
|
||||
return inspector->m_walker.strong_ref();
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue