[webkit-changes] [WebKit/WebKit] b422a1: [iOS] Tap to revert does not work for multi-word a...

Aditya Keerthi noreply at github.com
Wed Jul 26 16:08:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b422a1c3f07c5ab9951cd222a71c61430189deb3
      https://github.com/WebKit/WebKit/commit/b422a1c3f07c5ab9951cd222a71c61430189deb3
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-07-26 (Wed, 26 Jul 2023)

  Changed paths:
    M Source/WebCore/editing/TextIterator.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm

  Log Message:
  -----------
  [iOS] Tap to revert does not work for multi-word autocorrections
https://bugs.webkit.org/show_bug.cgi?id=259522
rdar://112908387

Reviewed by Wenson Hsieh.

There are two issues preventing multi-word autocorrection UI from working correctly:

1. The correction indicator is only applied to the last word.
2. `-[WKContentView selectWordForReplacement]` does not extend the selection to cover multiple autocorrected words.

To fix (1), apply the correction indicator marker to the entire autocorrected
range. This is achieved by searching backwords for the inserted text to obtain
a range.

Then (2) is fixed by leveraging the same logic to extend the selection for
dictation alternatives, by extending the selection to cover the entire
DocumentMarker::CorrectionIndicator.

* Source/WebCore/editing/TextIterator.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::adjustCandidateAutocorrectionInFrame):

Search for the autocorrected range, beginning at the start of the editable
content and ending at the current selection. Search backwards since we know the
range will be at the end. Mark the entire range with
`DocumentMarker::CorrectionIndicator`.

(WebKit::WebPage::extendSelectionForReplacement):

Extend the selection to encompass the entire `DocumentMarker::CorrectionIndicator`.

(WebKit::WebPage::applyAutocorrectionInternal):
* Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:
(TEST):

Canonical link: https://commits.webkit.org/266336@main




More information about the webkit-changes mailing list