[webkit-changes] [WebKit/WebKit] d23335: Adopt UIAsyncTextInteraction behind the "Async UIK...

Wenson Hsieh noreply at github.com
Thu Nov 2 13:31:27 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d23335f7ed29a16f0efa731cfdfd4cde398b6a59
      https://github.com/WebKit/WebKit/commit/d23335f7ed29a16f0efa731cfdfd4cde398b6a59
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-11-02 (Thu, 02 Nov 2023)

  Changed paths:
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/SourcesCocoa.txt
    M Source/WebKit/UIProcess/ios/WKContentView.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    A Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.h
    A Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  Adopt UIAsyncTextInteraction behind the "Async UIKit Interactions" setting
https://bugs.webkit.org/show_bug.cgi?id=264020

Reviewed by Megan Gardner.

Replace the existing `_textInteractionAssistant` in `WKContentView` with a `_textInteractionWrapper`
object instead, which wraps either a `UIWKTextInteractionAssistant` (in the case where the "Async
UIKit Interactions" feature flag is off), or a `UIAsyncTextInteraction` (in the case where the
feature flag is on).

For the legacy codepath, all methods on this new wrapper object correspond directly to the existing
methods already on `UIWKTextInteractionAssistant`, so there's no change in behavior; however, in the
case where we're using the new `UIAsyncTextInteraction`, only a subset of the methods have been
implemented so far, so we only plumb calls into `WKTextInteractionWrapper` through in those cases.

As we continue iterating on the modern async text interaction, we'll implement the remainder of
these methods which are currently no-ops when using `UIAsyncTextInteraction`.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _didExitStableState]):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldUseAsyncInteractions]):
(-[WKContentView _shouldUseUIContextMenuAsyncConfiguration]):
(-[WKContentView _shouldUseTextCursorDragAnimator]):
(-[WKContentView _updateRuntimeProtocolConformanceIfNeeded]):

Additionally declare conformance to `UIAsyncTextInputClient`, which extends from `UIAsyncTextInput`
and provides some additional functionality around text input via dictation (and more areas in the
near future).

(-[WKContentView cleanUpInteraction]):
(-[WKContentView becomeFirstResponderForWebView]):
(-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
(-[WKContentView _scrollingNodeScrollingWillBegin:]):
(-[WKContentView _scrollingNodeScrollingDidEnd:]):
(-[WKContentView setUpTextSelectionAssistant]):

Initialize a `WKTextInteractionWrapper` instead of a `UIWKTextInteractionAssistant`; this object
internally wraps either a legacy `UIWKTextInteractionAssistant`, or a new `UIAsyncTextInteraction`.

(-[WKContentView _willStartScrollingOrZooming]):
(-[WKContentView _didEndScrollingOrZooming]):
(-[WKContentView _lookupForWebView:]):
(-[WKContentView _shareForWebView:]):
(-[WKContentView _translateForWebView:]):
(-[WKContentView _addShortcutForWebView:]):
(-[WKContentView _promptForReplaceForWebView:]):
(-[WKContentView _transliterateChineseForWebView:]):
(-[WKContentView tintColorDidChange]):
(-[WKContentView selectForWebView:]):
(-[WKContentView selectAllForWebView:]):
(-[WKContentView _showDictionary:]):
(selectionChangedWithGesture):
(selectionChangedWithTouch):
(-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
(-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
(-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
(-[WKContentView interactionAssistant]):
(-[WKContentView _showKeyboard]):
(-[WKContentView _hideKeyboard]):
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
(-[WKContentView _updateChangedSelection:]):
(-[WKContentView prepareSelectionForContextMenuWithLocationInView:completionHandler:]):
(-[WKContentView _startSuppressingSelectionAssistantForReason:]):
(-[WKContentView _stopSuppressingSelectionAssistantForReason:]):
(-[WKContentView _dragInteractionClass]):
(-[WKContentView _restoreEditMenuIfNeeded]):
(-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
(-[WKContentView textInteractionAssistant]):
(-[WKContentView contextMenuInteraction]):
(-[WKContentView _registerPreview]):

Mechanically replace `_textInteractionAssistant` with `_textInteractionWrapper` in the content view.

* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.h: Added.
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm: Added.
(SOFT_LINK_CLASS_OPTIONAL):
(-[WKTextInteractionWrapper initWithView:]):
(-[WKTextInteractionWrapper textInteractionAssistant]):
(-[WKTextInteractionWrapper activateSelection]):
(-[WKTextInteractionWrapper deactivateSelection]):
(-[WKTextInteractionWrapper didEndScrollingOverflow]):
(-[WKTextInteractionWrapper selectionChanged]):
(-[WKTextInteractionWrapper setGestureRecognizers]):
(-[WKTextInteractionWrapper willStartScrollingOverflow]):
(-[WKTextInteractionWrapper selectionChangedWithGestureAt:withGesture:withState:withFlags:]):
(-[WKTextInteractionWrapper showDictionaryFor:fromRect:]):
(-[WKTextInteractionWrapper selectionChangedWithTouchAt:withSelectionTouch:withFlags:]):
(-[WKTextInteractionWrapper lookup:withRange:fromRect:]):
(-[WKTextInteractionWrapper showShareSheetFor:fromRect:]):
(-[WKTextInteractionWrapper showTextServiceFor:fromRect:]):
(-[WKTextInteractionWrapper scheduleReplacementsForText:]):
(-[WKTextInteractionWrapper scheduleChineseTransliterationForText:]):
(-[WKTextInteractionWrapper willStartScrollingOrZooming]):
(-[WKTextInteractionWrapper didEndScrollingOrZooming]):
(-[WKTextInteractionWrapper selectWord]):
(-[WKTextInteractionWrapper selectAll:]):
(-[WKTextInteractionWrapper contextMenuInteraction]):
(-[WKTextInteractionWrapper setExternalContextMenuInteractionDelegate:]):
(-[WKTextInteractionWrapper translate:fromRect:]):

Plumb from the text interaction wrapper to the inner interaction assistant; we also call into the
`_textInteractionWrapper` in only the methods that currently have parity with
`UIWKTextInteractionAssistant`.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

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




More information about the webkit-changes mailing list