Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dea762339998f966d7cda547c1c4e78527fd2274
      
https://github.com/WebKit/WebKit/commit/dea762339998f966d7cda547c1c4e78527fd2274
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-10-05 (Thu, 05 Oct 2023)

  Changed paths:
    M Source/WTF/wtf/PlatformHave.h
    M Source/WebKit/Platform/spi/ios/TextInputSPI.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

  Log Message:
  -----------
  [iOS] Refactor some code around `UIWKTextInteractionAssistant`
https://bugs.webkit.org/show_bug.cgi?id=262725

Reviewed by Megan Gardner.

Refactor some SPI usage related to `UIWKTextInteractionAssistant`. See below 
for more details.

* Source/WTF/wtf/PlatformHave.h:

Remove `HAVE(TEXT_INTERACTION_WITH_CONTEXT_MENU_INTERACTION)`. This has been 
true for all platforms
where `USE(UICONTEXTMENU)` is also true, since iOS 16.

* Source/WebKit/Platform/spi/ios/TextInputSPI.h:
* Source/WebKit/Platform/spi/ios/UIKitSPI.h:

Remove more SPI that's now unused.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:

Remove some unused typedefs, along with the `_contextMenuInteraction` ivar (see 
below).

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[UIGestureRecognizer _wk_isTapAndAHalf]):

Drop the `UI-` prefix when performing a class check for the tap-and-half 
gesture.

(-[WKContentView gestureRecognizer:canBePreventedByGestureRecognizer:]):

Greatly simplify this logic by removing logic to deal with the interaction 
assistant's
`-forcePressGesture`. This is `nil` for all iPad, iPhone (both 3D-touch-enabled 
and non-3D-touch
models), and Mac Catalyst, so there's no longer any need to consider this when 
checking for text
interaction gestures. Long pressing to select text now entirely relies on the 
variable loupe
gesture, whose name is `"UITextInteractionNameInteractiveRefinement"`.

(-[WKContentView 
gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):

Similarly, remove all uses of `-loupeGesture` and `-singleTapGesture`. Instead, 
cache these on the
content view as instance variables (based on gesture name) after adding them to 
the view under
`-setUpTextSelectionAssistant`.

(-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):
(-[WKContentView setUpTextSelectionAssistant]):

Also log a release error message in the case where either text interaction 
gestures can no longer be
found by iterating over the content view's gestures; this makes it a bit easier 
to determine when
(and if) this logic needs to be updated.

(-[WKContentView _translateForWebView:]):

Drive-by fix: remove a `-respondsToSelector` check that's no longer necessary.

(-[WKContentView 
changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
(-[WKContentView 
changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
(-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
(logTextInteractionAssistantSelectionChange):
(-[WKContentView 
_selectPositionAtPoint:stayingWithinFocusedElement:completionHandler:]):
(-[WKContentView 
selectPositionAtBoundary:inDirection:fromPoint:completionHandler:]):
(-[WKContentView moveSelectionAtBoundary:inDirection:completionHandler:]):
(-[WKContentView selectTextWithGranularity:atPoint:completionHandler:]):
(-[WKContentView beginSelectionInDirection:completionHandler:]):
(-[WKContentView updateSelectionWithExtentPoint:completionHandler:]):
(-[WKContentView 
updateSelectionWithExtentPoint:withBoundary:completionHandler:]):
(-[WKContentView _updateChangedSelection:]):

Remove logic to call into `-tintColorDidChange` on the selection view. 
`-selectionView` is actually
unconditionally `nil` on iOS 17 now, so this is just a no-op. I verified by 
manual testing (and also
by running the layout test 
`editing/caret/ios/caret-color-after-refocusing-input.html`) that this
caret-color bug remains fixed.

(-[WKContentView shouldDeferGestureDueToImageAnalysis:]):
(-[WKContentView 
deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
(-[WKContentView cancelActiveTextInteractionGestures]):
(-[WKContentView selectPositionAtPoint:withContextRequest:completionHandler:]):
(-[WKContentView contextMenuInteraction]):

Remove the `_contextMenuInteraction` ivar from the content view entirely. This 
is no longer
necessary because the context menu interaction in `WKWebView` is added 
indirectly by the text
interaction assistant, and is exposed via `-[UIWKTextInteractionAssistant 
contextMenuInteraction]`.

(-[WKContentView _registerPreview]):
(-[WKContentView _unregisterPreview]):
(-[WKContentView textInteractionAssistantContextMenuInteraction]): Deleted.

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


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

Reply via email to