diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-04-15 20:50:02 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-15 20:22:08 +0200 |
commit | ad8e2f481d72b70a9a68b09f95a9e306d8c6a7c3 (patch) | |
tree | 7f799d26493e62783b0af84642717000c95596fa /Userland/Libraries/LibWeb/UIEvents | |
parent | 815934a95dc7f3bc540a6c66988073d0dddfb87e (diff) | |
download | serenity-ad8e2f481d72b70a9a68b09f95a9e306d8c6a7c3.zip |
LibWeb: Expose the MouseEvent::{clientX, clientY} attributes
These provide the cursor coordinate within the viewport at which the
event occurred (as opposed to the page relative coordinates exposed via
offsetX, offsetY).
Diffstat (limited to 'Userland/Libraries/LibWeb/UIEvents')
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.h | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index e102a4e138..8b3aab45b4 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -30,10 +30,12 @@ namespace Web::UIEvents { -MouseEvent::MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y) +MouseEvent::MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y) : UIEvent(event_name) , m_offset_x(offset_x) , m_offset_y(offset_y) + , m_client_x(client_x) + , m_client_y(client_y) { set_event_characteristics(); } diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 13fc8d3322..4c2d216fc7 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -35,24 +35,28 @@ class MouseEvent final : public UIEvents::UIEvent { public: using WrapperType = Bindings::MouseEventWrapper; - static NonnullRefPtr<MouseEvent> create(const FlyString& event_name, i32 offset_x, i32 offset_y) + static NonnullRefPtr<MouseEvent> create(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y) { - return adopt(*new MouseEvent(event_name, offset_x, offset_y)); + return adopt(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y)); } virtual ~MouseEvent() override; i32 offset_x() const { return m_offset_x; } i32 offset_y() const { return m_offset_y; } + i32 client_x() const { return m_client_x; } + i32 client_y() const { return m_client_y; } protected: - MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y); + MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y); private: void set_event_characteristics(); i32 m_offset_x { 0 }; i32 m_offset_y { 0 }; + i32 m_client_x { 0 }; + i32 m_client_y { 0 }; }; } diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl index 2751f2353a..452ef261d4 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.idl @@ -2,5 +2,7 @@ interface MouseEvent : Event { readonly attribute double offsetX; readonly attribute double offsetY; + readonly attribute double clientX; + readonly attribute double clientY; }; |