Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d1a44d038a3ef83816237ffefeb4a5f6d3d12ceb
https://github.com/WebKit/WebKit/commit/d1a44d038a3ef83816237ffefeb4a5f6d3d12ceb
Author: Alan Baradlay <[email protected]>
Date: 2026-04-15 (Wed, 15 Apr 2026)
Changed paths:
A LayoutTests/editing/deleting/first-letter-delete-expected.txt
A LayoutTests/editing/deleting/first-letter-delete.html
M Source/WebCore/rendering/RenderText.h
M Source/WebCore/rendering/RenderTextFragment.cpp
M Source/WebCore/rendering/RenderTextFragment.h
Log Message:
-----------
Deleting the first letter character in a contenteditable element with
::first-letter leaves the old letter visible
https://bugs.webkit.org/show_bug.cgi?id=311479
Reviewed by Antti Koivisto.
Given <div contenteditable>01</div> with div::first-letter, WebKit splits
the text into two renderers: first-letter text "0" and remaining fragment "1".
When the user places the caret between "0" and "1" and presses backspace,
the DOM text correctly changes from "01" to "1", but the rendered output
still shows "0". The first-letter renderer is never rebuilt.
The render tree updater calls setTextWithOffset("1") on the remaining
fragment to sync the renderer with the new DOM text. But the remaining
fragment's text is already "1" (it was the trailing portion of "01").
The base class sees text() == newText, skips the update, and the stale
first-letter renderer with "0" is never destroyed.
The fix: override setTextWithOffset in RenderTextFragment. When an edit
falls within the first-letter range (offset < m_start), destroy the
first-letter renderer before calling the base class. This lets the tree
builder recreate the first-letter split from the current DOM text.
Test: editing/deleting/first-letter-delete.html
* LayoutTests/editing/deleting/first-letter-delete-expected.txt: Added.
* LayoutTests/editing/deleting/first-letter-delete.html: Added.
* Source/WebCore/rendering/RenderText.h:
* Source/WebCore/rendering/RenderTextFragment.cpp:
(WebCore::RenderTextFragment::setTextWithOffset):
* Source/WebCore/rendering/RenderTextFragment.h:
Canonical link: https://commits.webkit.org/311298@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications