diff --git a/Libraries/LibWebView/InspectorClient.cpp b/Libraries/LibWebView/InspectorClient.cpp index 75f8baf94e9..5379fb8918d 100644 --- a/Libraries/LibWebView/InspectorClient.cpp +++ b/Libraries/LibWebView/InspectorClient.cpp @@ -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 message_types, ReadonlySpan messages) +void InspectorClient::handle_console_messages(i32 start_index, ReadonlySpan message_types, ReadonlySpan messages) { auto end_index = start_index + static_cast(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); } diff --git a/Libraries/LibWebView/InspectorClient.h b/Libraries/LibWebView/InspectorClient.h index 09514d83c4a..4e28548eda2 100644 --- a/Libraries/LibWebView/InspectorClient.h +++ b/Libraries/LibWebView/InspectorClient.h @@ -58,7 +58,7 @@ private: void request_console_messages(); void handle_console_message(i32 message_index); - void handle_console_messages(i32 start_index, ReadonlySpan message_types, ReadonlySpan messages); + void handle_console_messages(i32 start_index, ReadonlySpan message_types, ReadonlySpan messages); void append_console_source(StringView); void append_console_message(StringView); diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cpp index 122f6dcea71..1e35e675cef 100644 --- a/Libraries/LibWebView/ViewImplementation.cpp +++ b/Libraries/LibWebView/ViewImplementation.cpp @@ -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) diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h index f87f8b9476c..1f1ee94724a 100644 --- a/Libraries/LibWebView/ViewImplementation.h +++ b/Libraries/LibWebView/ViewImplementation.h @@ -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 const& node_id)> on_finshed_editing_dom_node; Function on_received_dom_node_html; Function on_received_console_message; - Function const& message_types, Vector const& messages)> on_received_console_messages; + Function const& message_types, Vector const& messages)> on_received_console_messages; Function on_resource_status_change; Function on_restore_window; Function on_reposition_window; diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cpp index efa09cd418d..4bef200e246 100644 --- a/Libraries/LibWebView/WebContentClient.cpp +++ b/Libraries/LibWebView/WebContentClient.cpp @@ -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 const& message_types, Vector const& messages) +void WebContentClient::did_get_js_console_messages(u64 page_id, i32 start_index, Vector const& message_types, Vector const& messages) { if (auto view = view_for_page_id(page_id); view.has_value()) { if (view->on_received_console_messages) diff --git a/Libraries/LibWebView/WebContentClient.h b/Libraries/LibWebView/WebContentClient.h index d7fb9d00e23..e8971d02ec3 100644 --- a/Libraries/LibWebView/WebContentClient.h +++ b/Libraries/LibWebView/WebContentClient.h @@ -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 const& message_types, Vector const& messages) override; + virtual void did_get_js_console_messages(u64 page_id, i32 start_index, Vector const& message_types, Vector 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; diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index d06a97fdb15..9c8db9a5b93 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -1150,7 +1150,7 @@ void ConnectionFromClient::set_system_visibility_state(u64 page_id, Web::HTML::V page->page().top_level_traversable()->set_system_visibility_state(visibility_state); } -void ConnectionFromClient::js_console_input(u64 page_id, ByteString const& js_source) +void ConnectionFromClient::js_console_input(u64 page_id, String const& js_source) { auto page = this->page(page_id); if (!page.has_value()) @@ -1159,7 +1159,7 @@ void ConnectionFromClient::js_console_input(u64 page_id, ByteString const& js_so page->js_console_input(js_source); } -void ConnectionFromClient::run_javascript(u64 page_id, ByteString const& js_source) +void ConnectionFromClient::run_javascript(u64 page_id, String const& js_source) { if (auto page = this->page(page_id); page.has_value()) page->run_javascript(js_source); diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.h index 61640740f1f..c7be6e9c733 100644 --- a/Services/WebContent/ConnectionFromClient.h +++ b/Services/WebContent/ConnectionFromClient.h @@ -111,8 +111,8 @@ private: virtual void handle_file_return(u64 page_id, i32 error, Optional const& file, i32 request_id) override; virtual void set_system_visibility_state(u64 page_id, Web::HTML::VisibilityState) override; - virtual void js_console_input(u64 page_id, ByteString const&) override; - virtual void run_javascript(u64 page_id, ByteString const&) override; + virtual void js_console_input(u64 page_id, String const&) override; + virtual void run_javascript(u64 page_id, String const&) override; virtual void js_console_request_messages(u64 page_id, i32) override; virtual void alert_closed(u64 page_id) override; diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cpp index fcc0f7c34fc..3d85231880b 100644 --- a/Services/WebContent/PageClient.cpp +++ b/Services/WebContent/PageClient.cpp @@ -738,13 +738,13 @@ void PageClient::initialize_js_console(Web::DOM::Document& document) document.set_console_client(console_client); } -void PageClient::js_console_input(ByteString const& js_source) +void PageClient::js_console_input(StringView js_source) { if (m_top_level_document_console_client) m_top_level_document_console_client->handle_input(js_source); } -void PageClient::run_javascript(ByteString const& js_source) +void PageClient::run_javascript(StringView js_source) { auto* active_document = page().top_level_browsing_context().active_document(); @@ -787,7 +787,7 @@ void PageClient::console_peer_did_misbehave(char const* reason) client().did_misbehave(reason); } -void PageClient::did_get_js_console_messages(i32 start_index, Vector message_types, Vector messages) +void PageClient::did_get_js_console_messages(i32 start_index, Vector message_types, Vector messages) { client().async_did_get_js_console_messages(m_id, start_index, move(message_types), move(messages)); } diff --git a/Services/WebContent/PageClient.h b/Services/WebContent/PageClient.h index b190dd3d625..09cd69e8b2e 100644 --- a/Services/WebContent/PageClient.h +++ b/Services/WebContent/PageClient.h @@ -82,12 +82,12 @@ public: void ready_to_paint(); void initialize_js_console(Web::DOM::Document& document); - void js_console_input(ByteString const& js_source); - void run_javascript(ByteString const& js_source); + void js_console_input(StringView js_source); + void run_javascript(StringView js_source); void js_console_request_messages(i32 start_index); void did_output_js_console_message(i32 message_index); void console_peer_did_misbehave(char const* reason); - void did_get_js_console_messages(i32 start_index, Vector message_types, Vector messages); + void did_get_js_console_messages(i32 start_index, Vector message_types, Vector messages); Vector list_style_sheets() const; diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc index 4e274efd20c..9edb48a7ec3 100644 --- a/Services/WebContent/WebContentClient.ipc +++ b/Services/WebContent/WebContentClient.ipc @@ -92,7 +92,7 @@ endpoint WebContentClient did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState play_state) =| did_output_js_console_message(u64 page_id, i32 message_index) =| - did_get_js_console_messages(u64 page_id, i32 start_index, Vector message_types, Vector messages) =| + did_get_js_console_messages(u64 page_id, i32 start_index, Vector message_types, Vector messages) =| did_finish_text_test(u64 page_id, String text) =| did_set_test_timeout(u64 page_id, double milliseconds) =| diff --git a/Services/WebContent/WebContentConsoleClient.cpp b/Services/WebContent/WebContentConsoleClient.cpp index 1376c3c4a0e..be032a2f904 100644 --- a/Services/WebContent/WebContentConsoleClient.cpp +++ b/Services/WebContent/WebContentConsoleClient.cpp @@ -43,7 +43,7 @@ void WebContentConsoleClient::visit_edges(JS::Cell::Visitor& visitor) visitor.visit(m_console_global_environment_extensions); } -void WebContentConsoleClient::handle_input(ByteString const& js_source) +void WebContentConsoleClient::handle_input(StringView js_source) { if (!m_console_global_environment_extensions) return; @@ -58,16 +58,16 @@ void WebContentConsoleClient::handle_input(ByteString const& js_source) if (result.value().has_value()) { m_console_global_environment_extensions->set_most_recent_result(result.value().value()); - print_html(JS::MarkupGenerator::html_from_value(*result.value()).release_value_but_fixme_should_propagate_errors().to_byte_string()); + print_html(JS::MarkupGenerator::html_from_value(*result.value()).release_value_but_fixme_should_propagate_errors()); } } void WebContentConsoleClient::report_exception(JS::Error const& exception, bool in_promise) { - print_html(JS::MarkupGenerator::html_from_error(exception, in_promise).release_value_but_fixme_should_propagate_errors().to_byte_string()); + print_html(JS::MarkupGenerator::html_from_error(exception, in_promise).release_value_but_fixme_should_propagate_errors()); } -void WebContentConsoleClient::print_html(ByteString const& line) +void WebContentConsoleClient::print_html(String const& line) { m_message_log.append({ .type = ConsoleOutput::Type::HTML, .data = line }); m_client->did_output_js_console_message(m_message_log.size() - 1); @@ -75,11 +75,11 @@ void WebContentConsoleClient::print_html(ByteString const& line) void WebContentConsoleClient::clear_output() { - m_message_log.append({ .type = ConsoleOutput::Type::Clear, .data = "" }); + m_message_log.append({ .type = ConsoleOutput::Type::Clear, .data = String {} }); m_client->did_output_js_console_message(m_message_log.size() - 1); } -void WebContentConsoleClient::begin_group(ByteString const& label, bool start_expanded) +void WebContentConsoleClient::begin_group(String const& label, bool start_expanded) { m_message_log.append({ .type = start_expanded ? ConsoleOutput::Type::BeginGroup : ConsoleOutput::Type::BeginGroupCollapsed, .data = label }); m_client->did_output_js_console_message(m_message_log.size() - 1); @@ -87,7 +87,7 @@ void WebContentConsoleClient::begin_group(ByteString const& label, bool start_ex void WebContentConsoleClient::end_group() { - m_message_log.append({ .type = ConsoleOutput::Type::EndGroup, .data = "" }); + m_message_log.append({ .type = ConsoleOutput::Type::EndGroup, .data = String {} }); m_client->did_output_js_console_message(m_message_log.size() - 1); } @@ -105,8 +105,8 @@ void WebContentConsoleClient::send_messages(i32 start_index) } // FIXME: Replace with a single Vector of message structs - Vector message_types; - Vector messages; + Vector message_types; + Vector messages; message_types.ensure_capacity(messages_to_send); messages.ensure_capacity(messages_to_send); @@ -114,26 +114,26 @@ void WebContentConsoleClient::send_messages(i32 start_index) auto& message = m_message_log[i]; switch (message.type) { case ConsoleOutput::Type::HTML: - message_types.append("html"sv); + message_types.append("html"_string); break; case ConsoleOutput::Type::Clear: - message_types.append("clear"sv); + message_types.append("clear"_string); break; case ConsoleOutput::Type::BeginGroup: - message_types.append("group"sv); + message_types.append("group"_string); break; case ConsoleOutput::Type::BeginGroupCollapsed: - message_types.append("groupCollapsed"sv); + message_types.append("groupCollapsed"_string); break; case ConsoleOutput::Type::EndGroup: - message_types.append("groupEnd"sv); + message_types.append("groupEnd"_string); break; } messages.append(message.data); } - m_client->did_get_js_console_messages(start_index, message_types, messages); + m_client->did_get_js_console_messages(start_index, move(message_types), move(messages)); } void WebContentConsoleClient::clear() @@ -215,7 +215,7 @@ JS::ThrowCompletionOr WebContentConsoleClient::printer(JS::Console::L html.appendff(""); html.appendff(""); html.appendff(""); - print_html(html.string_view()); + print_html(MUST(html.to_string())); auto output = TRY(generically_format_values(table_args)); m_console->output_debug_message(log_level, output); @@ -234,13 +234,13 @@ JS::ThrowCompletionOr WebContentConsoleClient::printer(JS::Console::L html.appendff("-> {}
", escape_html_entities(function_name)); html.append(""sv); - print_html(html.string_view()); + print_html(MUST(html.to_string())); return JS::js_undefined(); } if (log_level == JS::Console::LogLevel::Group || log_level == JS::Console::LogLevel::GroupCollapsed) { auto group = arguments.get(); - begin_group(ByteString::formatted("{}", styling, escape_html_entities(group.label)), log_level == JS::Console::LogLevel::Group); + begin_group(MUST(String::formatted("{}", styling, escape_html_entities(group.label))), log_level == JS::Console::LogLevel::Group); return JS::js_undefined(); } @@ -272,7 +272,7 @@ JS::ThrowCompletionOr WebContentConsoleClient::printer(JS::Console::L html.append(escape_html_entities(output)); html.append(""sv); - print_html(html.string_view()); + print_html(MUST(html.to_string())); return JS::js_undefined(); } diff --git a/Services/WebContent/WebContentConsoleClient.h b/Services/WebContent/WebContentConsoleClient.h index 6be8c60f50a..4635c99aa3d 100644 --- a/Services/WebContent/WebContentConsoleClient.h +++ b/Services/WebContent/WebContentConsoleClient.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include #include @@ -25,7 +26,7 @@ class WebContentConsoleClient final : public JS::ConsoleClient { public: virtual ~WebContentConsoleClient() override; - void handle_input(ByteString const& js_source); + void handle_input(StringView js_source); void send_messages(i32 start_index); void report_exception(JS::Error const&, bool) override; @@ -46,8 +47,8 @@ private: GC::Ptr m_console_global_environment_extensions; void clear_output(); - void print_html(ByteString const& line); - void begin_group(ByteString const& label, bool start_expanded); + void print_html(String const& line); + void begin_group(String const& label, bool start_expanded); virtual void end_group() override; struct ConsoleOutput { @@ -59,7 +60,7 @@ private: EndGroup, }; Type type; - ByteString data; + String data; }; Vector m_message_log; diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipc index 86ad895db53..845a1423e4d 100644 --- a/Services/WebContent/WebContentServer.ipc +++ b/Services/WebContent/WebContentServer.ipc @@ -48,8 +48,11 @@ endpoint WebContentServer highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) =| inspect_accessibility_tree(u64 page_id) =| get_hovered_node_id(u64 page_id) =| - js_console_input(u64 page_id, ByteString js_source) =| + + js_console_input(u64 page_id, String js_source) =| js_console_request_messages(u64 page_id, i32 start_index) =| + run_javascript(u64 page_id, String js_source) =| + list_style_sheets(u64 page_id) =| request_style_sheet_source(u64 page_id, Web::CSS::StyleSheetIdentifier identifier) =| @@ -68,8 +71,6 @@ endpoint WebContentServer request_internal_page_info(u64 page_id, WebView::PageInfoType type) =| - run_javascript(u64 page_id, ByteString js_source) =| - get_selected_text(u64 page_id) => (ByteString selection) select_all(u64 page_id) =| paste(u64 page_id, String text) =|