Skip to content

Commit

Permalink
LibWeb: Add fast_is<T> for UIEvents::MouseEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Mar 16, 2024
1 parent bfbc08e commit 774c574
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Userland/Libraries/LibWeb/DOM/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ class Event : public Bindings::PlatformObject {

Vector<JS::Handle<EventTarget>> composed_path() const;

template<typename T>
bool fast_is() const = delete;

virtual bool is_mouse_event() const { return false; }

protected:
void initialize_event(String const&, bool, bool);

Expand Down
9 changes: 9 additions & 0 deletions Userland/Libraries/LibWeb/UIEvents/MouseEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -102,3 +104,10 @@ class MouseEvent : public UIEvent {
};

}

namespace Web::DOM {

template<>
inline bool Event::fast_is<UIEvents::MouseEvent>() const { return is_mouse_event(); }

}

0 comments on commit 774c574

Please sign in to comment.