mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWebView+WebContent: Port JS console handling to String
This commit is contained in:
parent
bbcd8bd97c
commit
a8d3252f93
Notes:
github-actions[bot]
2025-02-28 12:09:54 +00:00
Author: https://github.com/trflynn89
Commit: a8d3252f93
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3686
14 changed files with 58 additions and 56 deletions
|
@ -71,7 +71,7 @@ InspectorClient::InspectorClient(ViewImplementation& content_web_view, ViewImple
|
|||
builder.append_escaped_for_json(properties.fonts.serialized());
|
||||
builder.append("\");"sv);
|
||||
|
||||
m_inspector_web_view.run_javascript(builder.string_view());
|
||||
m_inspector_web_view.run_javascript(MUST(builder.to_string()));
|
||||
};
|
||||
|
||||
m_content_web_view.on_received_accessibility_tree = [this](auto const& accessibility_tree) {
|
||||
|
@ -94,7 +94,7 @@ InspectorClient::InspectorClient(ViewImplementation& content_web_view, ViewImple
|
|||
}
|
||||
builder.append("]);"sv);
|
||||
|
||||
m_inspector_web_view.run_javascript(builder.string_view());
|
||||
m_inspector_web_view.run_javascript(MUST(builder.to_string()));
|
||||
};
|
||||
|
||||
m_content_web_view.on_received_style_sheet_source = [this](Web::CSS::StyleSheetIdentifier const& identifier, auto const& base_url, String const& source) {
|
||||
|
@ -199,7 +199,7 @@ InspectorClient::InspectorClient(ViewImplementation& content_web_view, ViewImple
|
|||
m_inspector_web_view.on_inspector_executed_console_script = [this](auto const& script) {
|
||||
append_console_source(script);
|
||||
|
||||
m_content_web_view.js_console_input(script.to_byte_string());
|
||||
m_content_web_view.js_console_input(script);
|
||||
};
|
||||
|
||||
m_inspector_web_view.on_inspector_exported_inspector_html = [this](String const& html) {
|
||||
|
@ -280,7 +280,7 @@ void InspectorClient::inspect()
|
|||
|
||||
void InspectorClient::reset()
|
||||
{
|
||||
static constexpr auto script = "inspector.reset();"sv;
|
||||
static auto script = "inspector.reset();"_string;
|
||||
m_inspector_web_view.run_javascript(script);
|
||||
|
||||
m_body_or_frameset_node_id.clear();
|
||||
|
@ -310,7 +310,7 @@ void InspectorClient::clear_selection()
|
|||
m_content_web_view.clear_highlighted_dom_node();
|
||||
m_content_web_view.clear_inspected_dom_node();
|
||||
|
||||
static constexpr auto script = "inspector.clearInspectedDOMNode();"sv;
|
||||
static auto script = "inspector.clearInspectedDOMNode();"_string;
|
||||
m_inspector_web_view.run_javascript(script);
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ void InspectorClient::load_cookies()
|
|||
json_cookies.serialize(builder);
|
||||
builder.append(");"sv);
|
||||
|
||||
m_inspector_web_view.run_javascript(builder.string_view());
|
||||
m_inspector_web_view.run_javascript(MUST(builder.to_string()));
|
||||
}
|
||||
|
||||
void InspectorClient::context_menu_edit_dom_node()
|
||||
|
@ -717,7 +717,7 @@ void InspectorClient::handle_console_message(i32 message_index)
|
|||
request_console_messages();
|
||||
}
|
||||
|
||||
void InspectorClient::handle_console_messages(i32 start_index, ReadonlySpan<ByteString> message_types, ReadonlySpan<ByteString> messages)
|
||||
void InspectorClient::handle_console_messages(i32 start_index, ReadonlySpan<String> message_types, ReadonlySpan<String> messages)
|
||||
{
|
||||
auto end_index = start_index + static_cast<i32>(message_types.size()) - 1;
|
||||
if (end_index <= m_highest_received_message_index) {
|
||||
|
@ -787,7 +787,7 @@ void InspectorClient::append_console_output(StringView html)
|
|||
|
||||
void InspectorClient::clear_console_output()
|
||||
{
|
||||
static constexpr auto script = "inspector.clearConsoleOutput();"sv;
|
||||
static auto script = "inspector.clearConsoleOutput();"_string;
|
||||
m_inspector_web_view.run_javascript(script);
|
||||
}
|
||||
|
||||
|
@ -801,7 +801,7 @@ void InspectorClient::begin_console_group(StringView label, bool start_expanded)
|
|||
|
||||
void InspectorClient::end_console_group()
|
||||
{
|
||||
static constexpr auto script = "inspector.endConsoleGroup();"sv;
|
||||
static auto script = "inspector.endConsoleGroup();"_string;
|
||||
m_inspector_web_view.run_javascript(script);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
|
||||
void request_console_messages();
|
||||
void handle_console_message(i32 message_index);
|
||||
void handle_console_messages(i32 start_index, ReadonlySpan<ByteString> message_types, ReadonlySpan<ByteString> messages);
|
||||
void handle_console_messages(i32 start_index, ReadonlySpan<String> message_types, ReadonlySpan<String> messages);
|
||||
|
||||
void append_console_source(StringView);
|
||||
void append_console_message(StringView);
|
||||
|
|
|
@ -393,14 +393,14 @@ void ViewImplementation::debug_request(ByteString const& request, ByteString con
|
|||
client().async_debug_request(page_id(), request, argument);
|
||||
}
|
||||
|
||||
void ViewImplementation::run_javascript(StringView js_source)
|
||||
void ViewImplementation::run_javascript(String js_source)
|
||||
{
|
||||
client().async_run_javascript(page_id(), js_source);
|
||||
client().async_run_javascript(page_id(), move(js_source));
|
||||
}
|
||||
|
||||
void ViewImplementation::js_console_input(ByteString const& js_source)
|
||||
void ViewImplementation::js_console_input(String js_source)
|
||||
{
|
||||
client().async_js_console_input(page_id(), js_source);
|
||||
client().async_js_console_input(page_id(), move(js_source));
|
||||
}
|
||||
|
||||
void ViewImplementation::js_console_request_messages(i32 start_index)
|
||||
|
|
|
@ -127,8 +127,8 @@ public:
|
|||
|
||||
void debug_request(ByteString const& request, ByteString const& argument = {});
|
||||
|
||||
void run_javascript(StringView);
|
||||
void js_console_input(ByteString const& js_source);
|
||||
void run_javascript(String);
|
||||
void js_console_input(String);
|
||||
void js_console_request_messages(i32 start_index);
|
||||
|
||||
void alert_closed();
|
||||
|
@ -216,7 +216,7 @@ public:
|
|||
Function<void(Optional<Web::UniqueNodeID> const& node_id)> on_finshed_editing_dom_node;
|
||||
Function<void(String const&)> on_received_dom_node_html;
|
||||
Function<void(i32 message_id)> on_received_console_message;
|
||||
Function<void(i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages)> on_received_console_messages;
|
||||
Function<void(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)> on_received_console_messages;
|
||||
Function<void(i32 count_waiting)> on_resource_status_change;
|
||||
Function<void()> on_restore_window;
|
||||
Function<void(Gfx::IntPoint)> on_reposition_window;
|
||||
|
|
|
@ -374,7 +374,7 @@ void WebContentClient::did_output_js_console_message(u64 page_id, i32 message_in
|
|||
}
|
||||
}
|
||||
|
||||
void WebContentClient::did_get_js_console_messages(u64 page_id, i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages)
|
||||
void WebContentClient::did_get_js_console_messages(u64 page_id, i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
||||
if (view->on_received_console_messages)
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
virtual void did_take_screenshot(u64 page_id, Gfx::ShareableBitmap const& screenshot) override;
|
||||
virtual void did_get_internal_page_info(u64 page_id, PageInfoType, String const&) override;
|
||||
virtual void did_output_js_console_message(u64 page_id, i32 message_index) override;
|
||||
virtual void did_get_js_console_messages(u64 page_id, i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages) override;
|
||||
virtual void did_get_js_console_messages(u64 page_id, i32 start_index, Vector<String> const& message_types, Vector<String> const& messages) override;
|
||||
virtual void did_change_favicon(u64 page_id, Gfx::ShareableBitmap const&) override;
|
||||
virtual void did_request_alert(u64 page_id, String const&) override;
|
||||
virtual void did_request_confirm(u64 page_id, String const&) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue