diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-21 18:17:18 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-21 18:17:18 +0100 |
commit | 4dde36844b26de285abdd289a2b0443bfc54188c (patch) | |
tree | 39bbc3b1fc36c0cd3f22e2ef758c30246041f4ba /Libraries/LibWeb/DOM/Event.h | |
parent | b1966651312610e96059689c8d27e9502b6f3dc1 (diff) | |
download | serenity-4dde36844b26de285abdd289a2b0443bfc54188c.zip |
LibWeb: Add a DOM Event class (instead of events being simple strings)
This patch adds the Event base class, along with a MouseEvent subclass.
We now dispatch MouseEvent objects for mousedown, mouseup and mousemove
and these objects have the .offsetX and .offsetY properties.
Both of those properties are hard-coded at the moment. This will be
fixed in the next patch. :^)
Diffstat (limited to 'Libraries/LibWeb/DOM/Event.h')
-rw-r--r-- | Libraries/LibWeb/DOM/Event.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Libraries/LibWeb/DOM/Event.h b/Libraries/LibWeb/DOM/Event.h new file mode 100644 index 0000000000..ca2ca845db --- /dev/null +++ b/Libraries/LibWeb/DOM/Event.h @@ -0,0 +1,36 @@ +#pragma once + +#include <AK/RefCounted.h> +#include <AK/String.h> +#include <LibWeb/Bindings/Wrappable.h> + +namespace Web { + +class Event + : public RefCounted<Event> + , public Bindings::Wrappable { +public: + using WrapperType = Bindings::EventWrapper; + + static NonnullRefPtr<Event> create(String event_name) + { + return adopt(*new Event(move(event_name))); + } + + virtual ~Event() {} + + const String& name() const { return m_event_name; } + + virtual bool is_mouse_event() const { return false; } + +protected: + Event(String event_name) + : m_event_name(move(event_name)) + { + } + +private: + String m_event_name; +}; + +} |