diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-04-06 16:12:33 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-04-07 22:41:01 +0200 |
commit | ad5cbdc51bd1673bedf544b4e6332896a7706171 (patch) | |
tree | cb3e0d647508e4607a858b2426ca97e2a8a2b02f /Userland/Libraries/LibWeb/UIEvents | |
parent | e0002aa9939c71deb32dc0065cba9e129e389ad5 (diff) | |
download | serenity-ad5cbdc51bd1673bedf544b4e6332896a7706171.zip |
LibWeb: Port {Mouse,UI,Wheel,}Event to new String
This ports MouseEvent, UIEvent, WheelEvent, and Event to new String.
They all had a dependency to T::create() in
WebDriverConnection::fire_an_event() and therefore had to be ported in
the same commit.
Diffstat (limited to 'Userland/Libraries/LibWeb/UIEvents')
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/UIEvent.h | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/UIEvent.idl | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/WheelEvent.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/WheelEvent.idl | 2 |
11 files changed, 27 insertions, 28 deletions
diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp index 7e72932a60..635a4779e6 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp @@ -15,7 +15,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<FocusEvent>> FocusEvent::construct_impl(JS: } FocusEvent::FocusEvent(JS::Realm& realm, FlyString const& event_name, FocusEventInit const& event_init) - : UIEvent(realm, event_name.to_deprecated_fly_string()) + : UIEvent(realm, event_name) { set_related_target(const_cast<DOM::EventTarget*>(event_init.related_target.ptr())); } diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp index c87e2a68ad..aed2fe34bb 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp @@ -117,7 +117,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> KeyboardEvent::construct_im } KeyboardEvent::KeyboardEvent(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init) - : UIEvent(realm, event_name.to_deprecated_fly_string(), event_init) + : UIEvent(realm, event_name, event_init) , m_key(event_init.key) , m_code(event_init.code) , m_location(event_init.location) diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 3220b0c6b2..0a10f90fd3 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -13,7 +13,7 @@ namespace Web::UIEvents { -MouseEvent::MouseEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MouseEventInit const& event_init) +MouseEvent::MouseEvent(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init) : UIEvent(realm, event_name, event_init) , m_offset_x(event_init.offset_x) , m_offset_y(event_init.offset_y) @@ -56,12 +56,12 @@ static i16 determine_button(unsigned mouse_button) } } -WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, MouseEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init) { return MUST_OR_THROW_OOM(realm.heap().allocate<MouseEvent>(realm, realm, event_name, event_init)); } -WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create_from_platform_event(JS::Realm& realm, DeprecatedFlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button) { MouseEventInit event_init {}; event_init.offset_x = static_cast<double>(offset.x().value()); @@ -77,8 +77,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create_from_platfo void MouseEvent::set_event_characteristics() { - auto type = String::from_deprecated_string(this->type()).release_value(); - if (type.is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click)) { + if (type().is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click)) { set_bubbles(true); set_cancelable(true); set_composed(true); diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 6f4f9d6cc9..35a85bf233 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -29,8 +29,8 @@ class MouseEvent : public UIEvent { WEB_PLATFORM_OBJECT(MouseEvent, UIEvent); public: - static WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, MouseEventInit const& event_init = {}); - static WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> create_from_platform_event(JS::Realm&, DeprecatedFlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button = 1); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> create(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init = {}); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> create_from_platform_event(JS::Realm&, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button = 1); virtual ~MouseEvent() override; @@ -56,7 +56,7 @@ public: virtual u32 which() const override { return m_button + 1; } protected: - MouseEvent(JS::Realm&, DeprecatedFlyString const& event_name, MouseEventInit const& event_init); + MouseEvent(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init); virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl index 449253ab6c..4a96e9cbf3 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl @@ -1,5 +1,5 @@ // https://w3c.github.io/uievents/#mouseevent -[Exposed=Window] +[Exposed=Window, UseNewAKString] interface MouseEvent : UIEvent { readonly attribute double offsetX; diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp index ae896da473..40f8f0bfd3 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp @@ -9,22 +9,22 @@ namespace Web::UIEvents { -WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name) +WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::create(JS::Realm& realm, FlyString const& event_name) { return MUST_OR_THROW_OOM(realm.heap().allocate<UIEvent>(realm, realm, event_name)); } -WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init) { return MUST_OR_THROW_OOM(realm.heap().allocate<UIEvent>(realm, realm, event_name, event_init)); } -UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name) +UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name) : Event(realm, event_name) { } -UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEventInit const& event_init) +UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init) : Event(realm, event_name, event_init) , m_view(event_init.view) , m_detail(event_init.detail) diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h index 57be8375c3..19bf8c0fcf 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h @@ -21,8 +21,8 @@ class UIEvent : public DOM::Event { WEB_PLATFORM_OBJECT(UIEvent, DOM::Event); public: - static WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> create(JS::Realm&, DeprecatedFlyString const& type); - static WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> create(JS::Realm&, FlyString const& type); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> construct_impl(JS::Realm&, FlyString const& event_name, UIEventInit const& event_init); virtual ~UIEvent() override; @@ -30,7 +30,7 @@ public: int detail() const { return m_detail; } virtual u32 which() const { return 0; } - void init_ui_event(DeprecatedString const& type, bool bubbles, bool cancelable, HTML::Window* view, int detail) + void init_ui_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, int detail) { init_event(type, bubbles, cancelable); m_view = view; @@ -38,8 +38,8 @@ public: } protected: - UIEvent(JS::Realm&, DeprecatedFlyString const& event_name); - UIEvent(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init); + UIEvent(JS::Realm&, FlyString const& event_name); + UIEvent(JS::Realm&, FlyString const& event_name, UIEventInit const& event_init); virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl b/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl index d79f774fa8..e3eb996fea 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl @@ -1,7 +1,7 @@ #import <DOM/Event.idl> // https://w3c.github.io/uievents/#uievent -[Exposed=Window] +[Exposed=Window, UseNewAKString] interface UIEvent : Event { constructor(DOMString type, optional UIEventInit eventInitDict = {}); readonly attribute Window? view; diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp index 3965831a61..48d5ab593c 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp @@ -12,7 +12,7 @@ namespace Web::UIEvents { -WheelEvent::WheelEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init) +WheelEvent::WheelEvent(JS::Realm& realm, FlyString const& event_name, WheelEventInit const& event_init) : MouseEvent(realm, event_name, event_init) , m_delta_x(event_init.delta_x) , m_delta_y(event_init.delta_y) @@ -31,12 +31,12 @@ JS::ThrowCompletionOr<void> WheelEvent::initialize(JS::Realm& realm) return {}; } -WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init) +WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create(JS::Realm& realm, FlyString const& event_name, WheelEventInit const& event_init) { return MUST_OR_THROW_OOM(realm.heap().allocate<WheelEvent>(realm, realm, event_name, event_init)); } -WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create_from_platform_event(JS::Realm& realm, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button) +WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button) { WheelEventInit event_init {}; event_init.offset_x = static_cast<double>(offset_x.value()); diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h index 9a645a55a1..855eb1fe52 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h @@ -29,8 +29,8 @@ class WheelEvent final : public MouseEvent { WEB_PLATFORM_OBJECT(WheelEvent, MouseEvent); public: - static WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init = {}); - static WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> create_from_platform_event(JS::Realm&, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> create(JS::Realm&, FlyString const& event_name, WheelEventInit const& event_init = {}); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> create_from_platform_event(JS::Realm&, FlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button); virtual ~WheelEvent() override; @@ -40,7 +40,7 @@ public: unsigned long delta_mode() const { return to_underlying(m_delta_mode); } private: - WheelEvent(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init); + WheelEvent(JS::Realm&, FlyString const& event_name, WheelEventInit const& event_init); virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.idl b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.idl index 51a633737b..969126869f 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.idl +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.idl @@ -1,7 +1,7 @@ #import <UIEvents/MouseEvent.idl> // https://www.w3.org/TR/uievents/#idl-wheelevent -[Exposed=Window] +[Exposed=Window, UseNewAKString] interface WheelEvent : MouseEvent { // DeltaModeCode const unsigned long DOM_DELTA_PIXEL = 0x00; |