[Extra Zoom Mode] Implement support for indirect mainframe scrolling
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Feb 2018 17:44:36 +0000 (17:44 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Feb 2018 17:44:36 +0000 (17:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182421
<rdar://problem/35142694>

Reviewed by Tim Horton.

Makes a few small adjustments to WKScrollView to improve mainframe scrolling, and disable the pinch gesture for
zooming. See below for more details.

* UIProcess/API/Cocoa/WKWebView.mm:

Remove a now-unneeded WebKitAdditions import.

* UIProcess/ios/WKScrollView.mm:
(-[WKScrollView initWithFrame:]):

Add imports for -Before and -After versions of WKScrollViewAdditions.

(-[WKScrollView addGestureRecognizer:]):

Override -addGestureRecognizer here to prevent touches on the pinch gesture recognizer from being recognized.
I chose this approach instead of just disabling the gesture in -initWithFrame: because (1) the pinch gesture
recognizer is lazily created when setting minimum or maximum zoom scales, rather than immediately in
-initWithFrame:, and (2) even if we set the -enabled to NO, UIKit later resets it to YES in other codepaths.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/ios/WKScrollView.mm

index 212ea2d..8400a56 100644 (file)
@@ -1,3 +1,30 @@
+2018-02-02  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra Zoom Mode] Implement support for indirect mainframe scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=182421
+        <rdar://problem/35142694>
+
+        Reviewed by Tim Horton.
+
+        Makes a few small adjustments to WKScrollView to improve mainframe scrolling, and disable the pinch gesture for
+        zooming. See below for more details.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+
+        Remove a now-unneeded WebKitAdditions import.
+
+        * UIProcess/ios/WKScrollView.mm:
+        (-[WKScrollView initWithFrame:]):
+
+        Add imports for -Before and -After versions of WKScrollViewAdditions.
+
+        (-[WKScrollView addGestureRecognizer:]):
+
+        Override -addGestureRecognizer here to prevent touches on the pinch gesture recognizer from being recognized.
+        I chose this approach instead of just disabling the gesture in -initWithFrame: because (1) the pinch gesture
+        recognizer is lazily created when setting minimum or maximum zoom scales, rather than immediately in
+        -initWithFrame:, and (2) even if we set the -enabled to NO, UIKit later resets it to YES in other codepaths.
+
 2018-02-01  Tim Horton  <timothy_horton@apple.com>
 
         WebKit fails to build (_startAssistingNode has conflicting parameters)
index bda2338..a159c5c 100644 (file)
@@ -6340,8 +6340,4 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 
 @end
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebViewAdditionsAfter.mm>
-#endif
-
 #endif // WK_API_ENABLED
index 8138037..0ee82b0 100644 (file)
 
 using namespace WebKit;
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKScrollViewAdditionsBefore.mm>
+#endif
+
 @interface UIScrollView (UIScrollViewInternalHack)
 - (CGFloat)_rubberBandOffsetForOffset:(CGFloat)newOffset maxOffset:(CGFloat)maxOffset minOffset:(CGFloat)minOffset range:(CGFloat)range outside:(BOOL *)outside;
 @end
@@ -134,6 +138,10 @@ using namespace WebKit;
     _contentInsetAdjustmentBehaviorWasExternallyOverridden = (self.contentInsetAdjustmentBehavior != UIScrollViewContentInsetAdjustmentAutomatic);
 #endif
     
+#if ENABLE(EXTRA_ZOOM_MODE)
+    [self _configureScrollingForExtraZoomMode];
+#endif
+
     return self;
 }
 
@@ -311,6 +319,20 @@ static inline bool valuesAreWithinOnePixel(CGFloat a, CGFloat b)
         [self _restoreContentOffsetWithRubberbandAmount:rubberbandAmount];
 }
 
+- (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
+{
+    [super addGestureRecognizer:gestureRecognizer];
+
+#if ENABLE(EXTRA_ZOOM_MODE)
+    if (gestureRecognizer == self.pinchGestureRecognizer)
+        gestureRecognizer.allowedTouchTypes = @[];
+#endif
+}
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKScrollViewAdditionsAfter.mm>
+#endif
+
 @end
 
 #endif // PLATFORM(IOS)