Commit 05d76942 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS] Change omnibox pre-edit exiting behavior.

This reverts the improvements introduced in
https://chromium-review.googlesource.com/c/chromium/src/+/1183495 on
iOS 13 due to a UIKit bug. This way, swiping on the system keyboard
does not hang the app and the keyboard. However, bugs 875918,873544
are regressing.

Bug: 988431, 875918, 873544
Change-Id: I91f358d80531d17104ffc6db96d4a488864325a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722545Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682196}
parent 423e1b3f
......@@ -438,13 +438,24 @@ bool OmniboxViewIOS::OnWillChange(NSRange range, NSString* new_text) {
[field_ setClearingPreEditText:YES];
// Exit the pre-editing state in OnWillChange() instead of OnDidChange(), as
// that allows IME to continue working. The following code selects the text
// as if the pre-edit fake selection was real.
// that allows IME to continue working.
[field_ exitPreEditState];
field_.selectedTextRange =
[field_ textRangeFromPosition:field_.beginningOfDocument
toPosition:field_.endOfDocument];
if (@available(iOS 13, *)) {
// Exit pre-edit completely by setting the text to an empty string.
// On iOS 13, swiping keyboard acquires a lock that UITextField attempts
// to acquire when setSelectedTextRange: is called, causing a deadlock.
// Therefore this workaround is introduced. This probably introduces small
// issues with third-party keyboards, like crbug.com/875918 and
// crbug.com/873544. See crbug.com/988431 for more context.
[field_ setText:@""];
} else {
// The following code selects the text
// as if the pre-edit fake selection was real.
field_.selectedTextRange =
[field_ textRangeFromPosition:field_.beginningOfDocument
toPosition:field_.endOfDocument];
}
// Reset |range| to be of zero-length at location zero, as the field will be
// now cleared.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment