-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] [UIAsyncTextInput] WKWebView AutoFill input assistant item does…
…n't show up in the keyboard https://bugs.webkit.org/show_bug.cgi?id=267865 rdar://121160501 Reviewed by Aditya Keerthi and Abrar Rahman Protyasha. When async text input is enabled, we use `-requestTextContextForAutocorrectionWithCompletionHandler:` to surface autocorrection context information to UIKit. The conversion from `WebAutocorrectionContext::markedTextRange` to `DocumentEditingContext::selectedRangeInMarkedText` is currently straightforward: ``` editingContext.selectedRangeInMarkedText = { .location = correctionContext.selectedRangeInMarkedText.location, .length = correctionContext.selectedRangeInMarkedText.length }; ``` …however, this hides a subtle bug, since the "not found" location of `markedTextRange` (an `EditingRange`) is represented using `WTF::notFound`, while the `selectedRangeInMarkedText` represents "not found" with `NSNotFound`, directly mirroring `NSRange`. The `NSRange` operator in `EditingRange` is aware of this difference: ``` operator NSRange() const { if (location == notFound) return NSMakeRange(NSNotFound, 0); return NSMakeRange(location, length); } ``` …but we don't use it in the above code since we set the location and length directly. Fix this by simply mapping `notFound` to `NSNotFound` when creating the platform context in the async text input codepath. Test: AutocorrectionTests.AutocorrectionContextBeforeAndAfterEditing * Source/WebKit/Shared/ios/WebAutocorrectionContext.h: * Source/WebKit/Shared/ios/WebAutocorrectionContext.serialization.in: While we're here, also rename `markedTextRange` to `selectedRangeInMarkedText`, to clarify what this range actually represents. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView requestTextContextForAutocorrectionWithCompletionHandler:]): (+[WKAutocorrectionContext autocorrectionContextWithWebContext:]): * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::autocorrectionContext): * Tools/TestRunnerShared/spi/UIKitSPIForTesting.h: * Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm: Augment an existing API test to also verify that when there's no IME composition range, `markedText` is `nil` and `selectedRangeInMarkedText` is exactly equal to `{ NSNotFound, 0 }`. * Tools/TestWebKitAPI/cocoa/TestWKWebView.h: * Tools/TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView autocorrectionContext]): Canonical link: https://commits.webkit.org/273316@main
- Loading branch information
Showing
8 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters