Bug 239055

Summary: REGRESSION (r289785): [iOS] Unable to double-click to select a word in a received email
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: PlatformAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: akeerthi, hi, katherine_cheney, megan_gardner, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
For EWS
none
For landing ews-feeder: commit-queue-

Description Wenson Hsieh 2022-04-10 14:59:04 PDT
rdar://90736710
Comment 1 Wenson Hsieh 2022-04-10 15:35:16 PDT
Created attachment 457213 [details]
For EWS
Comment 2 Tim Horton 2022-04-10 18:37:42 PDT
Comment on attachment 457213 [details]
For EWS

View in context: https://bugs.webkit.org/attachment.cgi?id=457213&action=review

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:-1857
> -    if (gestureRecognizer != _mouseGestureRecognizer && [_mouseGestureRecognizer mouseTouch] == touch && touch.type == UITouchTypeIndirectPointer)

I think this isn't the only use of `UITouchTypeIndirectPointer` in our code? Are the others wrong too?
Comment 3 Wenson Hsieh 2022-04-11 07:40:15 PDT
Comment on attachment 457213 [details]
For EWS

View in context: https://bugs.webkit.org/attachment.cgi?id=457213&action=review

Thanks for the review!

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:-1857
>> -    if (gestureRecognizer != _mouseGestureRecognizer && [_mouseGestureRecognizer mouseTouch] == touch && touch.type == UITouchTypeIndirectPointer)
> 
> I think this isn't the only use of `UITouchTypeIndirectPointer` in our code? Are the others wrong too?

That's a good point — the two other checks in `-_shouldReceiveTouch:forEvent:recognizerView:` and in this same function (below) also look a bit suspicious.

I'll double check to see if they should be changed as well....
Comment 4 Wenson Hsieh 2022-04-11 09:35:19 PDT
(In reply to Wenson Hsieh from comment #3)
> Comment on attachment 457213 [details]
> For EWS
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457213&action=review
> 
> Thanks for the review!
> 
> >> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:-1857
> >> -    if (gestureRecognizer != _mouseGestureRecognizer && [_mouseGestureRecognizer mouseTouch] == touch && touch.type == UITouchTypeIndirectPointer)
> > 
> > I think this isn't the only use of `UITouchTypeIndirectPointer` in our code? Are the others wrong too?
> 
> That's a good point — the two other checks in
> `-_shouldReceiveTouch:forEvent:recognizerView:` and in this same function
> (below) also look a bit suspicious.
> 
> I'll double check to see if they should be changed as well....

So for this check:

```
    if (gestureRecognizer == _doubleTapGestureRecognizer || gestureRecognizer == _nonBlockingDoubleTapGestureRecognizer)
        return touch.type != UITouchTypeIndirectPointer;
```

I'm actually not sure how to exercise that codepath using touches produced by a trackpad on iOS, since we would normally already have bailed in the `gestureRecognizer != _mouseGestureRecognizer && [_mouseGestureRecognizer mouseTouch] == touch` check above. It's also interesting to note that this was changed in trac.webkit.org/r261978 as well, from `-_isPointerTouch` to `UITouchTypeIndirectPointer`, though maybe that was just about moving off of UIKit SPI (rather than about changing behavior).

For the other check:

```
- (BOOL)_shouldReceiveTouch:(UITouch *)touch forEvent:(UIEvent *)event recognizerView:(id)gestureOwner
{
    return touch == _currentTouch && touch.type == UITouchTypeIndirectPointer;
}
```

I confirmed that this causes `mousedown` and `mouseup` events to *not* be dispatched in non-"UIApplicationSupportsIndirectInputEvents" apps when clicking with a trackpad! This is fixed if we use `-_isPointerTouch` instead. Since this also appears to be a recent regression (from r290009), I'll fix it in this patch as well.
Comment 5 Wenson Hsieh 2022-04-11 09:40:25 PDT
Created attachment 457259 [details]
For landing
Comment 6 EWS 2022-04-11 13:19:58 PDT
Committed r292715 (249505@main): <https://commits.webkit.org/249505@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 457259 [details].