mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
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. :^)
This commit is contained in:
parent
b196665131
commit
4dde36844b
15 changed files with 311 additions and 10 deletions
36
Libraries/LibWeb/DOM/Event.h
Normal file
36
Libraries/LibWeb/DOM/Event.h
Normal file
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue