[webkit-changes] [WebKit/WebKit] 6f7cad: [iOS] [UIAsyncTextInput] Support text context requ...
Wenson Hsieh
noreply at github.com
Wed Nov 8 13:36:29 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6f7cadfbdbe598673d2062be72141ead0a8b5aff
https://github.com/WebKit/WebKit/commit/6f7cadfbdbe598673d2062be72141ead0a8b5aff
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2023-11-08 (Wed, 08 Nov 2023)
Changed paths:
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
M Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm
Log Message:
-----------
[iOS] [UIAsyncTextInput] Support text context requests for autocorrection in UIKit
https://bugs.webkit.org/show_bug.cgi?id=264412
Reviewed by Tim Horton.
Adopt `-requestTextContextForAutocorrectionWithCompletionHandler:`, which is intended to replace
`-requestAutocorrectionContextWithCompletionHandler:`; the only functional difference here is that
the completion handler takes a `UIWKDocumentContext` (which will, itself, have a more generic name
in the near future) instead of a `UIWKAutocorrectionContext`.
To make this compatible with both the async text input codepath and legacy codepaths, we refactor
our logic for delivering this autocorrection context, such that the two codepaths both rely on a
common `-_internalRequestAutocorrectionContextWithCompletionHandler:` helper, which calls the
completion handler with an enum type indicating whether or not we should return the last cached
autocorrection context data on the content view. The logic to convert this cached WebKit struct into
either a `UIWKDocumentContext` or `UIWKAutocorrectionContext` exists in the delegate methods
themselves (`-requestAutocorrectionContextWithCompletionHandler:` and
`requestTextContextForAutocorrectionWithCompletionHandler:`).
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _cancelPendingAutocorrectionContextHandler]):
(-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
(-[WKContentView _internalRequestAutocorrectionContextWithCompletionHandler:]):
(-[WKContentView requestTextContextForAutocorrectionWithCompletionHandler:]):
(-[WKContentView _invokePendingAutocorrectionContextHandler:]): Deleted.
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm:
(-[WKTextInteractionWrapper dealloc]):
Drive-by fix: make sure we uninstall the async text interaction when tearing down the wrapper. This
is crucial to make sure that the interactions and related gestures are actually uninstalled from
the web view, upon calling `-[WKContentView cleanupInteraction]`
Canonical link: https://commits.webkit.org/270403@main
More information about the webkit-changes
mailing list