From 2554d766bc24d5ddf6357d76925f3a1d208de9fe Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Fri, 21 Jun 2024 22:35:12 +0100 Subject: [PATCH] LibWeb: Add `Internals.middleClick` This simulates click of the middle mouse button, which is necessary for testing whether the `auxevent` fires correctly. (cherry picked from commit 728fca1b1ffd8b472bc8524e5e8ec8443de011a5) --- Userland/Libraries/LibWeb/Internals/Internals.cpp | 14 ++++++++++++-- Userland/Libraries/LibWeb/Internals/Internals.h | 4 ++++ Userland/Libraries/LibWeb/Internals/Internals.idl | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Internals/Internals.cpp b/Userland/Libraries/LibWeb/Internals/Internals.cpp index 70f4f48219..dc421c7109 100644 --- a/Userland/Libraries/LibWeb/Internals/Internals.cpp +++ b/Userland/Libraries/LibWeb/Internals/Internals.cpp @@ -77,10 +77,20 @@ void Internals::commit_text() } void Internals::click(double x, double y) +{ + click(x, y, UIEvents::MouseButton::Primary); +} + +void Internals::middle_click(double x, double y) +{ + click(x, y, UIEvents::MouseButton::Middle); +} + +void Internals::click(double x, double y, UIEvents::MouseButton button) { auto& page = global_object().browsing_context()->page(); - page.handle_mousedown({ x, y }, { x, y }, 1, 0, 0); - page.handle_mouseup({ x, y }, { x, y }, 1, 0, 0); + page.handle_mousedown({ x, y }, { x, y }, button, 0, 0); + page.handle_mouseup({ x, y }, { x, y }, button, 0, 0); } void Internals::move_pointer_to(double x, double y) diff --git a/Userland/Libraries/LibWeb/Internals/Internals.h b/Userland/Libraries/LibWeb/Internals/Internals.h index a186be33ba..6118e0360f 100644 --- a/Userland/Libraries/LibWeb/Internals/Internals.h +++ b/Userland/Libraries/LibWeb/Internals/Internals.h @@ -8,6 +8,7 @@ #include #include +#include namespace Web::Internals { @@ -27,6 +28,7 @@ public: void commit_text(); void click(double x, double y); + void middle_click(double x, double y); void move_pointer_to(double x, double y); void wheel(double x, double y, double delta_x, double delta_y); @@ -37,6 +39,8 @@ public: private: explicit Internals(JS::Realm&); virtual void initialize(JS::Realm&) override; + + void click(double x, double y, UIEvents::MouseButton); }; } diff --git a/Userland/Libraries/LibWeb/Internals/Internals.idl b/Userland/Libraries/LibWeb/Internals/Internals.idl index 194620a941..f770f83116 100644 --- a/Userland/Libraries/LibWeb/Internals/Internals.idl +++ b/Userland/Libraries/LibWeb/Internals/Internals.idl @@ -13,6 +13,7 @@ interface Internals { undefined commitText(); undefined click(double x, double y); + undefined middleClick(double x, double y); undefined movePointerTo(double x, double y); undefined wheel(double x, double y, double deltaX, double deltaY);