From 774c574ede270c4f8b1255724082b566dd36c0e6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Mar 2024 14:47:54 +0100 Subject: [PATCH] LibWeb: Add fast_is for UIEvents::MouseEvent --- Userland/Libraries/LibWeb/DOM/Event.h | 5 +++++ Userland/Libraries/LibWeb/UIEvents/MouseEvent.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h index eeb9784c4fd911d..f9cc2f74e612d27 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.h +++ b/Userland/Libraries/LibWeb/DOM/Event.h @@ -144,6 +144,11 @@ class Event : public Bindings::PlatformObject { Vector> composed_path() const; + template + bool fast_is() const = delete; + + virtual bool is_mouse_event() const { return false; } + protected: void initialize_event(String const&, bool, bool); diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index a27d85ffe201ee4..69b8d0852908f4c 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -71,6 +71,8 @@ class MouseEvent : public UIEvent { virtual void initialize(JS::Realm&) override; private: + virtual bool is_mouse_event() const override { return true; } + void set_event_characteristics(); double m_screen_x { 0 }; @@ -102,3 +104,10 @@ class MouseEvent : public UIEvent { }; } + +namespace Web::DOM { + +template<> +inline bool Event::fast_is() const { return is_mouse_event(); } + +}