⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280647 in webkit


Ignore:
Timestamp:
Aug 4, 2021, 11:44:20 AM (5 years ago)
Author:
Wenson Hsieh
Message:

[iOS 15] "Look Up" action is sometimes missing after force pressing images
https://bugs.webkit.org/show_bug.cgi?id=228774
rdar://78040734

Reviewed by Devin Rousso.

On iOS devices that support both 3D Touch and Visual Look Up (i.e., iPhone XS and iPhone XS Max), it's currently
possible to skip the image analysis preflight gesture entirely when showing the context menu over images in the
case where the user triggers the interaction by exceeding the force press threshold in under 100 ms (the current
delay of the image analysis long press gesture).

Mitigate this by teaching WKImageAnalysisGestureRecognizer to trigger image analysis preflight slightly ahead of
the context menu interaction when performing a force press by transitioning to Began state early under
-touchesBegan:withEvent: and -touchesMoved:withEvent:, if the touch's force exceeds a certain (relatively
low) threshold.

  • UIProcess/ios/WKImageAnalysisGestureRecognizer.mm:

(-[WKImageAnalysisGestureRecognizer touchesBegan:withEvent:]):
(-[WKImageAnalysisGestureRecognizer touchesMoved:withEvent:]):
(-[WKImageAnalysisGestureRecognizer beginAfterExceedingForceThresholdIfNeeded:]):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r280644 r280647  
     12021-08-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS 15] "Look Up" action is sometimes missing after force pressing images
     4        https://bugs.webkit.org/show_bug.cgi?id=228774
     5        rdar://78040734
     6
     7        Reviewed by Devin Rousso.
     8
     9        On iOS devices that support both 3D Touch and Visual Look Up (i.e., iPhone XS and iPhone XS Max), it's currently
     10        possible to skip the image analysis preflight gesture entirely when showing the context menu over images in the
     11        case where the user triggers the interaction by exceeding the force press threshold in under 100 ms (the current
     12        delay of the image analysis long press gesture).
     13
     14        Mitigate this by teaching WKImageAnalysisGestureRecognizer to trigger image analysis preflight slightly ahead of
     15        the context menu interaction when performing a force press by transitioning to Began state early under
     16        `-touchesBegan:withEvent:` and `-touchesMoved:withEvent:`, if the touch's force exceeds a certain (relatively
     17        low) threshold.
     18
     19        * UIProcess/ios/WKImageAnalysisGestureRecognizer.mm:
     20        (-[WKImageAnalysisGestureRecognizer touchesBegan:withEvent:]):
     21        (-[WKImageAnalysisGestureRecognizer touchesMoved:withEvent:]):
     22        (-[WKImageAnalysisGestureRecognizer beginAfterExceedingForceThresholdIfNeeded:]):
     23
    1242021-08-04  Per Arne  <pvollan@apple.com>
    225
  • trunk/Source/WebKit/UIProcess/ios/WKImageAnalysisGestureRecognizer.mm

    r278575 r280647  
    4646}
    4747
     48- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
     49{
     50    [super touchesBegan:touches withEvent:event];
     51
     52    [self beginAfterExceedingForceThresholdIfNeeded:touches];
     53}
     54
     55- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
     56{
     57    [super touchesMoved:touches withEvent:event];
     58
     59    [self beginAfterExceedingForceThresholdIfNeeded:touches];
     60}
     61
     62- (void)beginAfterExceedingForceThresholdIfNeeded:(NSSet<UITouch *> *)touches
     63{
     64    if (self.state != UIGestureRecognizerStatePossible)
     65        return;
     66
     67    if (touches.count > 1)
     68        return;
     69
     70    constexpr CGFloat forceThreshold = 1.5;
     71    if (touches.anyObject.force < forceThreshold)
     72        return;
     73
     74    self.state = UIGestureRecognizerStateBegan;
     75}
     76
    4877- (void)setState:(UIGestureRecognizerState)state
    4978{
Note: See TracChangeset for help on using the changeset viewer.