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:
Timothy Flynn 2025-02-21 12:39:43 -05:00 committed by Tim Flynn
commit d4b7dd88b7
Notes: github-actions[bot] 2025-02-24 17:07:18 +00:00
4 changed files with 63 additions and 70 deletions

View file

@ -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();