mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00: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
|
@ -41,11 +41,9 @@ void PageStyleActor::handle_message(StringView type, JsonObject const& message)
|
|||
}
|
||||
|
||||
if (type == "getComputed"sv) {
|
||||
auto node = message.get_string("node"sv);
|
||||
if (!node.has_value()) {
|
||||
send_missing_parameter_error("node"sv);
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
}
|
||||
|
||||
inspect_dom_node(*node, [](auto& self, auto const& properties, auto 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) {
|
||||
auto node = message.get_string("node"sv);
|
||||
if (!node.has_value()) {
|
||||
send_missing_parameter_error("node"sv);
|
||||
auto node = get_required_parameter<String>(message, "node"sv);
|
||||
if (!node.has_value())
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue