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): Autocorrection candidates fail to insert te…
…xt when the selection is collapsed https://bugs.webkit.org/show_bug.cgi?id=271288 rdar://125034366 Reviewed by Richard Robinson. The change in 275503@main refactored the text search logic in `WebPage::applyAutocorrectionInternal` to use `rangeExpandedAroundPositionByCharacters` and `findPlainText`. However, this missed one subtlety in the previous implementation, which is that it would set the `range` to the current selection, in the case where both: 1. The current selection is collapsed, and 2. The `originalText` is also the empty string. This scenario is exercised simply by inserting content by pressing one of the predictive text candidates above the software keyboard on iOS, when the selection is after a space following a previous word — for example: ``` Hello |(world) ``` ...where `(world)` represents the predictive text candidate. The new codepath always fails here, since `findPlainText` will be given an empty range (which it returns), and then we fail the subsequent `!isCollapsed` check (which only makes sense in the case where the original text is non- empty). To fix this, we simply avoid falling down this `rangeExpandedAroundPositionByCharacters` codepath in the first place when the selection is collapsed, and just insert the text candidate. * LayoutTests/fast/events/ios/autocorrect-with-caret-selection.html: Added. * LayoutTests/fast/events/ios/autocorrect-with-caret-selection-expected.txt: Added. Add a layout test to exercise the change. * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::applyAutocorrectionInternal): Canonical link: https://commits.webkit.org/276385@main
- Loading branch information