[webkit-changes] [WebKit/WebKit] ee754d: Consecutive calls to `-insertTextAlternatives:` sh...

Wenson Hsieh noreply at github.com
Fri Mar 1 16:31:49 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ee754d7dfc571ca86d2785731e52091ccaab308b
      https://github.com/WebKit/WebKit/commit/ee754d7dfc571ca86d2785731e52091ccaab308b
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-03-01 (Fri, 01 Mar 2024)

  Changed paths:
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/page/EditorClient.h
    M Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
    M Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestWebKitAPI/Tests/ios/TextAlternatives.mm
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

  Log Message:
  -----------
  Consecutive calls to `-insertTextAlternatives:` should not cause dictation underlines to disappear
https://bugs.webkit.org/show_bug.cgi?id=270370
rdar://107087527

Reviewed by Abrar Rahman Protyasha.

Add support for preserving dictation underlines when UIKit calls into `-insertTextAlternatives:`,
while finalizing dictation results. Currently, UIKit only calls into `-insertText:` with the best
alternative for the dictated text, which loses all information about dictation alternatives (along
with the blue dotted underlines). While there's public API on `UITextInput` to
`-insertDictationResults:` which we _could_ implement, the suggestions will eventually be shown by
UIKit when tapping on a dictation alternative range via `-alternativesForSelectedText`, which means
that we would need to convert `UIDictationPhrase` objects into `BETextAlternatives` — something
that's not possible without introducing new API surface in BrowserEngineKit.

Instead, UIKit will be inserting text alternatives in the form of `BETextAlternatives` (or
`NSTextAlternatives` in the case where BrowserEngineKit integration is disabled), which we'll honor
by adding dictation alternative document markers.

Test: TextAlternatives.InsertDictationResultsAsAlternatives

* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::updateMarkersForWordsAffectedByEditing):

Prevent dictation markers from being removed as a result of inserting plain text, while finalizing
dictation results.

* Source/WebCore/page/EditorClient.h:
(WebCore::EditorClient::shouldRemoveDictationAlternativesAfterEditing const):
* Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h:
* Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::shouldRemoveDictationAlternativesAfterEditing const):
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::shouldRemoveDictationAlternativesAfterEditing const):
* Tools/TestWebKitAPI/Tests/ios/TextAlternatives.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:

Add an API test to exercise this change.

(-[WKWebView insertText:alternatives:]):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list