Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: abdb8d25bff5d073b594a550095cee3b82f08b82
      
https://github.com/WebKit/WebKit/commit/abdb8d25bff5d073b594a550095cee3b82f08b82
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-11-18 (Mon, 18 Nov 2024)

  Changed paths:
    A 
LayoutTests/editing/caret/ios/place-caret-after-autocorrected-word-expected.txt
    A LayoutTests/editing/caret/ios/place-caret-after-autocorrected-word.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebCore/dom/SimpleRange.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  [iOS] [Mail Compose] Unable to tap to put text cursor at end of line if last 
word was autocorrected
https://bugs.webkit.org/show_bug.cgi?id=283304
rdar://129961069

Reviewed by Abrar Rahman Protyasha and Richard Robinson.

Currently, it's possible to get stuck in a state where you can't move the text 
cursor to the end of
a line by tapping after the end of the word, if the last word on the line was 
autocorrected. This is
because UIKit's text interaction tap gesture tells us to 
`-selectWordForReplacement` when tapping
after the end of the autocorrected word, which we (currently) always honor.

To mitigate this, we prevent the same autocorrected word range from being 
selected multiple times in
a row, as long as the selection is still inside of the word range. This allows 
the user to toggle
between selecting the autocorrected word and setting the selection to the end 
of the line, which
matches platform behavior in Notes.

* 
LayoutTests/editing/caret/ios/place-caret-after-autocorrected-word-expected.txt:
 Added.
* LayoutTests/editing/caret/ios/place-caret-after-autocorrected-word.html: 
Added.

Add a new layout test to exercise this change, by calling into 
`-selectWordForReplacement` from a
new testing hook. I couldn't reliably get UIKit's text interactions to exhibit 
this same behavior in
a testing environment purely by tapping to set the selection, but we can still 
simulate UIKit
behavior at the API boundary using this approach.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.selectWordForReplacement):
(window.UIHelper.applyAutocorrection):

Add an `underline` argument to this testing helper, to determine whether or not 
we should add blue
autocorrection underlines.

* Source/WebCore/dom/SimpleRange.h:
(WebCore::makeBoundaryPointHelper):
(WebCore::makeSimpleRangeHelper):
(WebCore::makeSimpleRange):

Add a helper method to convert from `WeakSimpleRange` to 
`std::optional<SimpleRange>`. This returns
`nullopt` if either of the boundary points are invalidated.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didChangeSelection):
(WebKit::WebPage::didCommitLoad):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::extendSelectionForReplacement):

See above for more details.

(WebKit::WebPage::resetLastSelectedReplacementRangeIfNeeded):

Clear out `m_lastSelectedReplacementRange` when the selection moves outside of 
the range.

* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::selectWordForReplacement):
(WTR::UIScriptController::applyAutocorrection):
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::selectWordForReplacement):
(WTR::UIScriptControllerIOS::applyAutocorrection):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to