Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d9d2a596e24f68b71b15b89129171287b9cfa419
https://github.com/WebKit/WebKit/commit/d9d2a596e24f68b71b15b89129171287b9cfa419
Author: Brent Fulgham <[email protected]>
Date: 2026-03-05 (Thu, 05 Mar 2026)
Changed paths:
A LayoutTests/editing/deleting/merge-image-and-text-expected.txt
A LayoutTests/editing/deleting/merge-image-and-text.html
M Source/WebCore/editing/ReplaceSelectionCommand.cpp
Log Message:
-----------
Wrong text position when you click backspace on the line below the image
https://bugs.webkit.org/show_bug.cgi?id=114960
rdar://171660935
Reviewed by Darin Adler.
Based on earlier work by Sudarshan C P <[email protected]>
When pasting, inserting, or deleting content, WebKit tries to place it outside
any inline styled ancestors of the insertion point (elements like <b>, <font>,
<i>,
etc.) so the pasted content doesn't inadvertently inherit those styles. It does
this
by splitting the ancestor tree at the insertion point.
This fix corrects a subtle failure of that logic when the cursor is positioned
immediately adjacent to a void element (an element that can't contain children,
like
<img>, <br>, or <input>). In that situation, the split was degenerate — there
was
nothing meaningful to split — but the code still updated the insertion position
as if
a real split had occurred, silently moving it to the wrong place. The result was
content being inserted at an incorrect location, such as merging into the wrong
paragraph or appearing inside a styled element it should have been placed
outside of.
This fix ensures that when the split would be a no-op, the insertion position
is left
alone, so content ends up exactly where the user placed the cursor.
Test: editing/deleting/merge-image-and-text.html
* LayoutTests/editing/deleting/merge-image-and-text-expected.txt: Added.
* LayoutTests/editing/deleting/merge-image-and-text.html: Added.
* Source/WebCore/editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
Canonical link: https://commits.webkit.org/308727@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications