Title: [191072] trunk
- Revision
- 191072
- Author
- wenson_hs...@apple.com
- Date
- 2015-10-14 14:20:50 -0700 (Wed, 14 Oct 2015)
Log Message
Web pages with unscalable viewports shouldn't have a single tap delay
https://bugs.webkit.org/show_bug.cgi?id=149968
<rdar://problem/23054453>
Reviewed by Simon Fraser.
Source/WebKit2:
When a viewport is unscalable (specified through the meta viewport tag) we
do not add a delay to our single tap gesture recognizer. We do this by
disabling or reinitializing the WKContentView's double tap gesture recognizer
when the viewport becomes unscalable or scalable, respectively. A viewport is
deemed unscalable when it has user-scalable = no, or when the minimum scale is
greater than or equal to the maximum scale.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLayerTree:]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]): Pulled logic
for initializing a double tap gesture recognizer out into a helper function.
(-[WKContentView setupInteraction]):
(-[WKContentView _setDoubleTapGesturesEnabled:]): Turns gesture recognition for double
taps on or off.
LayoutTests:
Add a layout test to check that when a viewport is unscalable (specified through
the meta viewport tag) we do not add a delay to our single tap gesture recognizer.
* fast/events/ios/unscalable-viewport-clicks-on-doubletap-expected.txt: Added.
* fast/events/ios/unscalable-viewport-clicks-on-doubletap.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (191071 => 191072)
--- trunk/LayoutTests/ChangeLog 2015-10-14 21:03:05 UTC (rev 191071)
+++ trunk/LayoutTests/ChangeLog 2015-10-14 21:20:50 UTC (rev 191072)
@@ -1,3 +1,17 @@
+2015-10-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Web pages with unscalable viewports shouldn't have a single tap delay
+ https://bugs.webkit.org/show_bug.cgi?id=149968
+ <rdar://problem/23054453>
+
+ Reviewed by Simon Fraser.
+
+ Add a layout test to check that when a viewport is unscalable (specified through
+ the meta viewport tag) we do not add a delay to our single tap gesture recognizer.
+
+ * fast/events/ios/unscalable-viewport-clicks-on-doubletap-expected.txt: Added.
+ * fast/events/ios/unscalable-viewport-clicks-on-doubletap.html: Added.
+
2015-10-14 Jiewen Tan <jiewen_...@apple.com>
Postpone mutation events before invoke Editor::Command command(Document*, const String&, bool).
Added: trunk/LayoutTests/fast/events/ios/unscalable-viewport-clicks-on-doubletap-expected.txt (0 => 191072)
--- trunk/LayoutTests/fast/events/ios/unscalable-viewport-clicks-on-doubletap-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/ios/unscalable-viewport-clicks-on-doubletap-expected.txt 2015-10-14 21:20:50 UTC (rev 191072)
@@ -0,0 +1,5 @@
+
+Double tapping on the button should fire 2 click events.
+Click!
+Click!
+
Added: trunk/LayoutTests/fast/events/ios/unscalable-viewport-clicks-on-doubletap.html (0 => 191072)
--- trunk/LayoutTests/fast/events/ios/unscalable-viewport-clicks-on-doubletap.html (rev 0)
+++ trunk/LayoutTests/fast/events/ios/unscalable-viewport-clicks-on-doubletap.html 2015-10-14 21:20:50 UTC (rev 191072)
@@ -0,0 +1,55 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<meta id="viewport-data" name="viewport" content="user-scalable=no, initial-scale=1.0">
+
+<head>
+ <script id="ui-script" type="text/plain">
+ (function() {
+ uiController.doubleTapAtPoint(50, 50, function() {});
+ })();
+ </script>
+
+ <script>
+ var clickCount = 0;
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function getUIScript() {
+ return document.getElementById("ui-script").text;
+ }
+
+ function runTest() {
+ if (testRunner.runUIScript) {
+ testRunner.runUIScript(getUIScript(), function(result) {});
+ }
+ }
+ function handleClicked() {
+ clickCount++;
+ document.body.appendChild(document.createTextNode("Click!"));
+ document.body.appendChild(document.createElement("br"));
+ if (clickCount == 2)
+ testRunner.notifyDone();
+ }
+ </script>
+
+ <style>
+ body {
+ margin: 0;
+ }
+
+ #target {
+ width: 100px;
+ height: 100px;
+ }
+ </style>
+</head>
+
+<body _onload_="runTest()">
+ <button id="target" _onclick_="handleClicked()"></button>
+ <div>Double tapping on the button should fire 2 click events.</div>
+</body>
+
+</html>
Modified: trunk/Source/WebKit2/ChangeLog (191071 => 191072)
--- trunk/Source/WebKit2/ChangeLog 2015-10-14 21:03:05 UTC (rev 191071)
+++ trunk/Source/WebKit2/ChangeLog 2015-10-14 21:20:50 UTC (rev 191072)
@@ -1,3 +1,28 @@
+2015-10-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Web pages with unscalable viewports shouldn't have a single tap delay
+ https://bugs.webkit.org/show_bug.cgi?id=149968
+ <rdar://problem/23054453>
+
+ Reviewed by Simon Fraser.
+
+ When a viewport is unscalable (specified through the meta viewport tag) we
+ do not add a delay to our single tap gesture recognizer. We do this by
+ disabling or reinitializing the WKContentView's double tap gesture recognizer
+ when the viewport becomes unscalable or scalable, respectively. A viewport is
+ deemed unscalable when it has user-scalable = no, or when the minimum scale is
+ greater than or equal to the maximum scale.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _didCommitLayerTree:]):
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]): Pulled logic
+ for initializing a double tap gesture recognizer out into a helper function.
+ (-[WKContentView setupInteraction]):
+ (-[WKContentView _setDoubleTapGesturesEnabled:]): Turns gesture recognition for double
+ taps on or off.
+
2015-10-14 Anders Carlsson <ander...@apple.com>
Remove a message that isn't used by anyone
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (191071 => 191072)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-10-14 21:03:05 UTC (rev 191071)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-10-14 21:20:50 UTC (rev 191072)
@@ -1006,6 +1006,8 @@
if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing] && ![_scrollView _isAnimatingZoom])
[_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
+ [_contentView _setDoubleTapGesturesEnabled:[_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale]];
+
[self _updateScrollViewBackground];
if (_gestureController)
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (191071 => 191072)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2015-10-14 21:03:05 UTC (rev 191071)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2015-10-14 21:20:50 UTC (rev 191072)
@@ -203,6 +203,7 @@
- (void)_enableInspectorNodeSearch;
- (void)_disableInspectorNodeSearch;
- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler;
+- (void)_setDoubleTapGesturesEnabled:(BOOL)enabled;
@end
#if HAVE(LINK_PREVIEW)
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (191071 => 191072)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2015-10-14 21:03:05 UTC (rev 191071)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2015-10-14 21:20:50 UTC (rev 191072)
@@ -296,6 +296,15 @@
return UIWebSelectionModeWeb;
}
+- (void)_createAndConfigureDoubleTapGestureRecognizer
+{
+ _doubleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_doubleTapRecognized:)]);
+ [_doubleTapGestureRecognizer setNumberOfTapsRequired:2];
+ [_doubleTapGestureRecognizer setDelegate:self];
+ [self addGestureRecognizer:_doubleTapGestureRecognizer.get()];
+ [_singleTapGestureRecognizer requireOtherGestureToFail:_doubleTapGestureRecognizer.get()];
+}
+
- (void)setupInteraction
{
if (!_interactionViewsContainerView) {
@@ -319,11 +328,7 @@
[_singleTapGestureRecognizer setResetTarget:self action:@selector(_singleTapDidReset:)];
[self addGestureRecognizer:_singleTapGestureRecognizer.get()];
- _doubleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_doubleTapRecognized:)]);
- [_doubleTapGestureRecognizer setNumberOfTapsRequired:2];
- [_doubleTapGestureRecognizer setDelegate:self];
- [self addGestureRecognizer:_doubleTapGestureRecognizer.get()];
- [_singleTapGestureRecognizer requireOtherGestureToFail:_doubleTapGestureRecognizer.get()];
+ [self _createAndConfigureDoubleTapGestureRecognizer];
_twoFingerDoubleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_twoFingerDoubleTapRecognized:)]);
[_twoFingerDoubleTapGestureRecognizer setNumberOfTapsRequired:2];
@@ -2239,6 +2244,18 @@
});
}
+- (void)_setDoubleTapGesturesEnabled:(BOOL)enabled
+{
+ if (enabled && ![_doubleTapGestureRecognizer isEnabled]) {
+ // The first tap recognized after re-enabling double tap gestures will not wait for the
+ // second tap before committing. To fix this, we use a new double tap gesture recognizer.
+ [self removeGestureRecognizer:_doubleTapGestureRecognizer.get()];
+ [_doubleTapGestureRecognizer setDelegate:nil];
+ [self _createAndConfigureDoubleTapGestureRecognizer];
+ }
+ [_doubleTapGestureRecognizer setEnabled:enabled];
+}
+
- (void)accessoryAutoFill
{
id <_WKFormDelegate> formDelegate = [_webView _formDelegate];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes