Title: [280647] trunk/Source/WebKit
- Revision
- 280647
- Author
- [email protected]
- Date
- 2021-08-04 11:44:20 -0700 (Wed, 04 Aug 2021)
Log 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:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (280646 => 280647)
--- trunk/Source/WebKit/ChangeLog 2021-08-04 18:39:37 UTC (rev 280646)
+++ trunk/Source/WebKit/ChangeLog 2021-08-04 18:44:20 UTC (rev 280647)
@@ -1,3 +1,26 @@
+2021-08-04 Wenson Hsieh <[email protected]>
+
+ [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:]):
+
2021-08-04 Per Arne <[email protected]>
[macOS] Update message filters
Modified: trunk/Source/WebKit/UIProcess/ios/WKImageAnalysisGestureRecognizer.mm (280646 => 280647)
--- trunk/Source/WebKit/UIProcess/ios/WKImageAnalysisGestureRecognizer.mm 2021-08-04 18:39:37 UTC (rev 280646)
+++ trunk/Source/WebKit/UIProcess/ios/WKImageAnalysisGestureRecognizer.mm 2021-08-04 18:44:20 UTC (rev 280647)
@@ -45,6 +45,35 @@
return self;
}
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
+{
+ [super touchesBegan:touches withEvent:event];
+
+ [self beginAfterExceedingForceThresholdIfNeeded:touches];
+}
+
+- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
+{
+ [super touchesMoved:touches withEvent:event];
+
+ [self beginAfterExceedingForceThresholdIfNeeded:touches];
+}
+
+- (void)beginAfterExceedingForceThresholdIfNeeded:(NSSet<UITouch *> *)touches
+{
+ if (self.state != UIGestureRecognizerStatePossible)
+ return;
+
+ if (touches.count > 1)
+ return;
+
+ constexpr CGFloat forceThreshold = 1.5;
+ if (touches.anyObject.force < forceThreshold)
+ return;
+
+ self.state = UIGestureRecognizerStateBegan;
+}
+
- (void)setState:(UIGestureRecognizerState)state
{
auto previousState = self.state;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes