Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 54f691b62739c79aac116c4aa0d83fb859e72f8f
      
https://github.com/WebKit/WebKit/commit/54f691b62739c79aac116c4aa0d83fb859e72f8f
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-10-21 (Mon, 21 Oct 2024)

  Changed paths:
    A 
LayoutTests/editing/selection/ios/clear-selection-after-tap-on-video-expected.txt
    A LayoutTests/editing/selection/ios/clear-selection-after-tap-on-video.html
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

  Log Message:
  -----------
  [iOS] Removing a text selection that covers the video is nearly impossible on 
YouTube.com
https://bugs.webkit.org/show_bug.cgi?id=281887
rdar://88015073

Reviewed by Richard Robinson.

When tapping selection highlights on iOS, we normally allow UIKit 
(specifically, the text
interaction's multi tap gesture) to intercept the tap and toggle edit menu 
visibility, instead of
dispatching synthetic click events to the page.

There's an exception to this rule, which is that a selection covering most 
(>75%) of the unobscured
content rect will prefer sending the tap gesture through to the page instead of 
toggling the edit
menu (which clears the selection, due to dispatching a synthetic click).

On YouTube.com, there's a similar case where it makes more sense to prefer 
dispatching the tap over
the page instead of toggling the edit menu: the scenario where the selection 
has somehow covered the
main video player (normally by accident). In this case, tapping the video to 
play/pause/show the
controls overlay is almost always preferable to toggling visibility of the edit 
menu. Currently,
repeatedly tapping the selection just shows and hides the edit menu, which can 
feel frustrating to
the user.

To that end, we can mitigate this by separately clearing the text selection, in 
the case where the
tap over a selection highlight that would normally toggle the edit menu happens 
to also be over a
video element (unless it's over Live Text).

* 
LayoutTests/editing/selection/ios/clear-selection-after-tap-on-video-expected.txt:
 Added.
* LayoutTests/editing/selection/ios/clear-selection-after-tap-on-video.html: 
Added.

Add a layout test to exercise the change.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _shouldToggleEditMenuAfterTapAt:]):
(-[WKContentView gestureRecognizerShouldBegin:]):

Refactor this to send `ClearSelectionAfterTappingSelectionHighlightIfNeeded` to 
the web page, in
the event where the selection highlight was tapped.

(-[WKContentView _shouldToggleSelectionCommandsAfterTapAt:]): Deleted.

Rename this to refer to `EditMenu` instead of `SelectionCommands`. The former 
is the official,
modern API name for the edit menu, while the latter references the older 
internal name in UIKit.

* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::clearSelectionAfterTappingSelectionHighlightIfNeeded):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::clearSelectionAfterTappingSelectionHighlightIfNeeded):

Implement the main heuristic here — detect when the tap location is over a 
video (using a piercing
hit-test to take care of the case where custom video controls are rendered in a 
container covering
the video player), and clear the selection if needed.

Canonical link: https://commits.webkit.org/285543@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