Bug 240011

Summary: Double tap to hold on a Canvas tag to selected other text
Product: WebKit Reporter: misinoe.t
Component: CanvasAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: dino, megan_gardner, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: iPhone / iPad   
OS: iOS 15   
Attachments:
Description Flags
This is a working demo and recorded video none

Description misinoe.t 2022-05-03 07:51:16 PDT
Created attachment 458744 [details]
This is a working demo and recorded video

I have confirmed that the paint web application I developed does not work properly on my iPad Pro.

Pursuing deeper, I found that
When I double tap and hold on an HTMLCanvasElement, nearby text is selected.

This causes the focus to be incorrect and the position of the magnifier to be fixed to the top of the selected text.
Comment 1 Wenson Hsieh 2022-05-03 18:22:53 PDT
Able to reproduce on trunk WebKit, iOS 15. The `canvas` element already has `user-select: none;`, but that doesn't seem to have any effect :(

(Using `-webkit-user-select: none;` didn't make any difference either).
Comment 2 Wenson Hsieh 2022-05-03 18:32:12 PDT
I think we can fix this by relaxing this check:

```
(in WKContentViewInteraction.mm:)

    if (gesture == UIWKGestureLoupe && _positionInformation.selectability == WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToUserSelectNone)
        return NO;

```

...to something like this instead:

```
(in WKContentViewInteraction.mm:)

    if (gesture != UIWKGestureOneFingerTap && _positionInformation.selectability == WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToUserSelectNone)
        return NO;

```

I _suspect_ the choice to limit this to only the Loupe gesture was made to (1) limit risk, and (2) to make it so that the user can always still tap in `-webkit-user-select: none;` regions to clear an existing selection.

One workaround here would be to add active touch event listeners and prevent `touchstart` and/or `touchend`.
Comment 3 Radar WebKit Bug Importer 2022-05-10 07:52:15 PDT
<rdar://problem/93028767>