LibWeb: Merge nested editing hosts

If a node with `contenteditable=true/plaintextonly` is the child of an
editable node or an editing host, we should make it editable instead of
an editing host. This effectively merges nested editing hosts together,
which is how other browsers deal with this as well.

Gains us 5 WPT subtest passes in `editing`.
This commit is contained in:
Jelle Raaijmakers 2025-09-03 16:53:18 +02:00 committed by Jelle Raaijmakers
parent 3931c0336b
commit 8986e1f1ec
Notes: github-actions[bot] 2025-09-03 22:25:59 +00:00
6 changed files with 59 additions and 23 deletions

View file

@ -550,8 +550,6 @@ void Selection::set_range(GC::Ptr<DOM::Range> range)
// AD-HOC: Focus editing host if the previous selection was outside of it. There seems to be no spec for this.
if (range && range->start_container()->is_editable_or_editing_host()) {
GC::Ref new_editing_host = *range->start_container()->editing_host();
while (new_editing_host->parent() && new_editing_host->parent()->is_editing_host())
new_editing_host = *new_editing_host->parent();
if (document()->focused_area() != new_editing_host) {
// FIXME: Determine and propagate the right focus trigger.
HTML::run_focusing_steps(new_editing_host, nullptr, HTML::FocusTrigger::Other);