From dd2d029952f3d1adb91fa9bcd5762803851f7213 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sun, 5 Mar 2023 10:56:50 +0100 Subject: [PATCH] LibWeb: Port PromiseRejectionEvent to new String --- Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp | 2 +- Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp | 8 ++++---- Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h | 7 ++++--- Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.idl | 2 +- Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index 8f4b5b236c..6d32dc4bf7 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -138,7 +138,7 @@ JS::VM& main_thread_vm() /* .promise = */ promise, /* .reason = */ promise.result(), }; - auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), HTML::EventNames::rejectionhandled, event_init).release_value_but_fixme_should_propagate_errors(); + auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), String::from_deprecated_string(HTML::EventNames::rejectionhandled).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors(); window.dispatch_event(promise_rejection_event); }); break; diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp index 7ce8f15545..bd7c33039c 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp @@ -9,18 +9,18 @@ namespace Web::HTML { -WebIDL::ExceptionOr> PromiseRejectionEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init) +WebIDL::ExceptionOr> PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) { return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); } -WebIDL::ExceptionOr> PromiseRejectionEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init) +WebIDL::ExceptionOr> PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) { return create(realm, event_name, event_init); } -PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init) - : DOM::Event(realm, event_name, event_init) +PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) + : DOM::Event(realm, event_name.to_deprecated_fly_string(), event_init) , m_promise(const_cast(event_init.promise.cell())) , m_reason(event_init.reason) { diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h index ec295b879c..7f84347d76 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -23,8 +24,8 @@ class PromiseRejectionEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init = {}); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init); + static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init = {}); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init); virtual ~PromiseRejectionEvent() override; @@ -33,7 +34,7 @@ public: JS::Value reason() const { return m_reason; } private: - PromiseRejectionEvent(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init); + PromiseRejectionEvent(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.idl b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.idl index 44438306a4..4785ca22b1 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.idl +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.idl @@ -1,6 +1,6 @@ #import -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker), UseNewAKString] interface PromiseRejectionEvent : Event { constructor(DOMString type, PromiseRejectionEventInit eventInitDict); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp index 17c2b89079..1b4becd78b 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -251,7 +251,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge) // FIXME: This currently assumes that global is a WindowObject. auto& window = verify_cast(global); - auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init).release_value_but_fixme_should_propagate_errors(); + auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), String::from_deprecated_string(HTML::EventNames::unhandledrejection).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors(); bool not_handled = window.dispatch_event(*promise_rejection_event);