mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
a8077f79cc
This input event handling change is intended to address the following design issues: - Having `DOM::Position` is unnecessary complexity when `Selection` exists because caret position could be described by the selection object with a collapsed state. Before this change, we had to synchronize those whenever one of them was modified, and there were already bugs caused by that, i.e., caret position was not changed when selection offset was modified from the JS side. - Selection API exposes selection offset within `<textarea>` and `<input>`, which is not supposed to happen. These objects should manage their selection state by themselves and have selection offset even when they are not displayed. - `EventHandler` looks only at `DOM::Text` owned by `DOM::Position` while doing text manipulations. It works fine for `<input>` and `<textarea>`, but `contenteditable` needs to consider all text descendant text nodes; i.e., if the cursor is moved outside of `DOM::Text`, we need to look for an adjacent text node to move the cursor there. With this change, `EventHandler` no longer does direct manipulations on caret position or text content, but instead delegates them to the active `InputEventsTarget`, which could be either `FormAssociatedTextControlElement` (for `<input>` and `<textarea>`) or `EditingHostManager` (for `contenteditable`). The `Selection` object is used to manage both selection and caret position for `contenteditable`, and text control elements manage their own selection state that is not exposed by Selection API. This change improves text editing on Discord, as now we don't have to refocus the `contenteditable` element after character input. The problem was that selection manipulations from the JS side were not propagated to `DOM::Position`. I expect this change to make future correctness improvements for `contenteditable` (and `designMode`) easier, as now it's decoupled from `<input>` and `<textarea>` and separated from `EventHandler`, which is quite a busy file. |
||
---|---|---|
.. | ||
CMake | ||
gn | ||
Lagom | ||
check-debug-flags.sh | ||
check-idl-files.py | ||
check-markdown.sh | ||
check-newlines-at-eof.py | ||
check-png-sizes.sh | ||
check-style.py | ||
configure-clangd.sh | ||
debug.plist | ||
embed_as_string.py | ||
find_compiler.sh | ||
generate-libwasm-spec-test.py | ||
generate-libwasm-spec-test.sh | ||
generate_clang_module_map.py | ||
import-wpt-test.py | ||
ladybird.sh | ||
lint-ci.sh | ||
lint-clang-format.sh | ||
lint-commit.sh | ||
lint-executable-resources.sh | ||
lint-gn.sh | ||
lint-prettier.sh | ||
lint-python.sh | ||
lint-shell-scripts.sh | ||
lint-swift.sh | ||
refresh-ladybird-qtcreator.sh | ||
shell_include.sh | ||
WPT.sh |