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

@ -9,6 +9,8 @@
#include <AK/Forward.h>
#include <AK/Function.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <AK/LexicalPath.h>
#include <AK/Queue.h>
#include <AK/String.h>
@ -35,12 +37,12 @@ public:
virtual ~ViewImplementation();
struct DOMNodeProperties {
String computed_style_json;
String resolved_style_json;
String custom_properties_json;
String node_box_sizing_json;
String aria_properties_state_json;
String fonts_json;
JsonObject computed_style;
JsonObject resolved_style;
JsonObject custom_properties;
JsonObject node_box_sizing;
JsonObject aria_properties_state;
JsonArray fonts;
};
static void for_each_view(Function<IterationDecision(ViewImplementation&)>);
@ -200,9 +202,9 @@ public:
Function<void()> on_request_accept_dialog;
Function<void()> on_request_dismiss_dialog;
Function<void(URL::URL const&, URL::URL const&, String const&)> on_received_source;
Function<void(String const&)> on_received_dom_tree;
Function<void(Optional<DOMNodeProperties>)> on_received_dom_node_properties;
Function<void(String const&)> on_received_accessibility_tree;
Function<void(JsonObject)> on_received_dom_tree;
Function<void(DOMNodeProperties)> on_received_dom_node_properties;
Function<void(JsonObject)> on_received_accessibility_tree;
Function<void(Vector<Web::CSS::StyleSheetIdentifier>)> on_received_style_sheet_list;
Function<void(Web::CSS::StyleSheetIdentifier const&)> on_inspector_requested_style_sheet_source;
Function<void(Web::CSS::StyleSheetIdentifier const&, URL::URL const&, String const&)> on_received_style_sheet_source;