Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e9f9c8bd018f93284b62781df8a556300ab06676
      
https://github.com/WebKit/WebKit/commit/e9f9c8bd018f93284b62781df8a556300ab06676
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-03-19 (Tue, 19 Mar 2024)

  Changed paths:
    A LayoutTests/fast/events/ios/autocorrect-with-caret-selection-expected.txt
    A LayoutTests/fast/events/ios/autocorrect-with-caret-selection.html
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

  Log Message:
  -----------
  REGRESSION (275503@main): Autocorrection candidates fail to insert text 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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to