mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-15 22:12:20 +00:00
LibWeb: Remove set_event_characteristics()
These methods were overriding properties specified by the EventInit property bags in the constructor for WheelEvent and MouseEvent. They appear to be legacy code and no longer relevant, as they would have been used for ensuring natively dispatched events had the correct properties --- This is now done in separate create methods, such as MouseEvent::create_from_platform_event. This fixes a couple WPT failures (e.g. in /dom/events/Event-subclasses-constructors.html)
This commit is contained in:
parent
5dde9cf327
commit
2c396b5378
Notes:
sideshowbarker
2024-07-17 03:35:16 +09:00
Author: https://github.com/caitp
Commit: 2c396b5378
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/586
5 changed files with 6 additions and 22 deletions
|
@ -1354,6 +1354,9 @@ void Document::set_hovered_node(Node* node)
|
|||
// https://w3c.github.io/uievents/#mouseout
|
||||
if (old_hovered_node && old_hovered_node != m_hovered_node) {
|
||||
UIEvents::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.bubbles = true;
|
||||
mouse_event_init.cancelable = true;
|
||||
mouse_event_init.composed = true;
|
||||
mouse_event_init.related_target = m_hovered_node;
|
||||
auto event = UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseout, mouse_event_init);
|
||||
old_hovered_node->dispatch_event(event);
|
||||
|
@ -1373,6 +1376,9 @@ void Document::set_hovered_node(Node* node)
|
|||
// https://w3c.github.io/uievents/#mouseover
|
||||
if (m_hovered_node && m_hovered_node != old_hovered_node) {
|
||||
UIEvents::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.bubbles = true;
|
||||
mouse_event_init.cancelable = true;
|
||||
mouse_event_init.composed = true;
|
||||
mouse_event_init.related_target = old_hovered_node;
|
||||
auto event = UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseover, mouse_event_init);
|
||||
m_hovered_node->dispatch_event(event);
|
||||
|
|
|
@ -47,7 +47,6 @@ MouseEvent::MouseEvent(JS::Realm& realm, FlyString const& event_name, MouseEvent
|
|||
, m_buttons(event_init.buttons)
|
||||
, m_related_target(event_init.related_target)
|
||||
{
|
||||
set_event_characteristics();
|
||||
}
|
||||
|
||||
MouseEvent::~MouseEvent() = default;
|
||||
|
@ -148,13 +147,4 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create_from_platfo
|
|||
return event;
|
||||
}
|
||||
|
||||
void MouseEvent::set_event_characteristics()
|
||||
{
|
||||
if (type().is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click, EventNames::dblclick, EventNames::contextmenu)) {
|
||||
set_bubbles(true);
|
||||
set_cancelable(true);
|
||||
set_composed(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,8 +77,6 @@ protected:
|
|||
private:
|
||||
virtual bool is_mouse_event() const override { return true; }
|
||||
|
||||
void set_event_characteristics();
|
||||
|
||||
double m_screen_x { 0 };
|
||||
double m_screen_y { 0 };
|
||||
double m_page_x { 0 };
|
||||
|
|
|
@ -23,7 +23,6 @@ WheelEvent::WheelEvent(JS::Realm& realm, FlyString const& event_name, WheelEvent
|
|||
, m_delta_z(event_init.delta_z)
|
||||
, m_delta_mode(event_init.delta_mode)
|
||||
{
|
||||
set_event_characteristics();
|
||||
}
|
||||
|
||||
WheelEvent::~WheelEvent() = default;
|
||||
|
@ -65,11 +64,4 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create_from_platfo
|
|||
return event;
|
||||
}
|
||||
|
||||
void WheelEvent::set_event_characteristics()
|
||||
{
|
||||
set_bubbles(true);
|
||||
set_cancelable(true);
|
||||
set_composed(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
void set_event_characteristics();
|
||||
|
||||
double m_delta_x { 0 };
|
||||
double m_delta_y { 0 };
|
||||
double m_delta_z { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue