mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
LibWebView+WebContent: Transfer inspected DOM info over IPC as String
Let's avoid a whole bunch of String to ByteString to String conversions.
This commit is contained in:
parent
1e841cd453
commit
5478f34992
Notes:
github-actions[bot]
2025-02-24 17:07:24 +00:00
Author: https://github.com/trflynn89
Commit: 5478f34992
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3666
Reviewed-by: https://github.com/AtkinsSJ
6 changed files with 44 additions and 44 deletions
|
@ -371,7 +371,7 @@ void Application::inspect_tab(DevTools::TabDescription const& description, DevTo
|
|||
return;
|
||||
}
|
||||
|
||||
view->on_received_dom_tree = [&view = *view, on_complete = move(on_complete)](ByteString const& dom_tree) {
|
||||
view->on_received_dom_tree = [&view = *view, on_complete = move(on_complete)](String const& dom_tree) {
|
||||
view.on_received_dom_tree = nullptr;
|
||||
|
||||
if (auto parsed_tree = JsonValue::from_string(dom_tree); parsed_tree.is_error()) {
|
||||
|
|
|
@ -200,9 +200,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(ByteString const&)> on_received_dom_tree;
|
||||
Function<void(String const&)> on_received_dom_tree;
|
||||
Function<void(Optional<DOMNodeProperties>)> on_received_dom_node_properties;
|
||||
Function<void(ByteString const&)> on_received_accessibility_tree;
|
||||
Function<void(String const&)> 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;
|
||||
|
|
|
@ -264,7 +264,7 @@ void WebContentClient::did_get_source(u64 page_id, URL::URL const& url, URL::URL
|
|||
}
|
||||
}
|
||||
|
||||
void WebContentClient::did_inspect_dom_tree(u64 page_id, ByteString const& dom_tree)
|
||||
void WebContentClient::did_inspect_dom_tree(u64 page_id, String const& dom_tree)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
if (view->on_received_dom_tree)
|
||||
|
@ -272,7 +272,7 @@ void WebContentClient::did_inspect_dom_tree(u64 page_id, ByteString const& dom_t
|
|||
}
|
||||
}
|
||||
|
||||
void WebContentClient::did_inspect_dom_node(u64 page_id, bool has_style, ByteString const& computed_style, ByteString const& resolved_style, ByteString const& custom_properties, ByteString const& node_box_sizing, ByteString const& aria_properties_state, ByteString const& fonts)
|
||||
void WebContentClient::did_inspect_dom_node(u64 page_id, bool has_style, String const& computed_style, String const& resolved_style, String const& custom_properties, String const& node_box_sizing, String const& aria_properties_state, String const& fonts)
|
||||
{
|
||||
auto view = view_for_page_id(page_id);
|
||||
if (!view.has_value() || !view->on_received_dom_node_properties)
|
||||
|
@ -282,19 +282,19 @@ void WebContentClient::did_inspect_dom_node(u64 page_id, bool has_style, ByteStr
|
|||
|
||||
if (has_style) {
|
||||
properties = ViewImplementation::DOMNodeProperties {
|
||||
.computed_style_json = MUST(String::from_byte_string(computed_style)),
|
||||
.resolved_style_json = MUST(String::from_byte_string(resolved_style)),
|
||||
.custom_properties_json = MUST(String::from_byte_string(custom_properties)),
|
||||
.node_box_sizing_json = MUST(String::from_byte_string(node_box_sizing)),
|
||||
.aria_properties_state_json = MUST(String::from_byte_string(aria_properties_state)),
|
||||
.fonts_json = MUST(String::from_byte_string(fonts))
|
||||
.computed_style_json = computed_style,
|
||||
.resolved_style_json = resolved_style,
|
||||
.custom_properties_json = custom_properties,
|
||||
.node_box_sizing_json = node_box_sizing,
|
||||
.aria_properties_state_json = aria_properties_state,
|
||||
.fonts_json = fonts,
|
||||
};
|
||||
}
|
||||
|
||||
view->on_received_dom_node_properties(move(properties));
|
||||
}
|
||||
|
||||
void WebContentClient::did_inspect_accessibility_tree(u64 page_id, ByteString const& accessibility_tree)
|
||||
void WebContentClient::did_inspect_accessibility_tree(u64 page_id, String const& accessibility_tree)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
if (view->on_received_accessibility_tree)
|
||||
|
|
|
@ -71,9 +71,9 @@ private:
|
|||
virtual void did_request_image_context_menu(u64 page_id, Gfx::IntPoint, URL::URL const&, ByteString const&, unsigned, Optional<Gfx::ShareableBitmap> const&) override;
|
||||
virtual void did_request_media_context_menu(u64 page_id, Gfx::IntPoint, ByteString const&, unsigned, Web::Page::MediaContextMenu const&) override;
|
||||
virtual void did_get_source(u64 page_id, URL::URL const&, URL::URL const&, String const&) override;
|
||||
virtual void did_inspect_dom_tree(u64 page_id, ByteString const&) override;
|
||||
virtual void did_inspect_dom_node(u64 page_id, bool has_style, ByteString const& computed_style, ByteString const& resolved_style, ByteString const& custom_properties, ByteString const& node_box_sizing, ByteString const& aria_properties_state, ByteString const& fonts) override;
|
||||
virtual void did_inspect_accessibility_tree(u64 page_id, ByteString const&) override;
|
||||
virtual void did_inspect_dom_tree(u64 page_id, String const&) override;
|
||||
virtual void did_inspect_dom_node(u64 page_id, bool has_style, String const& computed_style, String const& resolved_style, String const& custom_properties, String const& node_box_sizing, String const& aria_properties_state, String const& fonts) override;
|
||||
virtual void did_inspect_accessibility_tree(u64 page_id, String const&) override;
|
||||
virtual void did_get_hovered_node_id(u64 page_id, Web::UniqueNodeID const& node_id) override;
|
||||
virtual void did_finish_editing_dom_node(u64 page_id, Optional<Web::UniqueNodeID> const& node_id) override;
|
||||
virtual void did_get_dom_node_html(u64 page_id, String const& html) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue