LibWeb: Make event dispatching spec-compliant

Specification: https://dom.spec.whatwg.org/#concept-event-dispatch

This also introduces shadow roots due to it being a requirement of
the event dispatcher.

However, it does not introduce the full shadow DOM, that can be
left for future work.

This changes some event dispatches which require certain attributes
to be initialised to a value.
This commit is contained in:
Luke 2020-11-21 18:32:39 +00:00 committed by Andreas Kling
parent 819f099a8e
commit e8b3a65581
Notes: sideshowbarker 2024-07-19 01:18:46 +09:00
32 changed files with 858 additions and 54 deletions

View file

@ -26,6 +26,7 @@
#pragma once
#include <AK/TypeCasts.h>
#include <LibWeb/UIEvents/UIEvent.h>
namespace Web::UIEvents {
@ -39,24 +40,25 @@ public:
return adopt(*new MouseEvent(event_name, offset_x, offset_y));
}
virtual ~MouseEvent() override { }
virtual ~MouseEvent() override;
i32 offset_x() const { return m_offset_x; }
i32 offset_y() const { return m_offset_y; }
protected:
MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y)
: UIEvent(event_name)
, m_offset_x(offset_x)
, m_offset_y(offset_y)
{
}
MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y);
private:
virtual bool is_mouse_event() const override { return true; }
void set_event_characteristics();
i32 m_offset_x { 0 };
i32 m_offset_y { 0 };
};
}
AK_BEGIN_TYPE_TRAITS(Web::UIEvents::MouseEvent)
static bool is_type(const Web::DOM::Event& event) { return event.is_mouse_event(); }
AK_END_TYPE_TRAITS()