iOS element fullscreen should use a UIGestureRecognizer to detect user interaction.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 21:35:11 +0000 (21:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 21:35:11 +0000 (21:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179029
rdar://problem/35307882

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-11-06
Reviewed by Simon Fraser.

Replace _WKTapDelegatingView with a UILongPressGestureRecognizer. When set with a duration of 0, it effectively
recognizes UITouchBegin events.

* UIProcess/ios/WKFullScreenWindowControllerIOS.mm:
(-[_WKFullScreenViewController loadView]):
(-[_WKFullScreenViewController gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
(-[_WKTapDelegatingView setTarget:action:]): Deleted.
(-[_WKTapDelegatingView hitTest:withEvent:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224509 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKFullScreenWindowControllerIOS.mm

index 1fff2b3..d78c70e 100644 (file)
@@ -1,3 +1,20 @@
+2017-11-06  Jeremy Jones  <jeremyj@apple.com>
+
+        iOS element fullscreen should use a UIGestureRecognizer to detect user interaction.
+        https://bugs.webkit.org/show_bug.cgi?id=179029
+        rdar://problem/35307882
+
+        Reviewed by Simon Fraser.
+
+        Replace _WKTapDelegatingView with a UILongPressGestureRecognizer. When set with a duration of 0, it effectively
+        recognizes UITouchBegin events.
+
+        * UIProcess/ios/WKFullScreenWindowControllerIOS.mm:
+        (-[_WKFullScreenViewController loadView]):
+        (-[_WKFullScreenViewController gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+        (-[_WKTapDelegatingView setTarget:action:]): Deleted.
+        (-[_WKTapDelegatingView hitTest:withEvent:]): Deleted.
+
 2017-11-06  Chris Dumez  <cdumez@apple.com>
 
         [Service Workers] Add proper implementation for 'updatefound' event
index 61014c8..ad7f261 100644 (file)
@@ -101,26 +101,7 @@ struct WKWebViewState {
 } // namespace WebKit
 
 
-@interface _WKTapDelegatingView: UIView
-@property (retain) id target;
-@property (assign) SEL action;
-@end
-
-@implementation _WKTapDelegatingView
-- (void)setTarget:(id)target action:(SEL)action
-{
-    [self setTarget:target];
-    [self setAction:action];
-}
-
-- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
-{
-    [[self target] performSelector:[self action]];
-    return nil;
-}
-@end
-
-@interface _WKFullScreenViewController : UIViewController
+@interface _WKFullScreenViewController : UIViewController <UIGestureRecognizerDelegate>
 @property (retain, nonatomic) NSArray *savedConstraints;
 @property (retain, nonatomic) UIView *contentView;
 @property (retain, nonatomic) id target;
@@ -129,7 +110,7 @@ struct WKWebViewState {
 
 @implementation _WKFullScreenViewController {
     RetainPtr<UIView> _backgroundView;
-    RetainPtr<_WKTapDelegatingView> _tapView;
+    RetainPtr<UILongPressGestureRecognizer> _touchGestureRecognizer;
     RetainPtr<UIButton> _cancelButton;
     RetainPtr<UIVisualEffectView> _visualEffectView;
 }
@@ -225,10 +206,11 @@ struct WKWebViewState {
 
     [[self view] addSubview:_cancelButton.get()];
 
-    _tapView = adoptNS([[_WKTapDelegatingView alloc] initWithFrame:[[self view] bounds]]);
-    [_tapView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-    [_tapView setTarget:self action:@selector(showCancelButton)];
-    [[self view] addSubview:_tapView.get()];
+    _touchGestureRecognizer = adoptNS([[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showCancelButton:)]);
+    [_touchGestureRecognizer setDelegate:self];
+    [_touchGestureRecognizer setCancelsTouchesInView:NO];
+    [_touchGestureRecognizer setMinimumPressDuration:0];
+    [[self view] addGestureRecognizer:_touchGestureRecognizer.get()];
 }
 
 - (void)viewWillAppear:(BOOL)animated
@@ -261,7 +243,7 @@ struct WKWebViewState {
     }];
 }
 
-- (void)showCancelButton
+- (void)showCancelButton:(id)sender
 {
     [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideCancelButton) object:nil];
     [self performSelector:@selector(hideCancelButton) withObject:nil afterDelay:3.0];
@@ -284,6 +266,13 @@ struct WKWebViewState {
     return YES;
 }
 
+// MARK - UIGestureRecognizerDelegate
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
+{
+    return YES;
+}
+
 @end