mirror of
https://github.com/RGBCube/serenity
synced 2025-07-29 03:17:36 +00:00
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.
This commit is contained in:
parent
e0002aa993
commit
ad5cbdc51b
48 changed files with 160 additions and 160 deletions
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// https://w3c.github.io/uievents/#mouseevent
|
||||
[Exposed=Window]
|
||||
[Exposed=Window, UseNewAKString]
|
||||
interface MouseEvent : UIEvent {
|
||||
|
||||
readonly attribute double offsetX;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue