LibWeb: Start integrating the editing API with user keyboard input

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()`.
This commit is contained in:
Jelle Raaijmakers 2025-05-09 09:13:32 +02:00 committed by Andreas Kling
commit ac46ec0b2e
Notes: github-actions[bot] 2025-05-16 22:30:34 +00:00
9 changed files with 84 additions and 80 deletions

View file

@ -122,6 +122,11 @@ WebIDL::ExceptionOr<bool> Document::exec_command(FlyString const& command, [[may
UIEvents::InputEventInit event_init {};
event_init.bubbles = true;
event_init.input_type = command_definition.mapped_value;
// AD-HOC: For insertText, we do what other browsers do and set data to value.
if (command == Editing::CommandNames::insertText)
event_init.data = value;
auto event = realm().create<UIEvents::InputEvent>(realm(), HTML::EventNames::input, event_init);
event->set_is_trusted(true);
affected_editing_host->dispatch_event(event);