mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-08 01:51:57 +00:00
This reworks EventHandler so text insertion, backspace, delete and return actions are now handled by the Editing API. This was the whole point of the execCommand spec, to provide an implementation of both editing commands and the expected editing behavior on user input. Responsibility of firing the `input` event is moved from EventHandler to the Editing API, which also gets rid of duplicate events whenever dealing with `<input>` or `<textarea>` events. The `beforeinput` event still needs to be fired by `EventHandler` however, since that is never fired by `execCommand()`.
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGC/Ptr.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Page/EventResult.h>
|
|
|
|
namespace Web {
|
|
|
|
class InputEventsTarget {
|
|
public:
|
|
virtual ~InputEventsTarget() = default;
|
|
|
|
virtual GC::Ref<JS::Cell> as_cell() = 0;
|
|
|
|
virtual void handle_insert(String const&) = 0;
|
|
virtual EventResult handle_return_key(FlyString const& ui_input_type) = 0;
|
|
|
|
enum class DeleteDirection {
|
|
Backward,
|
|
Forward,
|
|
};
|
|
virtual void handle_delete(DeleteDirection) = 0;
|
|
|
|
virtual void select_all() = 0;
|
|
virtual void set_selection_anchor(GC::Ref<DOM::Node>, size_t offset) = 0;
|
|
virtual void set_selection_focus(GC::Ref<DOM::Node>, size_t offset) = 0;
|
|
enum class CollapseSelection {
|
|
No,
|
|
Yes,
|
|
};
|
|
virtual void move_cursor_to_start(CollapseSelection) = 0;
|
|
virtual void move_cursor_to_end(CollapseSelection) = 0;
|
|
virtual void increment_cursor_position_offset(CollapseSelection) = 0;
|
|
virtual void decrement_cursor_position_offset(CollapseSelection) = 0;
|
|
virtual void increment_cursor_position_to_next_word(CollapseSelection) = 0;
|
|
virtual void decrement_cursor_position_to_previous_word(CollapseSelection) = 0;
|
|
};
|
|
|
|
}
|