[webkit-changes] [WebKit/WebKit] 651757: [iOS] Tap to revert does not always display an acc...

Aditya Keerthi noreply at github.com
Fri Jul 28 13:59:20 PDT 2023


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

  Changed paths:
    M Source/WebCore/dom/DocumentMarkerController.cpp
    M Source/WebCore/dom/DocumentMarkerController.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/Shared/DocumentEditingContext.h
    M Source/WebKit/Shared/DocumentEditingContext.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm
    M Tools/TestWebKitAPI/ios/UIKitSPI.h

  Log Message:
  -----------
  [iOS] Tap to revert does not always display an accurate prompt for multi-word autocorrections
https://bugs.webkit.org/show_bug.cgi?id=259595
rdar://113036177

Reviewed by Wenson Hsieh.

UIKit requires additional information in order to detect that a tapped word is
part of a multi-word correction. Specifically, they require the entire
corrected string given a single tapped word, in order to look up the right
autocorrection record.

To support this requirement, add support for obtaining autocorrected ranges in
a document editing context. WebKit will provide `autocorrectedRanges` on
`UIWKDocumentContext`, when the `UIWKDocumentRequest` has
`UIWKDocumentRequestAutocorrectedRanges` specified in its flags. Then, with the
existing properties on `UIWKDocumentContext`, UIKit can determine the corrected
string nearest to the current selection.

* Source/WebCore/dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::forEach):

Pass the node into the callback function so that it may be used to obtain a
`SimpleRange` from the `DocumentMarker`.

(WebCore::DocumentMarkerController::rangesForMarkersInRange):

Return a `SimpleRange` for each `DocumentMarker`.

(WebCore::DocumentMarkerController::hasMarkers):
(WebCore::DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
* Source/WebCore/dom/DocumentMarkerController.h:
* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/Shared/DocumentEditingContext.h:
* Source/WebKit/Shared/DocumentEditingContext.mm:
(WebKit::DocumentEditingContext::toPlatformContext):
(IPC::ArgumentCoder<WebKit::DocumentEditingContext>::encode):
(IPC::ArgumentCoder<WebKit::DocumentEditingContext>::decode):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(toWebDocumentRequestOptions):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:

Resolve the `SimpleRange` from each marker as a character range, using a
`SimpleRange` representing the current context.

Populate `context.autocorrectedRanges` to be sent back to the UI process and UIKit.

(WebKit::WebPage::requestDocumentEditingContext):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
(TEST):
* Tools/TestWebKitAPI/ios/UIKitSPI.h:

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




More information about the webkit-changes mailing list