mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibDevTools: Store highlighter actors by type
We will be asked for different highlighters throughout the DevTools session, e.g. ViewportSizeOnResizeHighlighter and BoxModelHighlighter. The latter will be responsible for rendering and overlay on DOM nodes when the user hovers over a node in the inspector panel.
This commit is contained in:
parent
72905c84d5
commit
2386859e4b
Notes:
github-actions[bot]
2025-02-24 17:07:05 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/2386859e4bd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3666 Reviewed-by: https://github.com/AtkinsSJ
2 changed files with 13 additions and 5 deletions
|
@ -29,7 +29,7 @@ InspectorActor::InspectorActor(DevToolsServer& devtools, String name, WeakPtr<Ta
|
|||
|
||||
InspectorActor::~InspectorActor() = default;
|
||||
|
||||
void InspectorActor::handle_message(StringView type, JsonObject const&)
|
||||
void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
response.set("from"sv, name());
|
||||
|
@ -44,10 +44,17 @@ void InspectorActor::handle_message(StringView type, JsonObject const&)
|
|||
}
|
||||
|
||||
if (type == "getHighlighterByType"sv) {
|
||||
if (!m_highlighter)
|
||||
m_highlighter = devtools().register_actor<HighlighterActor>();
|
||||
auto type_name = message.get_string("typeName"sv);
|
||||
if (!type_name.has_value()) {
|
||||
send_missing_parameter_error("typeName"sv);
|
||||
return;
|
||||
}
|
||||
|
||||
response.set("highlighter"sv, m_highlighter->serialize_highlighter());
|
||||
auto highlighter = m_highlighters.ensure(*type_name, [&]() -> NonnullRefPtr<HighlighterActor> {
|
||||
return devtools().register_actor<HighlighterActor>();
|
||||
});
|
||||
|
||||
response.set("highlighter"sv, highlighter->serialize_highlighter());
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibDevTools/Actor.h>
|
||||
|
||||
|
@ -27,7 +28,7 @@ private:
|
|||
|
||||
WeakPtr<TabActor> m_tab;
|
||||
WeakPtr<PageStyleActor> m_page_style;
|
||||
WeakPtr<HighlighterActor> m_highlighter;
|
||||
HashMap<String, WeakPtr<HighlighterActor>> m_highlighters;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue