diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-03-05 10:33:56 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-05 18:25:59 +0000 |
commit | eed69e5093011aad0663a705c982302180dd0c64 (patch) | |
tree | 1a652165d5041487d86e070abfed624e9d9179a9 /Userland/Libraries/LibWeb | |
parent | 84997ab0eecc9ee9926b0b05007f525bfd9cba6f (diff) | |
download | serenity-eed69e5093011aad0663a705c982302180dd0c64.zip |
LibWeb: Port MessageEvent to new String
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessageEvent.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessageEvent.h | 19 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessageEvent.idl | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/MessagePort.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Window.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Worker.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp | 8 |
8 files changed, 26 insertions, 25 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 266681570d..8db5a31feb 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1298,7 +1298,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedSt } else if (Infra::is_ascii_case_insensitive_match(interface, "keyboardevent"sv)) { event = TRY(UIEvents::KeyboardEvent::create(realm, "")); } else if (Infra::is_ascii_case_insensitive_match(interface, "messageevent"sv)) { - event = TRY(HTML::MessageEvent::create(realm, "")); + event = TRY(HTML::MessageEvent::create(realm, String {})); } else if (Infra::is_ascii_case_insensitive_match(interface, "mouseevent"sv) || Infra::is_ascii_case_insensitive_match(interface, "mouseevents"sv)) { event = TRY(UIEvents::MouseEvent::create(realm, "")); diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp index 639cad228a..af331ebe3d 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -9,18 +9,18 @@ namespace Web::HTML { -WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::create(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) { return MUST_OR_THROW_OOM(realm.heap().allocate<MessageEvent>(realm, realm, event_name, event_init)); } -WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) { return create(realm, event_name, event_init); } -MessageEvent::MessageEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MessageEventInit const& event_init) - : DOM::Event(realm, event_name, event_init) +MessageEvent::MessageEvent(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) + : DOM::Event(realm, event_name.to_deprecated_fly_string(), event_init) , m_data(event_init.data) , m_origin(event_init.origin) , m_last_event_id(event_init.last_event_id) diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.h b/Userland/Libraries/LibWeb/HTML/MessageEvent.h index 838f25bbb6..fe824ae5b6 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.h +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.h @@ -7,37 +7,38 @@ #pragma once +#include <AK/FlyString.h> #include <LibWeb/DOM/Event.h> namespace Web::HTML { struct MessageEventInit : public DOM::EventInit { JS::Value data { JS::js_null() }; - DeprecatedString origin { "" }; - DeprecatedString last_event_id { "" }; + String origin; + String last_event_id; }; class MessageEvent : public DOM::Event { WEB_PLATFORM_OBJECT(MessageEvent, DOM::Event); public: - static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init = {}); - static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> create(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init = {}); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> construct_impl(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init); - MessageEvent(JS::Realm&, DeprecatedFlyString const& event_name, MessageEventInit const& event_init); + MessageEvent(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init); virtual ~MessageEvent() override; JS::Value data() const { return m_data; } - DeprecatedString const& origin() const { return m_origin; } - DeprecatedString const& last_event_id() const { return m_last_event_id; } + String const& origin() const { return m_origin; } + String const& last_event_id() const { return m_last_event_id; } private: virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::Value m_data; - DeprecatedString m_origin; - DeprecatedString m_last_event_id; + String m_origin; + String m_last_event_id; }; } diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.idl b/Userland/Libraries/LibWeb/HTML/MessageEvent.idl index f394f7b6d2..443635b5da 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.idl +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.idl @@ -1,7 +1,7 @@ #import <DOM/Event.idl> // https://html.spec.whatwg.org/multipage/comms.html#messageevent -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker), UseNewAKString] interface MessageEvent : Event { constructor(DOMString type, optional MessageEventInit eventInitDict = {}); diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index df8a526599..a32f9e3b11 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -98,8 +98,8 @@ void MessagePort::post_message(JS::Value message) main_thread_event_loop().task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [target_port, message] { MessageEventInit event_init {}; event_init.data = message; - event_init.origin = "<origin>"; - target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + event_init.origin = "<origin>"_string.release_value_but_fixme_should_propagate_errors(); + target_port->dispatch_event(MessageEvent::create(target_port->realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors()); })); } diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index b3c56fc364..c073cdf0c9 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -916,8 +916,8 @@ WebIDL::ExceptionOr<void> Window::post_message_impl(JS::Value message, Deprecate HTML::queue_global_task(HTML::Task::Source::PostedMessage, *this, [this, message] { HTML::MessageEventInit event_init {}; event_init.data = message; - event_init.origin = "<origin>"; - dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + event_init.origin = "<origin>"_string.release_value_but_fixme_should_propagate_errors(); + dispatch_event(HTML::MessageEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors()); }); return {}; } diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index e7ccf27900..27bf5fee1b 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -165,8 +165,8 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti event_loop.task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [this, message] { MessageEventInit event_init {}; event_init.data = message; - event_init.origin = "<origin>"; - dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + event_init.origin = "<origin>"_string.release_value_but_fixme_should_propagate_errors(); + dispatch_event(MessageEvent::create(*m_worker_realm, String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors()); })); return JS::js_undefined(); diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 07b7d6c78e..275116fae6 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -234,8 +234,8 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) auto text_message = DeprecatedString(ReadonlyBytes(message)); HTML::MessageEventInit event_init; event_init.data = JS::PrimitiveString::create(vm(), text_message); - event_init.origin = url(); - dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + event_init.origin = String::from_deprecated_string(url()).release_value_but_fixme_should_propagate_errors(); + dispatch_event(HTML::MessageEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors()); return; } @@ -246,8 +246,8 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) // type indicates that the data is Binary and binaryType is "arraybuffer" HTML::MessageEventInit event_init; event_init.data = JS::ArrayBuffer::create(realm(), message); - event_init.origin = url(); - dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + event_init.origin = String::from_deprecated_string(url()).release_value_but_fixme_should_propagate_errors(); + dispatch_event(HTML::MessageEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors()); return; } |