Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3fc6828f05499081fc602ef98715349aa167e5bd
      
https://github.com/WebKit/WebKit/commit/3fc6828f05499081fc602ef98715349aa167e5bd
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-12-01 (Fri, 01 Dec 2023)

  Changed paths:
    A 
LayoutTests/editing/input/ios/autocorrection-replaces-three-dots-with-ellipsis-expected.txt
    A 
LayoutTests/editing/input/ios/autocorrection-replaces-three-dots-with-ellipsis.html
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

  Log Message:
  -----------
  REGRESSION (270847@main): Typing three '.' adds extra periods instead of 
combining
https://bugs.webkit.org/show_bug.cgi?id=265671
rdar://118971986

Reviewed by Tim Horton and Megan Gardner.

After the changes in 270847@main, typing three `"."` characters results in the 
string `"..…"`,
instead of just a single ellipsis character. This is because UIKit now obtains 
a reinsertion string
when calling `-_expandSelectionToBackwardDeletionClusterWithReinsertionOut:`, 
underneath
`-[UIKeyboardImpl 
_deleteBackwardAndNotify:reinsertText:overrideOriginalContextBeforeInputWith:]`.
However, because we don't support synchronous calls to `-setSelectedRange:` 
with these new relative
ranges, UIKit's text reinsertion logic breaks, resulting in both the 
reinsertion string, `".."`, as
well as the replacement string, `"…"`, being inserted into the document.

To fix this in the short term, we conditionalize this `WKRelativeTextRange` 
refactoring (as well as
moving away from `-_characterInRelationToCaretSelection:`) on async text input 
enablement. The real
fix will require UIKit changes — i.e., refactoring keyboard code to handle 
async text inputs that
return non-null `-textRangeFromPosition:toPosition:`, but (crucially) don't 
support calls to
`-setSelectedTextRange:` that are expected to synchronously update document 
state.

Test: editing/input/ios/autocorrection-replaces-three-dots-with-ellipsis.html

* 
LayoutTests/editing/input/ios/autocorrection-replaces-three-dots-with-ellipsis-expected.txt:
 Added.
* 
LayoutTests/editing/input/ios/autocorrection-replaces-three-dots-with-ellipsis.html:
 Added.

Add a new layout test to exercise this scenario.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _characterInRelationToCaretSelection:]):

Restore this private method implementation, but call directly into the 
superclass implementation
instead of relying on our custom logic, in the case where async text input is 
enabled.

(-[WKContentView textRangeFromPosition:toPosition:]):
(-[WKContentView positionFromPosition:offset:]):

Revert to returning `nil`, in the case where async text input is disabled.

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to