LibWeb: Implement selectionchange event according to spec

This commit is contained in:
Jelle Raaijmakers 2024-10-09 13:50:06 +02:00 committed by Andreas Kling
commit a58f39c9e2
Notes: github-actions[bot] 2024-10-09 17:09:45 +00:00
4 changed files with 82 additions and 14 deletions

View file

@ -23,6 +23,13 @@ enum class RelativeBoundaryPointPosition {
// https://dom.spec.whatwg.org/#concept-range-bp-position
RelativeBoundaryPointPosition position_of_boundary_point_relative_to_other_boundary_point(Node const& node_a, u32 offset_a, Node const& node_b, u32 offset_b);
// https://w3c.github.io/selection-api/#dfn-has-scheduled-selectionchange-event
template<typename T>
concept SelectionChangeTarget = DerivedFrom<T, EventTarget> && requires(T t) {
{ t.has_scheduled_selectionchange_event() } -> SameAs<bool>;
{ t.set_scheduled_selectionchange_event(bool()) } -> SameAs<void>;
};
class Range final : public AbstractRange {
WEB_PLATFORM_OBJECT(Range, AbstractRange);
JS_DECLARE_ALLOCATOR(Range);
@ -108,6 +115,10 @@ private:
Node const& root() const;
void update_associated_selection();
template<SelectionChangeTarget T>
void schedule_a_selectionchange_event(T&);
template<SelectionChangeTarget T>
void fire_a_selectionchange_event(T&);
enum class StartOrEnd {
Start,