mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibDevTools: Add a helper to acquire required message parameters
This is just to help make the message handlers a bit briefer. I had considered adding a TRY-like macro to auto-return when the lookup fails, but since statement expressions cannot return references, that would result in a copy of all e.g. object and array lookups.
This commit is contained in:
parent
4ce10f3bf4
commit
e1ed8722e0
Notes:
github-actions[bot]
2025-03-12 16:49:03 +00:00
Author: https://github.com/trflynn89
Commit: e1ed8722e0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3904
12 changed files with 85 additions and 121 deletions
|
@ -4,7 +4,6 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/JsonObject.h>
|
|
||||||
#include <LibDevTools/Actor.h>
|
#include <LibDevTools/Actor.h>
|
||||||
#include <LibDevTools/Connection.h>
|
#include <LibDevTools/Connection.h>
|
||||||
#include <LibDevTools/DevToolsServer.h>
|
#include <LibDevTools/DevToolsServer.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Badge.h>
|
#include <AK/Badge.h>
|
||||||
|
#include <AK/JsonObject.h>
|
||||||
#include <AK/Optional.h>
|
#include <AK/Optional.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
@ -55,6 +56,30 @@ protected:
|
||||||
|
|
||||||
BlockToken block_responses();
|
BlockToken block_responses();
|
||||||
|
|
||||||
|
template<typename ParameterType>
|
||||||
|
auto get_required_parameter(JsonObject const& message, StringView parameter)
|
||||||
|
{
|
||||||
|
auto result = [&]() {
|
||||||
|
if constexpr (IsIntegral<ParameterType>)
|
||||||
|
return message.get_integer<ParameterType>(parameter);
|
||||||
|
else if constexpr (IsSame<ParameterType, bool>)
|
||||||
|
return message.get_bool(parameter);
|
||||||
|
else if constexpr (IsSame<ParameterType, String>)
|
||||||
|
return message.get_string(parameter);
|
||||||
|
else if constexpr (IsSame<ParameterType, JsonObject>)
|
||||||
|
return message.get_object(parameter);
|
||||||
|
else if constexpr (IsSame<ParameterType, JsonArray>)
|
||||||
|
return message.get_array(parameter);
|
||||||
|
else
|
||||||
|
static_assert(DependentFalse<ParameterType>);
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (!result.has_value())
|
||||||
|
send_missing_parameter_error(parameter);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevToolsServer& m_devtools;
|
DevToolsServer& m_devtools;
|
||||||
String m_name;
|
String m_name;
|
||||||
|
|
|
@ -40,11 +40,9 @@ void ConsoleActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "evaluateJSAsync"sv) {
|
if (type == "evaluateJSAsync"sv) {
|
||||||
auto text = message.get_string("text"sv);
|
auto text = get_required_parameter<String>(message, "text"sv);
|
||||||
if (!text.has_value()) {
|
if (!text.has_value())
|
||||||
send_missing_parameter_error("text"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto result_id = MUST(String::formatted("{}-{}", name(), m_execution_id++));
|
auto result_id = MUST(String::formatted("{}-{}", name(), m_execution_id++));
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,9 @@ void HighlighterActor::handle_message(StringView type, JsonObject const& message
|
||||||
JsonObject response;
|
JsonObject response;
|
||||||
|
|
||||||
if (type == "show"sv) {
|
if (type == "show"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
response.set("value"sv, false);
|
response.set("value"sv, false);
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,9 @@ void InspectorActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "getHighlighterByType"sv) {
|
if (type == "getHighlighterByType"sv) {
|
||||||
auto type_name = message.get_string("typeName"sv);
|
auto type_name = get_required_parameter<String>(message, "typeName"sv);
|
||||||
if (!type_name.has_value()) {
|
if (!type_name.has_value())
|
||||||
send_missing_parameter_error("typeName"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto highlighter = m_highlighters.ensure(*type_name, [&]() -> NonnullRefPtr<HighlighterActor> {
|
auto highlighter = m_highlighters.ensure(*type_name, [&]() -> NonnullRefPtr<HighlighterActor> {
|
||||||
return devtools().register_actor<HighlighterActor>(*this);
|
return devtools().register_actor<HighlighterActor>(*this);
|
||||||
|
|
|
@ -110,11 +110,9 @@ void NodeActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "modifyAttributes"sv) {
|
if (type == "modifyAttributes"sv) {
|
||||||
auto modifications = message.get_array("modifications"sv);
|
auto modifications = get_required_parameter<JsonArray>(message, "modifications"sv);
|
||||||
if (!modifications.has_value()) {
|
if (!modifications.has_value())
|
||||||
send_missing_parameter_error("modifications"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto [attribute_to_replace, replacement_attributes] = parse_attribute_modification(*modifications);
|
auto [attribute_to_replace, replacement_attributes] = parse_attribute_modification(*modifications);
|
||||||
if (!attribute_to_replace.has_value() && replacement_attributes.is_empty())
|
if (!attribute_to_replace.has_value() && replacement_attributes.is_empty())
|
||||||
|
@ -148,11 +146,9 @@ void NodeActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "setNodeValue"sv) {
|
if (type == "setNodeValue"sv) {
|
||||||
auto value = message.get_string("value"sv);
|
auto value = get_required_parameter<String>(message, "value"sv);
|
||||||
if (!value.has_value()) {
|
if (!value.has_value())
|
||||||
send_missing_parameter_error("value"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(m_walker, name());
|
auto dom_node = WalkerActor::dom_node_for(m_walker, name());
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
|
|
@ -41,11 +41,9 @@ void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "getComputed"sv) {
|
if (type == "getComputed"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
inspect_dom_node(*node, [](auto& self, auto const& properties, auto block_token) {
|
inspect_dom_node(*node, [](auto& self, auto const& properties, auto block_token) {
|
||||||
self.received_computed_style(properties.computed_style, move(block_token));
|
self.received_computed_style(properties.computed_style, move(block_token));
|
||||||
|
@ -55,11 +53,9 @@ void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "getLayout"sv) {
|
if (type == "getLayout"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
inspect_dom_node(*node, [](auto& self, auto const& properties, auto block_token) {
|
inspect_dom_node(*node, [](auto& self, auto const& properties, auto block_token) {
|
||||||
self.received_layout(properties.computed_style, properties.node_box_sizing, move(block_token));
|
self.received_layout(properties.computed_style, properties.node_box_sizing, move(block_token));
|
||||||
|
|
|
@ -65,11 +65,9 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "getProcess"sv) {
|
if (type == "getProcess"sv) {
|
||||||
auto id = message.get_integer<u64>("id"sv);
|
auto id = get_required_parameter<u64>(message, "id"sv);
|
||||||
if (!id.has_value()) {
|
if (!id.has_value())
|
||||||
send_missing_parameter_error("id"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const& actor : devtools().actor_registry()) {
|
for (auto const& actor : devtools().actor_registry()) {
|
||||||
auto const* process_actor = as_if<ProcessActor>(*actor.value);
|
auto const* process_actor = as_if<ProcessActor>(*actor.value);
|
||||||
|
@ -87,11 +85,9 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "getTab"sv) {
|
if (type == "getTab"sv) {
|
||||||
auto browser_id = message.get_integer<u64>("browserId"sv);
|
auto browser_id = get_required_parameter<u64>(message, "browserId"sv);
|
||||||
if (!browser_id.has_value()) {
|
if (!browser_id.has_value())
|
||||||
send_missing_parameter_error("browserId"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const& actor : devtools().actor_registry()) {
|
for (auto const& actor : devtools().actor_registry()) {
|
||||||
auto const* tab_actor = as_if<TabActor>(*actor.value);
|
auto const* tab_actor = as_if<TabActor>(*actor.value);
|
||||||
|
|
|
@ -27,11 +27,9 @@ void TargetConfigurationActor::handle_message(StringView type, JsonObject const&
|
||||||
JsonObject response;
|
JsonObject response;
|
||||||
|
|
||||||
if (type == "updateConfiguration"sv) {
|
if (type == "updateConfiguration"sv) {
|
||||||
auto configuration = message.get_object("configuration"sv);
|
auto configuration = get_required_parameter<JsonObject>(message, "configuration"sv);
|
||||||
if (!configuration.has_value()) {
|
if (!configuration.has_value())
|
||||||
send_missing_parameter_error("configuration"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
send_message(move(response));
|
send_message(move(response));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,11 +27,9 @@ void ThreadConfigurationActor::handle_message(StringView type, JsonObject const&
|
||||||
JsonObject response;
|
JsonObject response;
|
||||||
|
|
||||||
if (type == "updateConfiguration"sv) {
|
if (type == "updateConfiguration"sv) {
|
||||||
auto configuration = message.get_object("configuration"sv);
|
auto configuration = get_required_parameter<JsonObject>(message, "configuration"sv);
|
||||||
if (!configuration.has_value()) {
|
if (!configuration.has_value())
|
||||||
send_missing_parameter_error("configuration"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
send_message(move(response));
|
send_message(move(response));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,11 +48,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
JsonObject response;
|
JsonObject response;
|
||||||
|
|
||||||
if (type == "children"sv) {
|
if (type == "children"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto ancestor_node = WalkerActor::dom_node_for(*this, *node);
|
auto ancestor_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!ancestor_node.has_value()) {
|
if (!ancestor_node.has_value()) {
|
||||||
|
@ -76,11 +74,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "duplicateNode"sv) {
|
if (type == "duplicateNode"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -106,17 +102,13 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "editTagName"sv) {
|
if (type == "editTagName"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto tag_name = message.get_string("tagName"sv);
|
auto tag_name = get_required_parameter<String>(message, "tagName"sv);
|
||||||
if (!tag_name.has_value()) {
|
if (!tag_name.has_value())
|
||||||
send_missing_parameter_error("tagName"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -168,11 +160,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "innerHTML"sv) {
|
if (type == "innerHTML"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -204,11 +194,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
// FIXME: This message also contains `value` and `position` parameters, containing the HTML to insert and the
|
// 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",
|
// 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.
|
// which is exactly what our WebView implementation currently supports.
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -245,17 +233,13 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "insertBefore"sv) {
|
if (type == "insertBefore"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto parent = message.get_string("parent"sv);
|
auto parent = get_required_parameter<String>(message, "parent"sv);
|
||||||
if (!parent.has_value()) {
|
if (!parent.has_value())
|
||||||
send_missing_parameter_error("parent"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -298,11 +282,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "isInDOMTree"sv) {
|
if (type == "isInDOMTree"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
response.set("attached"sv, m_actor_to_dom_node_map.contains(*node));
|
response.set("attached"sv, m_actor_to_dom_node_map.contains(*node));
|
||||||
send_message(move(response));
|
send_message(move(response));
|
||||||
|
@ -310,11 +292,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "outerHTML"sv) {
|
if (type == "outerHTML"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -343,11 +323,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "previousSibling"sv) {
|
if (type == "previousSibling"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -365,17 +343,13 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "querySelector"sv) {
|
if (type == "querySelector"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto selector = message.get_string("selector"sv);
|
auto selector = get_required_parameter<String>(message, "selector"sv);
|
||||||
if (!selector.has_value()) {
|
if (!selector.has_value())
|
||||||
send_missing_parameter_error("selector"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto ancestor_node = WalkerActor::dom_node_for(*this, *node);
|
auto ancestor_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!ancestor_node.has_value()) {
|
if (!ancestor_node.has_value()) {
|
||||||
|
@ -400,11 +374,9 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "removeNode"sv) {
|
if (type == "removeNode"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
@ -446,17 +418,13 @@ void WalkerActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "setOuterHTML"sv) {
|
if (type == "setOuterHTML"sv) {
|
||||||
auto node = message.get_string("node"sv);
|
auto node = get_required_parameter<String>(message, "node"sv);
|
||||||
if (!node.has_value()) {
|
if (!node.has_value())
|
||||||
send_missing_parameter_error("node"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto value = message.get_string("value"sv);
|
auto value = get_required_parameter<String>(message, "value"sv);
|
||||||
if (!value.has_value()) {
|
if (!value.has_value())
|
||||||
send_missing_parameter_error("value"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
auto dom_node = WalkerActor::dom_node_for(*this, *node);
|
||||||
if (!dom_node.has_value()) {
|
if (!dom_node.has_value()) {
|
||||||
|
|
|
@ -38,11 +38,9 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
||||||
JsonObject response;
|
JsonObject response;
|
||||||
|
|
||||||
if (type == "getParentBrowsingContextID"sv) {
|
if (type == "getParentBrowsingContextID"sv) {
|
||||||
auto browsing_context_id = message.get_integer<u64>("browsingContextID"sv);
|
auto browsing_context_id = get_required_parameter<u64>(message, "browsingContextID"sv);
|
||||||
if (!browsing_context_id.has_value()) {
|
if (!browsing_context_id.has_value())
|
||||||
send_missing_parameter_error("browsingContextID"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
response.set("browsingContextID"sv, *browsing_context_id);
|
response.set("browsingContextID"sv, *browsing_context_id);
|
||||||
send_message(move(response));
|
send_message(move(response));
|
||||||
|
@ -68,11 +66,9 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "watchResources"sv) {
|
if (type == "watchResources"sv) {
|
||||||
auto resource_types = message.get_array("resourceTypes"sv);
|
auto resource_types = get_required_parameter<JsonArray>(message, "resourceTypes"sv);
|
||||||
if (!resource_types.has_value()) {
|
if (!resource_types.has_value())
|
||||||
send_missing_parameter_error("resourceTypes"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (DEVTOOLS_DEBUG) {
|
if constexpr (DEVTOOLS_DEBUG) {
|
||||||
for (auto const& resource_type : resource_types->values()) {
|
for (auto const& resource_type : resource_types->values()) {
|
||||||
|
@ -88,11 +84,9 @@ void WatcherActor::handle_message(StringView type, JsonObject const& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "watchTargets"sv) {
|
if (type == "watchTargets"sv) {
|
||||||
auto target_type = message.get_string("targetType"sv);
|
auto target_type = get_required_parameter<String>(message, "targetType"sv);
|
||||||
if (!target_type.has_value()) {
|
if (!target_type.has_value())
|
||||||
send_missing_parameter_error("targetType"sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (target_type == "frame"sv) {
|
if (target_type == "frame"sv) {
|
||||||
auto& css_properties = devtools().register_actor<CSSPropertiesActor>();
|
auto& css_properties = devtools().register_actor<CSSPropertiesActor>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue