-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REGRESSION (275503@main): Double space in Mail compose on iOS doesn’t…
… insert period https://bugs.webkit.org/show_bug.cgi?id=272237 rdar://125852636 Reviewed by Abrar Protyasha and Ryosuke Niwa. With the changes in 275503@main, we now use `WebCore::findPlainText` to discover the nearby text to replace, in the case where the replacement range isn't just the last word. While `findPlainText` (and the underlying `SearchBuffer` machinery) is intended to ignore non-breaking spaces for the purposes of finding matches, this only works when `UCONFIG_NO_COLLATION` is disabled; otherwise, searching for the target text `" "` against a single non-breaking space `"0xA0"` will fail to find any matches. This subsequently causes autocorrection replacement to fail, in the case where UIKit tries to replace a space after a sentence with a period, when the user inserts two space characters in a row, since we fail to match the non-breaking space character right after the word. To fix this, we align the two find behaviors by moving the `UCONFIG_NO_COLLATION`-specific logic to handle `nbsp`: ``` inline void SearchBuffer::append(UChar c, bool isStart) { … m_buffer[m_cursor] = c == noBreakSpace ? ' ' : foldQuoteMark(c); } ``` ...into `foldQuoteMark`, renaming that helper function to `foldQuoteMarkAndReplaceNoBreakSpace`, and finally deploying `foldQuoteMarkAndReplaceNoBreakSpace` in the `!UCONFIG_NO_COLLATION` codepath as well. Test: editing/input/ios/autocorrection-replaces-space-with-period.html * LayoutTests/editing/input/ios/autocorrection-replaces-space-with-period-expected.txt: Added. * LayoutTests/editing/input/ios/autocorrection-replaces-space-with-period.html: Added. * Source/WebCore/editing/TextIterator.cpp: (WebCore::foldQuoteMarkAndReplaceNoBreakSpace): (WebCore::SearchBuffer::append): (WebCore::foldQuoteMark): Deleted. Canonical link: https://commits.webkit.org/277151@main
- Loading branch information
Showing
3 changed files
with
92 additions
and
37 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
LayoutTests/editing/input/ios/autocorrection-replaces-space-with-period-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
This test verifies that pressing the Space key twice replaces a space character after 'Hi' with a period. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS editor.textContent became 'Hi.' | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Hi. |
43 changes: 43 additions & 0 deletions
43
LayoutTests/editing/input/ios/autocorrection-replaces-space-with-period.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<head> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
<script src="../../../resources/js-test.js"></script> | ||
<style> | ||
.editor { | ||
border: 1px solid tomato; | ||
width: 300px; | ||
height: 150px; | ||
font-size: 16px; | ||
} | ||
</style> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
addEventListener("load", async () => { | ||
description("This test verifies that pressing the Space key twice replaces a space character after 'Hi' with a period."); | ||
await UIHelper.setHardwareKeyboardAttached(false); | ||
|
||
editor = document.querySelector(".editor"); | ||
await UIHelper.activateElementAndWaitForInputSession(editor); | ||
|
||
await UIHelper.callFunctionAndWaitForEvent(async () => { | ||
await UIHelper.typeCharacter(" "); | ||
await UIHelper.ensurePresentationUpdate(); | ||
}, editor, "keyup"); | ||
|
||
await UIHelper.applyAutocorrection(".", " "); | ||
await shouldBecomeEqual("editor.textContent", "'Hi.'"); | ||
|
||
editor.blur(); | ||
await UIHelper.waitForKeyboardToHide(); | ||
|
||
finishJSTest(); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div contenteditable="true" class="editor">Hi</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters