diff options
author | Itamar <itamar8910@gmail.com> | 2022-12-31 16:19:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-31 16:17:48 +0100 |
commit | f6862a42030bda45457415aea6900c6f5b79eb14 (patch) | |
tree | 2e7aa143ca417fb24956f707418fd9d9c21591b6 /Userland/Libraries | |
parent | 66ee08c3dc97dda9822f90565ff1c58524956736 (diff) | |
download | serenity-f6862a42030bda45457415aea6900c6f5b79eb14.zip |
LibWeb: Use CSSPixelPoint in MouseEvent::create_from_platform_event()
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Page/EventHandler.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.h | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index ef188bb7d3..483438ee06 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -248,12 +248,12 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig auto offset = compute_mouse_event_offset(position, *layout_node); auto client_offset = compute_mouse_event_client_offset(position); - node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mouseup, offset.x(), offset.y(), client_offset.x(), client_offset.y(), buttons, button)); + node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mouseup, offset, client_offset, buttons, button)); handled_event = true; bool run_activation_behavior = true; if (node.ptr() == m_mousedown_target && button == GUI::MouseButton::Primary) { - run_activation_behavior = node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, offset.x(), offset.y(), client_offset.x(), client_offset.y(), button)); + run_activation_behavior = node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, offset, client_offset, button)); } if (run_activation_behavior) { @@ -370,7 +370,7 @@ bool EventHandler::handle_mousedown(CSSPixelPoint position, unsigned button, uns m_mousedown_target = node.ptr(); auto offset = compute_mouse_event_offset(position, *layout_node); auto client_offset = compute_mouse_event_client_offset(position); - node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousedown, offset.x(), offset.y(), client_offset.x(), client_offset.y(), buttons, button)); + node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousedown, offset, client_offset, buttons, button)); } // NOTE: Dispatching an event may have disturbed the world. @@ -483,7 +483,7 @@ bool EventHandler::handle_mousemove(CSSPixelPoint position, unsigned buttons, un auto offset = compute_mouse_event_offset(position, *layout_node); auto client_offset = compute_mouse_event_client_offset(position); - node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousemove, offset.x(), offset.y(), client_offset.x(), client_offset.y(), buttons)); + node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousemove, offset, client_offset, buttons)); // NOTE: Dispatching an event may have disturbed the world. if (!paint_root() || paint_root() != node->document().paint_box()) return true; @@ -565,7 +565,7 @@ bool EventHandler::handle_doubleclick(CSSPixelPoint position, unsigned button, u auto offset = compute_mouse_event_offset(position, *layout_node); auto client_offset = compute_mouse_event_client_offset(position); - node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::dblclick, offset.x(), offset.y(), client_offset.x(), client_offset.y(), buttons, button)); + node->dispatch_event(*UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::dblclick, offset, client_offset, buttons, button)); // NOTE: Dispatching an event may have disturbed the world. if (!paint_root() || paint_root() != node->document().paint_box()) diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 8dee161cf6..d7124ddb0a 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -52,13 +52,13 @@ MouseEvent* MouseEvent::create(JS::Realm& realm, FlyString const& event_name, Mo return realm.heap().allocate<MouseEvent>(realm, realm, event_name, event_init); } -MouseEvent* MouseEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, unsigned buttons, unsigned mouse_button) +MouseEvent* MouseEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, unsigned buttons, unsigned mouse_button) { MouseEventInit event_init {}; - event_init.offset_x = static_cast<double>(offset_x.value()); - event_init.offset_y = static_cast<double>(offset_y.value()); - event_init.client_x = static_cast<double>(client_x.value()); - event_init.client_y = static_cast<double>(client_y.value()); + event_init.offset_x = static_cast<double>(offset.x().value()); + event_init.offset_y = static_cast<double>(offset.y().value()); + event_init.client_x = static_cast<double>(client_offset.x().value()); + event_init.client_y = static_cast<double>(client_offset.y().value()); event_init.button = determine_button(mouse_button); event_init.buttons = buttons; return MouseEvent::create(realm, event_name, event_init); diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 3511fc6766..51eeab7e5e 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -28,7 +28,7 @@ class MouseEvent : public UIEvent { public: static MouseEvent* create(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init = {}); - static MouseEvent* create_from_platform_event(JS::Realm&, FlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, unsigned buttons, unsigned mouse_button = 1); + static MouseEvent* create_from_platform_event(JS::Realm&, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, unsigned buttons, unsigned mouse_button = 1); virtual ~MouseEvent() override; |