mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibDevTools: Move message data into a structure
This is to prepare for an upcoming change where we will need to track replies to messages by ID. We will be able to add parameters to this structure without having to edit every single actor subclass header file.
This commit is contained in:
parent
509eaca73d
commit
24a5e4e7d5
Notes:
github-actions[bot]
2025-03-13 20:57:59 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/24a5e4e7d57 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3920
42 changed files with 162 additions and 146 deletions
|
@ -18,6 +18,11 @@ Actor::Actor(DevToolsServer& devtools, String name)
|
|||
|
||||
Actor::~Actor() = default;
|
||||
|
||||
void Actor::message_received(StringView type, JsonObject message)
|
||||
{
|
||||
handle_message({ type, move(message) });
|
||||
}
|
||||
|
||||
void Actor::send_message(JsonObject message, Optional<BlockToken> block_token)
|
||||
{
|
||||
if (m_block_responses && !block_token.has_value()) {
|
||||
|
@ -41,11 +46,11 @@ void Actor::send_missing_parameter_error(StringView parameter)
|
|||
}
|
||||
|
||||
// https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#error-packets
|
||||
void Actor::send_unrecognized_packet_type_error(StringView type)
|
||||
void Actor::send_unrecognized_packet_type_error(Message const& message)
|
||||
{
|
||||
JsonObject error;
|
||||
error.set("error"sv, "unrecognizedPacketType"sv);
|
||||
error.set("message"sv, MUST(String::formatted("Unrecognized packet type: '{}'", type)));
|
||||
error.set("message"sv, MUST(String::formatted("Unrecognized packet type: '{}'", message.type)));
|
||||
send_message(move(error));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,16 @@ class Actor
|
|||
: public RefCounted<Actor>
|
||||
, public Weakable<Actor> {
|
||||
public:
|
||||
struct Message {
|
||||
StringView type;
|
||||
JsonObject data;
|
||||
};
|
||||
|
||||
virtual ~Actor();
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
virtual void handle_message(StringView type, JsonObject const&) = 0;
|
||||
|
||||
void message_received(StringView type, JsonObject);
|
||||
|
||||
class [[nodiscard]] BlockToken {
|
||||
public:
|
||||
|
@ -46,31 +52,33 @@ public:
|
|||
|
||||
void send_message(JsonObject, Optional<BlockToken> block_token = {});
|
||||
void send_missing_parameter_error(StringView parameter);
|
||||
void send_unrecognized_packet_type_error(StringView type);
|
||||
void send_unrecognized_packet_type_error(Message const&);
|
||||
void send_unknown_actor_error(StringView actor);
|
||||
|
||||
protected:
|
||||
explicit Actor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) = 0;
|
||||
|
||||
DevToolsServer& devtools() { return m_devtools; }
|
||||
DevToolsServer const& devtools() const { return m_devtools; }
|
||||
|
||||
BlockToken block_responses();
|
||||
|
||||
template<typename ParameterType>
|
||||
auto get_required_parameter(JsonObject const& message, StringView parameter)
|
||||
auto get_required_parameter(Message const& message, StringView parameter)
|
||||
{
|
||||
auto result = [&]() {
|
||||
if constexpr (IsIntegral<ParameterType>)
|
||||
return message.get_integer<ParameterType>(parameter);
|
||||
return message.data.get_integer<ParameterType>(parameter);
|
||||
else if constexpr (IsSame<ParameterType, bool>)
|
||||
return message.get_bool(parameter);
|
||||
return message.data.get_bool(parameter);
|
||||
else if constexpr (IsSame<ParameterType, String>)
|
||||
return message.get_string(parameter);
|
||||
return message.data.get_string(parameter);
|
||||
else if constexpr (IsSame<ParameterType, JsonObject>)
|
||||
return message.get_object(parameter);
|
||||
return message.data.get_object(parameter);
|
||||
else if constexpr (IsSame<ParameterType, JsonArray>)
|
||||
return message.get_array(parameter);
|
||||
return message.data.get_array(parameter);
|
||||
else
|
||||
static_assert(DependentFalse<ParameterType>);
|
||||
}();
|
||||
|
|
|
@ -24,11 +24,11 @@ CSSPropertiesActor::CSSPropertiesActor(DevToolsServer& devtools, String name)
|
|||
|
||||
CSSPropertiesActor::~CSSPropertiesActor() = default;
|
||||
|
||||
void CSSPropertiesActor::handle_message(StringView type, JsonObject const&)
|
||||
void CSSPropertiesActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getCSSDatabase"sv) {
|
||||
if (message.type == "getCSSDatabase"sv) {
|
||||
auto css_property_list = devtools().delegate().css_property_list();
|
||||
|
||||
JsonObject properties;
|
||||
|
@ -51,7 +51,7 @@ void CSSPropertiesActor::handle_message(StringView type, JsonObject const&)
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ public:
|
|||
static NonnullRefPtr<CSSPropertiesActor> create(DevToolsServer&, String name);
|
||||
virtual ~CSSPropertiesActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
private:
|
||||
CSSPropertiesActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -39,18 +39,18 @@ ConsoleActor::ConsoleActor(DevToolsServer& devtools, String name, WeakPtr<TabAct
|
|||
|
||||
ConsoleActor::~ConsoleActor() = default;
|
||||
|
||||
void ConsoleActor::handle_message(StringView type, JsonObject const& message)
|
||||
void ConsoleActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "autocomplete"sv) {
|
||||
if (message.type == "autocomplete"sv) {
|
||||
response.set("matches"sv, JsonArray {});
|
||||
response.set("matchProp"sv, String {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "evaluateJSAsync"sv) {
|
||||
if (message.type == "evaluateJSAsync"sv) {
|
||||
auto text = get_required_parameter<String>(message, "text"sv);
|
||||
if (!text.has_value())
|
||||
return;
|
||||
|
@ -61,7 +61,7 @@ void ConsoleActor::handle_message(StringView type, JsonObject const& message)
|
|||
send_message(move(response));
|
||||
|
||||
// FIXME: We do not support eager evaluation of scripts. Just bail for now.
|
||||
if (message.get_bool("eager"sv).value_or(false)) {
|
||||
if (message.data.get_bool("eager"sv).value_or(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ void ConsoleActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ public:
|
|||
static NonnullRefPtr<ConsoleActor> create(DevToolsServer&, String name, WeakPtr<TabActor>);
|
||||
virtual ~ConsoleActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
private:
|
||||
ConsoleActor(DevToolsServer&, String name, WeakPtr<TabActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
WeakPtr<TabActor> m_tab;
|
||||
|
||||
u64 m_execution_id { 0 };
|
||||
|
|
|
@ -24,9 +24,9 @@ DeviceActor::DeviceActor(DevToolsServer& devtools, String name)
|
|||
|
||||
DeviceActor::~DeviceActor() = default;
|
||||
|
||||
void DeviceActor::handle_message(StringView type, JsonObject const&)
|
||||
void DeviceActor::handle_message(Message const& message)
|
||||
{
|
||||
if (type == "getDescription"sv) {
|
||||
if (message.type == "getDescription"sv) {
|
||||
auto build_id = Core::Version::read_long_version_string();
|
||||
|
||||
static auto browser_name = String::from_utf8_without_validation({ BROWSER_NAME, __builtin_strlen(BROWSER_NAME) });
|
||||
|
@ -54,7 +54,7 @@ void DeviceActor::handle_message(StringView type, JsonObject const&)
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ public:
|
|||
static NonnullRefPtr<DeviceActor> create(DevToolsServer&, String name);
|
||||
virtual ~DeviceActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
private:
|
||||
DeviceActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -51,11 +51,11 @@ FrameActor::~FrameActor()
|
|||
devtools().delegate().stop_listening_for_console_messages(tab->description());
|
||||
}
|
||||
|
||||
void FrameActor::handle_message(StringView type, JsonObject const&)
|
||||
void FrameActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "detach"sv) {
|
||||
if (message.type == "detach"sv) {
|
||||
if (auto tab = m_tab.strong_ref()) {
|
||||
devtools().delegate().stop_listening_for_dom_mutations(tab->description());
|
||||
devtools().delegate().stop_listening_for_console_messages(tab->description());
|
||||
|
@ -66,12 +66,12 @@ void FrameActor::handle_message(StringView type, JsonObject const&)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "listFrames"sv) {
|
||||
if (message.type == "listFrames"sv) {
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
void FrameActor::send_frame_update_message()
|
||||
|
|
|
@ -21,7 +21,6 @@ public:
|
|||
static NonnullRefPtr<FrameActor> create(DevToolsServer&, String name, WeakPtr<TabActor>, WeakPtr<CSSPropertiesActor>, WeakPtr<ConsoleActor>, WeakPtr<InspectorActor>, WeakPtr<ThreadActor>);
|
||||
virtual ~FrameActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
void send_frame_update_message();
|
||||
|
||||
JsonObject serialize_target() const;
|
||||
|
@ -29,6 +28,8 @@ public:
|
|||
private:
|
||||
FrameActor(DevToolsServer&, String name, WeakPtr<TabActor>, WeakPtr<CSSPropertiesActor>, WeakPtr<ConsoleActor>, WeakPtr<InspectorActor>, WeakPtr<ThreadActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
void console_message_available(i32 message_index);
|
||||
void console_messages_received(i32 start_index, Vector<WebView::ConsoleOutput>);
|
||||
void request_console_messages();
|
||||
|
|
|
@ -27,11 +27,11 @@ HighlighterActor::HighlighterActor(DevToolsServer& devtools, String name, WeakPt
|
|||
|
||||
HighlighterActor::~HighlighterActor() = default;
|
||||
|
||||
void HighlighterActor::handle_message(StringView type, JsonObject const& message)
|
||||
void HighlighterActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "show"sv) {
|
||||
if (message.type == "show"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -47,7 +47,7 @@ void HighlighterActor::handle_message(StringView type, JsonObject const& message
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "hide"sv) {
|
||||
if (message.type == "hide"sv) {
|
||||
if (auto tab = InspectorActor::tab_for(m_inspector))
|
||||
devtools().delegate().clear_highlighted_dom_node(tab->description());
|
||||
|
||||
|
@ -55,7 +55,7 @@ void HighlighterActor::handle_message(StringView type, JsonObject const& message
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonValue HighlighterActor::serialize_highlighter() const
|
||||
|
|
|
@ -18,12 +18,13 @@ public:
|
|||
static NonnullRefPtr<HighlighterActor> create(DevToolsServer&, String name, WeakPtr<InspectorActor>);
|
||||
virtual ~HighlighterActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
JsonValue serialize_highlighter() const;
|
||||
|
||||
private:
|
||||
HighlighterActor(DevToolsServer&, String name, WeakPtr<InspectorActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
WeakPtr<InspectorActor> m_inspector;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ InspectorActor::InspectorActor(DevToolsServer& devtools, String name, WeakPtr<Ta
|
|||
|
||||
InspectorActor::~InspectorActor() = default;
|
||||
|
||||
void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
||||
void InspectorActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getPageStyle"sv) {
|
||||
if (message.type == "getPageStyle"sv) {
|
||||
if (!m_page_style)
|
||||
m_page_style = devtools().register_actor<PageStyleActor>(*this);
|
||||
|
||||
|
@ -42,7 +42,7 @@ void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getHighlighterByType"sv) {
|
||||
if (message.type == "getHighlighterByType"sv) {
|
||||
auto type_name = get_required_parameter<String>(message, "typeName"sv);
|
||||
if (!type_name.has_value())
|
||||
return;
|
||||
|
@ -56,7 +56,7 @@ void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getWalker"sv) {
|
||||
if (message.type == "getWalker"sv) {
|
||||
if (auto tab = m_tab.strong_ref()) {
|
||||
devtools().delegate().inspect_tab(tab->description(),
|
||||
async_handler<InspectorActor>([](auto& self, auto dom_tree, auto& response) {
|
||||
|
@ -72,13 +72,13 @@ void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "supportsHighlighters"sv) {
|
||||
if (message.type == "supportsHighlighters"sv) {
|
||||
response.set("value"sv, true);
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
void InspectorActor::received_dom_tree(JsonObject& response, JsonObject dom_tree)
|
||||
|
|
|
@ -19,14 +19,14 @@ public:
|
|||
static NonnullRefPtr<InspectorActor> create(DevToolsServer&, String name, WeakPtr<TabActor>);
|
||||
virtual ~InspectorActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
static RefPtr<TabActor> tab_for(WeakPtr<InspectorActor> const&);
|
||||
static RefPtr<WalkerActor> walker_for(WeakPtr<InspectorActor> const&);
|
||||
|
||||
private:
|
||||
InspectorActor(DevToolsServer&, String name, WeakPtr<TabActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
void received_dom_tree(JsonObject& response, JsonObject dom_tree);
|
||||
|
||||
WeakPtr<TabActor> m_tab;
|
||||
|
|
|
@ -22,23 +22,23 @@ LayoutInspectorActor::LayoutInspectorActor(DevToolsServer& devtools, String name
|
|||
|
||||
LayoutInspectorActor::~LayoutInspectorActor() = default;
|
||||
|
||||
void LayoutInspectorActor::handle_message(StringView type, JsonObject const&)
|
||||
void LayoutInspectorActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getCurrentFlexbox"sv) {
|
||||
if (message.type == "getCurrentFlexbox"sv) {
|
||||
response.set("flexbox"sv, JsonValue {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "getGrids"sv) {
|
||||
if (message.type == "getGrids"sv) {
|
||||
response.set("grids"sv, JsonArray {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ public:
|
|||
static NonnullRefPtr<LayoutInspectorActor> create(DevToolsServer&, String name);
|
||||
virtual ~LayoutInspectorActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
private:
|
||||
LayoutInspectorActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -93,11 +93,11 @@ NodeActor::NodeActor(DevToolsServer& devtools, String name, NodeIdentifier node_
|
|||
|
||||
NodeActor::~NodeActor() = default;
|
||||
|
||||
void NodeActor::handle_message(StringView type, JsonObject const& message)
|
||||
void NodeActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getUniqueSelector"sv) {
|
||||
if (message.type == "getUniqueSelector"sv) {
|
||||
auto dom_node = WalkerActor::dom_node_for(m_walker, name());
|
||||
if (!dom_node.has_value()) {
|
||||
send_unknown_actor_error(name());
|
||||
|
@ -109,7 +109,7 @@ void NodeActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "modifyAttributes"sv) {
|
||||
if (message.type == "modifyAttributes"sv) {
|
||||
auto modifications = get_required_parameter<JsonArray>(message, "modifications"sv);
|
||||
if (!modifications.has_value())
|
||||
return;
|
||||
|
@ -132,7 +132,7 @@ void NodeActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "setNodeValue"sv) {
|
||||
if (message.type == "setNodeValue"sv) {
|
||||
auto value = get_required_parameter<String>(message, "value"sv);
|
||||
if (!value.has_value())
|
||||
return;
|
||||
|
@ -147,7 +147,7 @@ void NodeActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ public:
|
|||
static NonnullRefPtr<NodeActor> create(DevToolsServer&, String name, NodeIdentifier, WeakPtr<WalkerActor>);
|
||||
virtual ~NodeActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
NodeIdentifier const& node_identifier() const { return m_node_identifier; }
|
||||
|
||||
private:
|
||||
NodeActor(DevToolsServer&, String name, NodeIdentifier, WeakPtr<WalkerActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
NodeIdentifier m_node_identifier;
|
||||
|
||||
WeakPtr<WalkerActor> m_walker;
|
||||
|
|
|
@ -85,11 +85,11 @@ PageStyleActor::PageStyleActor(DevToolsServer& devtools, String name, WeakPtr<In
|
|||
|
||||
PageStyleActor::~PageStyleActor() = default;
|
||||
|
||||
void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
||||
void PageStyleActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getApplied"sv) {
|
||||
if (message.type == "getApplied"sv) {
|
||||
// FIXME: This provides information to the "styles" pane in the inspector tab, which allows toggling and editing
|
||||
// styles live. We do not yet support figuring out the list of styles that apply to a specific node.
|
||||
response.set("entries"sv, JsonArray {});
|
||||
|
@ -97,7 +97,7 @@ void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getComputed"sv) {
|
||||
if (message.type == "getComputed"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -109,7 +109,7 @@ void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getLayout"sv) {
|
||||
if (message.type == "getLayout"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -121,13 +121,13 @@ void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "isPositionEditable") {
|
||||
if (message.type == "isPositionEditable") {
|
||||
response.set("value"sv, false);
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonValue PageStyleActor::serialize_style() const
|
||||
|
|
|
@ -24,12 +24,13 @@ public:
|
|||
static NonnullRefPtr<PageStyleActor> create(DevToolsServer&, String name, WeakPtr<InspectorActor>);
|
||||
virtual ~PageStyleActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
JsonValue serialize_style() const;
|
||||
|
||||
private:
|
||||
PageStyleActor(DevToolsServer&, String name, WeakPtr<InspectorActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
template<typename Callback>
|
||||
void inspect_dom_node(StringView node_actor, Callback&&);
|
||||
|
||||
|
|
|
@ -21,21 +21,21 @@ PreferenceActor::PreferenceActor(DevToolsServer& devtools, String name)
|
|||
|
||||
PreferenceActor::~PreferenceActor() = default;
|
||||
|
||||
void PreferenceActor::handle_message(StringView type, JsonObject const&)
|
||||
void PreferenceActor::handle_message(Message const& message)
|
||||
{
|
||||
// FIXME: During session initialization, Firefox DevTools asks for the following boolean configurations:
|
||||
// browser.privatebrowsing.autostart
|
||||
// devtools.debugger.prompt-connection
|
||||
// dom.serviceWorkers.enabled
|
||||
// We just blindly return `false` for these, but we will eventually want a real configuration manager.
|
||||
if (type == "getBoolPref"sv) {
|
||||
if (message.type == "getBoolPref"sv) {
|
||||
JsonObject response;
|
||||
response.set("value"sv, false);
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ public:
|
|||
static NonnullRefPtr<PreferenceActor> create(DevToolsServer&, String name);
|
||||
virtual ~PreferenceActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
private:
|
||||
PreferenceActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ ProcessActor::ProcessActor(DevToolsServer& devtools, String name, ProcessDescrip
|
|||
|
||||
ProcessActor::~ProcessActor() = default;
|
||||
|
||||
void ProcessActor::handle_message(StringView type, JsonObject const&)
|
||||
void ProcessActor::handle_message(Message const& message)
|
||||
{
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonObject ProcessActor::serialize_description() const
|
||||
|
|
|
@ -24,14 +24,14 @@ public:
|
|||
static NonnullRefPtr<ProcessActor> create(DevToolsServer&, String name, ProcessDescription);
|
||||
virtual ~ProcessActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
ProcessDescription const& description() const { return m_description; }
|
||||
JsonObject serialize_description() const;
|
||||
|
||||
private:
|
||||
ProcessActor(DevToolsServer&, String name, ProcessDescription);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
ProcessDescription m_description;
|
||||
};
|
||||
|
||||
|
|
|
@ -41,16 +41,16 @@ RootActor::RootActor(DevToolsServer& devtools, String name)
|
|||
|
||||
RootActor::~RootActor() = default;
|
||||
|
||||
void RootActor::handle_message(StringView type, JsonObject const& message)
|
||||
void RootActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "connect") {
|
||||
if (message.type == "connect") {
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "getRoot"sv) {
|
||||
if (message.type == "getRoot"sv) {
|
||||
response.set("selected"sv, 0);
|
||||
|
||||
for (auto const& actor : devtools().actor_registry()) {
|
||||
|
@ -64,7 +64,7 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getProcess"sv) {
|
||||
if (message.type == "getProcess"sv) {
|
||||
auto id = get_required_parameter<u64>(message, "id"sv);
|
||||
if (!id.has_value())
|
||||
return;
|
||||
|
@ -84,7 +84,7 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getTab"sv) {
|
||||
if (message.type == "getTab"sv) {
|
||||
auto browser_id = get_required_parameter<u64>(message, "browserId"sv);
|
||||
if (!browser_id.has_value())
|
||||
return;
|
||||
|
@ -104,13 +104,13 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "listAddons"sv) {
|
||||
if (message.type == "listAddons"sv) {
|
||||
response.set("addons"sv, JsonArray {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "listProcesses"sv) {
|
||||
if (message.type == "listProcesses"sv) {
|
||||
JsonArray processes;
|
||||
|
||||
for (auto const& actor : devtools().actor_registry()) {
|
||||
|
@ -123,13 +123,13 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "listServiceWorkerRegistrations"sv) {
|
||||
if (message.type == "listServiceWorkerRegistrations"sv) {
|
||||
response.set("registrations"sv, JsonArray {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "listTabs"sv) {
|
||||
if (message.type == "listTabs"sv) {
|
||||
m_has_sent_tab_list_changed_since_last_list_tabs_request = false;
|
||||
|
||||
JsonArray tabs;
|
||||
|
@ -144,13 +144,13 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "listWorkers"sv) {
|
||||
if (message.type == "listWorkers"sv) {
|
||||
response.set("workers"sv, JsonArray {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
void RootActor::send_tab_list_changed_message()
|
||||
|
|
|
@ -18,13 +18,13 @@ public:
|
|||
static NonnullRefPtr<RootActor> create(DevToolsServer&, String name);
|
||||
virtual ~RootActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
void send_tab_list_changed_message();
|
||||
|
||||
private:
|
||||
RootActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
// https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#the-request-reply-notify-pattern
|
||||
// the root actor sends at most one "tabListChanged" notification after each "listTabs" request.
|
||||
bool m_has_sent_tab_list_changed_since_last_list_tabs_request { false };
|
||||
|
|
|
@ -28,11 +28,11 @@ TabActor::~TabActor()
|
|||
reset_selected_node();
|
||||
}
|
||||
|
||||
void TabActor::handle_message(StringView type, JsonObject const&)
|
||||
void TabActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getFavicon"sv) {
|
||||
if (message.type == "getFavicon"sv) {
|
||||
// FIXME: Firefox DevTools wants a favicon URL here, but supplying a URL seems to prevent this tab from being
|
||||
// listed on the about:debugging page. Both Servo and Firefox itself supply `null` here.
|
||||
response.set("favicon"sv, JsonValue {});
|
||||
|
@ -40,7 +40,7 @@ void TabActor::handle_message(StringView type, JsonObject const&)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getWatcher"sv) {
|
||||
if (message.type == "getWatcher"sv) {
|
||||
if (!m_watcher)
|
||||
m_watcher = devtools().register_actor<WatcherActor>(this);
|
||||
|
||||
|
@ -50,7 +50,7 @@ void TabActor::handle_message(StringView type, JsonObject const&)
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonObject TabActor::serialize_description() const
|
||||
|
|
|
@ -25,8 +25,6 @@ public:
|
|||
static NonnullRefPtr<TabActor> create(DevToolsServer&, String name, TabDescription);
|
||||
virtual ~TabActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
TabDescription const& description() const { return m_description; }
|
||||
JsonObject serialize_description() const;
|
||||
|
||||
|
@ -35,6 +33,8 @@ public:
|
|||
private:
|
||||
TabActor(DevToolsServer&, String name, TabDescription);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
TabDescription m_description;
|
||||
WeakPtr<WatcherActor> m_watcher;
|
||||
};
|
||||
|
|
|
@ -22,11 +22,11 @@ TargetConfigurationActor::TargetConfigurationActor(DevToolsServer& devtools, Str
|
|||
|
||||
TargetConfigurationActor::~TargetConfigurationActor() = default;
|
||||
|
||||
void TargetConfigurationActor::handle_message(StringView type, JsonObject const& message)
|
||||
void TargetConfigurationActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "updateConfiguration"sv) {
|
||||
if (message.type == "updateConfiguration"sv) {
|
||||
auto configuration = get_required_parameter<JsonObject>(message, "configuration"sv);
|
||||
if (!configuration.has_value())
|
||||
return;
|
||||
|
@ -35,7 +35,7 @@ void TargetConfigurationActor::handle_message(StringView type, JsonObject const&
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonObject TargetConfigurationActor::serialize_configuration() const
|
||||
|
|
|
@ -18,12 +18,12 @@ public:
|
|||
static NonnullRefPtr<TargetConfigurationActor> create(DevToolsServer&, String name);
|
||||
virtual ~TargetConfigurationActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
JsonObject serialize_configuration() const;
|
||||
|
||||
private:
|
||||
TargetConfigurationActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ ThreadActor::ThreadActor(DevToolsServer& devtools, String name)
|
|||
|
||||
ThreadActor::~ThreadActor() = default;
|
||||
|
||||
void ThreadActor::handle_message(StringView type, JsonObject const&)
|
||||
void ThreadActor::handle_message(Message const& message)
|
||||
{
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ public:
|
|||
static NonnullRefPtr<ThreadActor> create(DevToolsServer&, String name);
|
||||
virtual ~ThreadActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
private:
|
||||
ThreadActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ ThreadConfigurationActor::ThreadConfigurationActor(DevToolsServer& devtools, Str
|
|||
|
||||
ThreadConfigurationActor::~ThreadConfigurationActor() = default;
|
||||
|
||||
void ThreadConfigurationActor::handle_message(StringView type, JsonObject const& message)
|
||||
void ThreadConfigurationActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "updateConfiguration"sv) {
|
||||
if (message.type == "updateConfiguration"sv) {
|
||||
auto configuration = get_required_parameter<JsonObject>(message, "configuration"sv);
|
||||
if (!configuration.has_value())
|
||||
return;
|
||||
|
@ -35,7 +35,7 @@ void ThreadConfigurationActor::handle_message(StringView type, JsonObject const&
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonObject ThreadConfigurationActor::serialize_configuration() const
|
||||
|
|
|
@ -18,12 +18,12 @@ public:
|
|||
static NonnullRefPtr<ThreadConfigurationActor> create(DevToolsServer&, String name);
|
||||
virtual ~ThreadConfigurationActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
JsonObject serialize_configuration() const;
|
||||
|
||||
private:
|
||||
ThreadConfigurationActor(DevToolsServer&, String name);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ WalkerActor::~WalkerActor()
|
|||
devtools().delegate().stop_listening_for_dom_mutations(tab->description());
|
||||
}
|
||||
|
||||
void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||
void WalkerActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "children"sv) {
|
||||
if (message.type == "children"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -73,7 +73,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "duplicateNode"sv) {
|
||||
if (message.type == "duplicateNode"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "editTagName"sv) {
|
||||
if (message.type == "editTagName"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -107,7 +107,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getLayoutInspector"sv) {
|
||||
if (message.type == "getLayoutInspector"sv) {
|
||||
if (!m_layout_inspector)
|
||||
m_layout_inspector = devtools().register_actor<LayoutInspectorActor>();
|
||||
|
||||
|
@ -119,7 +119,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getMutations"sv) {
|
||||
if (message.type == "getMutations"sv) {
|
||||
response.set("mutations"sv, serialize_mutations());
|
||||
send_message(move(response));
|
||||
|
||||
|
@ -127,13 +127,13 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getOffsetParent"sv) {
|
||||
if (message.type == "getOffsetParent"sv) {
|
||||
response.set("node"sv, JsonValue {});
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "innerHTML"sv) {
|
||||
if (message.type == "innerHTML"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -152,7 +152,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "insertAdjacentHTML") {
|
||||
if (message.type == "insertAdjacentHTML") {
|
||||
// FIXME: This message also contains `value` and `position` parameters, containing the HTML to insert and the
|
||||
// location to insert it. For the "Create New Node" action, this is always "<div></div>" and "beforeEnd",
|
||||
// which is exactly what our WebView implementation currently supports.
|
||||
|
@ -182,7 +182,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "insertBefore"sv) {
|
||||
if (message.type == "insertBefore"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -204,7 +204,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
}
|
||||
|
||||
Optional<Web::UniqueNodeID> sibling_node_id;
|
||||
if (auto sibling = message.get_string("sibling"sv); sibling.has_value()) {
|
||||
if (auto sibling = message.data.get_string("sibling"sv); sibling.has_value()) {
|
||||
auto sibling_dom_node = WalkerActor::dom_node_for(*this, *sibling);
|
||||
if (!sibling_dom_node.has_value()) {
|
||||
send_unknown_actor_error(*sibling);
|
||||
|
@ -218,7 +218,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "isInDOMTree"sv) {
|
||||
if (message.type == "isInDOMTree"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -228,7 +228,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "outerHTML"sv) {
|
||||
if (message.type == "outerHTML"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -247,7 +247,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "previousSibling"sv) {
|
||||
if (message.type == "previousSibling"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -267,7 +267,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "querySelector"sv) {
|
||||
if (message.type == "querySelector"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -298,7 +298,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "removeNode"sv) {
|
||||
if (message.type == "removeNode"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -325,12 +325,12 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "retainNode"sv) {
|
||||
if (message.type == "retainNode"sv) {
|
||||
send_message(move(response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "setOuterHTML"sv) {
|
||||
if (message.type == "setOuterHTML"sv) {
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
|
@ -349,7 +349,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "watchRootNode"sv) {
|
||||
if (message.type == "watchRootNode"sv) {
|
||||
response.set("type"sv, "root-available"sv);
|
||||
response.set("node"sv, serialize_root());
|
||||
send_message(move(response));
|
||||
|
@ -358,7 +358,7 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
bool WalkerActor::is_suitable_for_dom_inspection(JsonValue const& node)
|
||||
|
|
|
@ -24,8 +24,6 @@ public:
|
|||
static NonnullRefPtr<WalkerActor> create(DevToolsServer&, String name, WeakPtr<TabActor>, JsonObject dom_tree);
|
||||
virtual ~WalkerActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
static bool is_suitable_for_dom_inspection(JsonValue const&);
|
||||
JsonValue serialize_root() const;
|
||||
|
||||
|
@ -40,6 +38,8 @@ public:
|
|||
private:
|
||||
WalkerActor(DevToolsServer&, String name, WeakPtr<TabActor>, JsonObject dom_tree);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
JsonValue serialize_node(JsonObject const&) const;
|
||||
Optional<JsonObject const&> find_node_by_selector(JsonObject const& node, StringView selector);
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ WatcherActor::WatcherActor(DevToolsServer& devtools, String name, WeakPtr<TabAct
|
|||
|
||||
WatcherActor::~WatcherActor() = default;
|
||||
|
||||
void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
||||
void WatcherActor::handle_message(Message const& message)
|
||||
{
|
||||
JsonObject response;
|
||||
|
||||
if (type == "getParentBrowsingContextID"sv) {
|
||||
if (message.type == "getParentBrowsingContextID"sv) {
|
||||
auto browsing_context_id = get_required_parameter<u64>(message, "browsingContextID"sv);
|
||||
if (!browsing_context_id.has_value())
|
||||
return;
|
||||
|
@ -47,7 +47,7 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getTargetConfigurationActor"sv) {
|
||||
if (message.type == "getTargetConfigurationActor"sv) {
|
||||
if (!m_target_configuration)
|
||||
m_target_configuration = devtools().register_actor<TargetConfigurationActor>();
|
||||
|
||||
|
@ -56,7 +56,7 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "getThreadConfigurationActor"sv) {
|
||||
if (message.type == "getThreadConfigurationActor"sv) {
|
||||
if (!m_thread_configuration)
|
||||
m_thread_configuration = devtools().register_actor<ThreadConfigurationActor>();
|
||||
|
||||
|
@ -65,7 +65,7 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "watchResources"sv) {
|
||||
if (message.type == "watchResources"sv) {
|
||||
auto resource_types = get_required_parameter<JsonArray>(message, "resourceTypes"sv);
|
||||
if (!resource_types.has_value())
|
||||
return;
|
||||
|
@ -83,7 +83,7 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "watchTargets"sv) {
|
||||
if (message.type == "watchTargets"sv) {
|
||||
auto target_type = get_required_parameter<String>(message, "targetType"sv);
|
||||
if (!target_type.has_value())
|
||||
return;
|
||||
|
@ -108,7 +108,7 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
|||
}
|
||||
}
|
||||
|
||||
send_unrecognized_packet_type_error(type);
|
||||
send_unrecognized_packet_type_error(message);
|
||||
}
|
||||
|
||||
JsonObject WatcherActor::serialize_description() const
|
||||
|
|
|
@ -18,13 +18,13 @@ public:
|
|||
static NonnullRefPtr<WatcherActor> create(DevToolsServer&, String name, WeakPtr<TabActor>);
|
||||
virtual ~WatcherActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
JsonObject serialize_description() const;
|
||||
|
||||
private:
|
||||
WatcherActor(DevToolsServer&, String name, WeakPtr<TabActor>);
|
||||
|
||||
virtual void handle_message(Message const&) override;
|
||||
|
||||
WeakPtr<TabActor> m_tab;
|
||||
WeakPtr<Actor> m_target;
|
||||
WeakPtr<TargetConfigurationActor> m_target_configuration;
|
||||
|
|
|
@ -88,9 +88,9 @@ ErrorOr<void> Connection::on_ready_to_read()
|
|||
if (!message.is_object())
|
||||
continue;
|
||||
|
||||
Core::deferred_invoke([this, message = move(message)]() {
|
||||
Core::deferred_invoke([this, message = move(message)]() mutable {
|
||||
if (on_message_received)
|
||||
on_message_received(message.as_object());
|
||||
on_message_received(move(message.as_object()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
~Connection();
|
||||
|
||||
Function<void()> on_connection_closed;
|
||||
Function<void(JsonObject const&)> on_message_received;
|
||||
Function<void(JsonObject)> on_message_received;
|
||||
|
||||
void send_message(JsonValue const&);
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ ErrorOr<void> DevToolsServer::on_new_client()
|
|||
close_connection();
|
||||
};
|
||||
|
||||
m_connection->on_message_received = [this](auto const& message) {
|
||||
on_message_received(message);
|
||||
m_connection->on_message_received = [this](auto message) {
|
||||
on_message_received(move(message));
|
||||
};
|
||||
|
||||
m_root_actor = register_actor<RootActor>();
|
||||
|
@ -83,7 +83,7 @@ ErrorOr<void> DevToolsServer::on_new_client()
|
|||
return {};
|
||||
}
|
||||
|
||||
void DevToolsServer::on_message_received(JsonObject const& message)
|
||||
void DevToolsServer::on_message_received(JsonObject message)
|
||||
{
|
||||
auto to = message.get_string("to"sv);
|
||||
if (!to.has_value()) {
|
||||
|
@ -103,7 +103,7 @@ void DevToolsServer::on_message_received(JsonObject const& message)
|
|||
return;
|
||||
}
|
||||
|
||||
actor->value->handle_message(*type, message);
|
||||
actor->value->message_received(*type, move(message));
|
||||
}
|
||||
|
||||
void DevToolsServer::close_connection()
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
explicit DevToolsServer(DevToolsDelegate&, NonnullRefPtr<Core::TCPServer>);
|
||||
|
||||
ErrorOr<void> on_new_client();
|
||||
void on_message_received(JsonObject const&);
|
||||
void on_message_received(JsonObject);
|
||||
|
||||
void close_connection();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue