From 7bee1c9897c46334593814d9f4b58adfd3b1ead1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 19 Feb 2024 07:44:11 -0500 Subject: [PATCH] LibWeb: Store the input image button's selected coordinates as integers The spec has prose which states, e.g., "The x-component must be a valid integer". --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 6 +++++- Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 597caec823..e4fb38586b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -310,7 +310,11 @@ WebIDL::ExceptionOr HTMLInputElement::run_input_activation_behavior(DOM::E // coordinate to that coordinate. if (event.is_trusted() && is(event)) { auto const& mouse_event = static_cast(event); - m_selected_coordinate = { mouse_event.offset_x(), mouse_event.offset_y() }; + + CSSPixels x { mouse_event.offset_x() }; + CSSPixels y { mouse_event.offset_y() }; + + m_selected_coordinate = { x.to_int(), y.to_int() }; } // 4. Submit the element's form owner from the element with userInvolvement set to event's user navigation involvement. diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index d7b60fb8aa..b0e0826e17 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -105,8 +105,8 @@ public: WebIDL::ExceptionOr set_size(unsigned value); struct SelectedCoordinate { - double x { 0.0 }; - double y { 0.0 }; + int x { 0 }; + int y { 0 }; }; SelectedCoordinate selected_coordinate() const { return m_selected_coordinate; }