LibWeb: Fire input events in .execCommand()

We do not fire `beforeinput` events since other browsers do not seem to
do so either.

The spec asks us to check whether a command's action modified the DOM
tree. This means adding or removing nodes and attributes, or changing
character data anywhere in the tree. We have
`Document::dom_tree_version()` for node updates, but for character data
a new version number is introduced that allows us to easily keep track
of any text changes in the entire tree.
This commit is contained in:
Jelle Raaijmakers 2025-01-23 10:50:00 +01:00 committed by Andreas Kling
commit 0bb0061915
Notes: github-actions[bot] 2025-01-24 22:54:17 +00:00
8 changed files with 104 additions and 41 deletions

View file

@ -113,6 +113,11 @@ public:
u64 dom_tree_version() const { return m_dom_tree_version; }
void bump_dom_tree_version() { ++m_dom_tree_version; }
// AD-HOC: This number increments whenever CharacterData is modified in the document. It is used together with
// dom_tree_version() to understand whether either the DOM tree structure or contents were changed.
u64 character_data_version() const { return m_character_data_version; }
void bump_character_data_version() { ++m_character_data_version; }
WebIDL::ExceptionOr<void> populate_with_html_head_and_body();
GC::Ptr<Selection::Selection> get_selection() const;
@ -1067,6 +1072,7 @@ private:
Optional<Core::DateTime> m_last_modified;
u64 m_dom_tree_version { 0 };
u64 m_character_data_version { 0 };
// https://drafts.csswg.org/css-position-4/#document-top-layer
// Documents have a top layer, an ordered set containing elements from the document.