浏览代码

LibWeb: Convert internal test event coordinates to device pixels

This allows for coming up with coordinates that work on macOS with a DPR
of 2 more easily.
Timothy Flynn 10 月之前
父节点
当前提交
59fe7ca830
共有 1 个文件被更改,包括 19 次插入7 次删除
  1. 19 7
      Userland/Libraries/LibWeb/Internals/Internals.cpp

+ 19 - 7
Userland/Libraries/LibWeb/Internals/Internals.cpp

@@ -98,20 +98,26 @@ void Internals::middle_click(double x, double y)
 void Internals::click(double x, double y, UIEvents::MouseButton button)
 void Internals::click(double x, double y, UIEvents::MouseButton button)
 {
 {
     auto& page = global_object().browsing_context()->page();
     auto& page = global_object().browsing_context()->page();
-    page.handle_mousedown({ x, y }, { x, y }, button, 0, 0);
-    page.handle_mouseup({ x, y }, { x, y }, button, 0, 0);
+
+    auto position = page.css_to_device_point({ x, y });
+    page.handle_mousedown(position, position, button, 0, 0);
+    page.handle_mouseup(position, position, button, 0, 0);
 }
 }
 
 
 void Internals::move_pointer_to(double x, double y)
 void Internals::move_pointer_to(double x, double y)
 {
 {
     auto& page = global_object().browsing_context()->page();
     auto& page = global_object().browsing_context()->page();
-    page.handle_mousemove({ x, y }, { x, y }, 0, 0);
+
+    auto position = page.css_to_device_point({ x, y });
+    page.handle_mousemove(position, position, 0, 0);
 }
 }
 
 
 void Internals::wheel(double x, double y, double delta_x, double delta_y)
 void Internals::wheel(double x, double y, double delta_x, double delta_y)
 {
 {
     auto& page = global_object().browsing_context()->page();
     auto& page = global_object().browsing_context()->page();
-    page.handle_mousewheel({ x, y }, { x, y }, 0, 0, 0, delta_x, delta_y);
+
+    auto position = page.css_to_device_point({ x, y });
+    page.handle_mousewheel(position, position, 0, 0, 0, delta_x, delta_y);
 }
 }
 
 
 WebIDL::ExceptionOr<bool> Internals::dispatch_user_activated_event(DOM::EventTarget& target, DOM::Event& event)
 WebIDL::ExceptionOr<bool> Internals::dispatch_user_activated_event(DOM::EventTarget& target, DOM::Event& event)
@@ -132,19 +138,25 @@ void Internals::simulate_drag_start(double x, double y, String const& name, Stri
     files.empend(name.to_byte_string(), MUST(ByteBuffer::copy(contents.bytes())));
     files.empend(name.to_byte_string(), MUST(ByteBuffer::copy(contents.bytes())));
 
 
     auto& page = global_object().browsing_context()->page();
     auto& page = global_object().browsing_context()->page();
-    page.handle_drag_and_drop_event(DragEvent::Type::DragStart, { x, y }, { x, y }, UIEvents::MouseButton::Primary, 0, 0, move(files));
+
+    auto position = page.css_to_device_point({ x, y });
+    page.handle_drag_and_drop_event(DragEvent::Type::DragStart, position, position, UIEvents::MouseButton::Primary, 0, 0, move(files));
 }
 }
 
 
 void Internals::simulate_drag_move(double x, double y)
 void Internals::simulate_drag_move(double x, double y)
 {
 {
     auto& page = global_object().browsing_context()->page();
     auto& page = global_object().browsing_context()->page();
-    page.handle_drag_and_drop_event(DragEvent::Type::DragMove, { x, y }, { x, y }, UIEvents::MouseButton::Primary, 0, 0, {});
+
+    auto position = page.css_to_device_point({ x, y });
+    page.handle_drag_and_drop_event(DragEvent::Type::DragMove, position, position, UIEvents::MouseButton::Primary, 0, 0, {});
 }
 }
 
 
 void Internals::simulate_drop(double x, double y)
 void Internals::simulate_drop(double x, double y)
 {
 {
     auto& page = global_object().browsing_context()->page();
     auto& page = global_object().browsing_context()->page();
-    page.handle_drag_and_drop_event(DragEvent::Type::Drop, { x, y }, { x, y }, UIEvents::MouseButton::Primary, 0, 0, {});
+
+    auto position = page.css_to_device_point({ x, y });
+    page.handle_drag_and_drop_event(DragEvent::Type::Drop, position, position, UIEvents::MouseButton::Primary, 0, 0, {});
 }
 }
 
 
 }
 }