The issue title blames ::first-letter and ß (which uppercases to SS). Neither is involved. The reporter's page also toggles white-space: pre on every keypress, and that is the only trigger.
A space typed under pre is stored as a plain U+0020. Once the style is back to normal, that trailing space is collapsed (not rendered). On the next keystroke Blink moves the caret in front of the collapsed space and deletes it as "insignificant" whitespace. Typing This sentence should have spaces gives ßThissentence shouldhave spaces: every space typed while pre was active is lost.
The same sweep also removes an authored collapsed trailing space (caret after the space in <div contenteditable>This </div>, type s, result Thiss). That part is required by the WPT editing/run/inserttext.html expectations and stays unchanged; the fix is scoped to spaces typed in the still-open typing session.
Running checks...
Each case builds a contenteditable, places the caret and inserts text with document.execCommand('insertText'), which takes the same editor path as typing. Whitespace in results is shown as · for U+0020 and ° for U+00A0 (nbsp). Both render as a space; the check compares with nbsp normalized to a space.
Same logic as the original attachment: every keypress alternately adds and removes ::first-letter { text-transform: uppercase; background: blue } and white-space: pre. Click at the end of the box and type This sentence should have spaces.
textContent:
spaces: 0
bug Every second space disappears (the ones typed while pre was active).
fixed All spaces stay.
The box contains This with a plain trailing space that was never typed in an open typing session. Press the button to put the caret after that space, then type s. Per the WPT inserttext expectations the space is swept, with or without the fix.
textContent:
spec Thiss in both patched and unpatched builds.
Editor::InsertTextWithoutSendingTextEvent() turns the selection into a VisibleSelection. The caret at offset 5 in "This " sits after a collapsed space, so it is moved to offset 4. Everything downstream only sees offset 4.
InsertTextCommand::DoApply() calls MostBackwardCaretPosition() and then DeleteInsignificantText(start, MostForwardCaretPosition(start)). The unrendered space between offset 4 and 5 is deleted before the character is inserted.
third_party/blink/renderer/core/editing/editor.cc
Editor::InsertTextWithoutSendingTextEvent()
third_party/blink/renderer/core/editing/commands/insert_text_command.cc
InsertTextCommand::DoApply()
start_position = MostBackwardCaretPosition(start_position);
DeleteInsignificantText(start_position,
MostForwardCaretPosition(start_position));
CL 8554097
The fix is scoped to the open typing session. TypingCommand::InsertText() checks (SelectionKeepingTypedSpace()) whether the still-open typing command ended exactly at the raw caret and whether that caret directly follows a single collapsed space after text (ShouldKeepSpaceBeforeCaret()). Only then it keeps the raw caret instead of the canonicalized one, and before the next sub-insertion the collapsed space is rendered as an nbsp so the insignificant-whitespace sweep keeps it. Whitespace rebalancing turns it back into a plain space once text follows.
Authored collapsed spaces, leading indentation and runs of two or more spaces are untouched; the WPT editing/run/inserttext.html expectations require them to be swept. Covered in both editing code paths (a virtual test suite runs the test with EditingUseDomPositionApi disabled, the lane shipping in Chrome).
Kill switch: EditingKeepCollapsedSpaceBeforeCaret (status stable). Run Chrome with --disable-blink-features=EditingKeepCollapsedSpaceBeforeCaret to get the old behavior back.
Test: web_tests/editing/inserting/insert-text-after-unrendered-space.html.
The older WIP CL 7602173 changes SimplifiedBackwardsTextIterator::HandleFirstLetter() for the ß/SS length mismatch. Applying it does not change the result of the reporter's page, and its web tests already pass without it.
The second symptom in the report (Backspace while the blue first letter is visible clears the whole box) does not reproduce on current Chromium.