mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibWebView: Parse inspector-related JSON strings sooner
We currently receive serialized JSON values over IPC and forward them to them WebView callbacks, leaving it to the implementations of those callbacks to parse the strings as JSON objects. This patch hoists that parsing up to WebContentClient as soon as the IPC message is received. This is to reduce the work needed for secondary implementations of these callbacks (i.e. our Firefox DevTools server).
This commit is contained in:
@@ -371,14 +371,9 @@ void Application::inspect_tab(DevTools::TabDescription const& description, DevTo
|
||||
return;
|
||||
}
|
||||
|
||||
view->on_received_dom_tree = [&view = *view, on_complete = move(on_complete)](String const& dom_tree) {
|
||||
view->on_received_dom_tree = [&view = *view, on_complete = move(on_complete)](JsonObject dom_tree) {
|
||||
view.on_received_dom_tree = nullptr;
|
||||
|
||||
if (auto parsed_tree = JsonValue::from_string(dom_tree); parsed_tree.is_error()) {
|
||||
on_complete(parsed_tree.release_error());
|
||||
} else {
|
||||
on_complete(parsed_tree.release_value());
|
||||
}
|
||||
on_complete(move(dom_tree));
|
||||
};
|
||||
|
||||
view->inspect_dom_tree();
|
||||
|
||||
Reference in New Issue
Block a user