Provide an option for an always-on fast click mode in iOS
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2019 22:06:42 +0000 (22:06 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2019 22:06:42 +0000 (22:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195822
<rdar://problem/48939357>

Reviewed by Sam Weinig.

Source/WebKit:

Add an option that will always trigger a click and never
wait for a double tap to zoom. It is disabled by default.

* Shared/WebPreferences.yaml:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _handleSmartMagnificationInformationForPotentialTap:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):

LayoutTests:

New test for "always fast click" mode.

* fast/events/ios/ipad/fast-click-always-expected.txt: Added.
* fast/events/ios/ipad/fast-click-always.html: Copied from LayoutTests/fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html.
* fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/events/ios/ipad/fast-click-always-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/ipad/fast-click-always.html [new file with mode: 0644]
LayoutTests/fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 26ef99d..9b8d86f 100644 (file)
@@ -1,3 +1,17 @@
+2019-03-15  Dean Jackson  <dino@apple.com>
+
+        Provide an option for an always-on fast click mode in iOS
+        https://bugs.webkit.org/show_bug.cgi?id=195822
+        <rdar://problem/48939357>
+
+        Reviewed by Sam Weinig.
+
+        New test for "always fast click" mode.
+
+        * fast/events/ios/ipad/fast-click-always-expected.txt: Added.
+        * fast/events/ios/ipad/fast-click-always.html: Copied from LayoutTests/fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html.
+        * fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html:
+
 2019-03-15  Jer Noble  <jer.noble@apple.com>
 
         Add a "supportedConfiguration" dictionary to MediaCapabilitiesDecodingInfo and MediaCapabilitiesEncodingInfo
diff --git a/LayoutTests/fast/events/ios/ipad/fast-click-always-expected.txt b/LayoutTests/fast/events/ios/ipad/fast-click-always-expected.txt
new file mode 100644 (file)
index 0000000..5e17f44
--- /dev/null
@@ -0,0 +1,2 @@
+PASS: Click fired on element with handler.
+This document doesn't have fast clicks because it sets a viewport width. It has a significant zoom since the viewport width is significantly bigger than the body width. However, it sets fast click everywhere to on, so double tapping on the rectangle above should send a click event.
diff --git a/LayoutTests/fast/events/ios/ipad/fast-click-always.html b/LayoutTests/fast/events/ios/ipad/fast-click-always.html
new file mode 100644 (file)
index 0000000..52e2819
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:FastClicksEverywhere=true ] -->
+
+<html>
+<meta name="viewport" content="width=800">
+<head>
+    <style>
+        body {
+            font-family: system-ui;
+            line-height: 1.4;
+            padding: 10px 10px;
+            width: 500px;
+            margin: 0;
+        }
+    </style>
+    <script src="../../../../resources/ui-helper.js"></script>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        async function runTest()
+        {
+            document.getElementById("target").addEventListener("click", handleClick, false);
+
+            if (!window.testRunner)
+                return;
+            await UIHelper.humanSpeedDoubleTapAt(30, 30);
+        }
+
+        function handleClick(event)
+        {
+            document.getElementById("target").textContent = "PASS: Click fired on element with handler.";
+            testRunner.notifyDone();
+        }
+    </script>
+    <style>
+        body {
+            margin: 0;
+        }
+        #target {
+            height: 100px;
+            width: 100px;
+            background-color: silver;
+        }
+    </style>
+</head>
+<body onload="runTest()">
+<div id="target"></div>
+<div id="description">This document doesn't have fast clicks because
+    it sets a viewport width. It has a significant zoom since the viewport
+    width is significantly bigger than the body width. However, it sets fast click everywhere to
+    on, so double tapping on the rectangle above should send a click event.</div>
+</body>
+</html>
index d34c22f..f642517 100644 (file)
@@ -12,7 +12,7 @@
             margin: 0;
         }
     </style>
-    <script src="../../../resources/ui-helper.js"></script>
+    <script src="../../../../resources/ui-helper.js"></script>
     <script>
         if (window.testRunner) {
             testRunner.dumpAsText();
index f229607..7a3b236 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-15  Dean Jackson  <dino@apple.com>
+
+        Provide an option for an always-on fast click mode in iOS
+        https://bugs.webkit.org/show_bug.cgi?id=195822
+        <rdar://problem/48939357>
+
+        Reviewed by Sam Weinig.
+
+        Add an option that will always trigger a click and never
+        wait for a double tap to zoom. It is disabled by default.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):
+
 2019-03-15  Timothy Hatcher  <timothy@apple.com>
 
         Add support to WebPage for getting the contents as an attributed string.
index 1245185..1689876 100644 (file)
@@ -1486,6 +1486,15 @@ FasterClicksEnabled:
   webcoreBinding: none
   category: internal
 
+FastClicksEverywhere:
+  type: bool
+  defaultValue: false
+  condition: PLATFORM(IOS_FAMILY)
+  humanReadableName: "Fast clicks everywhere"
+  humanReadableDescription: "Force fast clicks on all pages"
+  webcoreBinding: none
+  category: internal
+
 InputTypeColorEnabled:
   type: bool
   defaultValue: DEFAULT_INPUT_TYPE_COLOR_ENABLED
index cbfcc92..30b9600 100644 (file)
@@ -1505,6 +1505,12 @@ static NSValue *nsSizeForTapHighlightBorderRadius(WebCore::IntSize borderRadius,
     if (!_potentialTapInProgress)
         return;
 
+    if (_page->preferences().fastClicksEverywhere()) {
+        RELEASE_LOG(ViewGestures, "Potential tap found an element and fast taps are forced on. Trigger click. (%p)", self);
+        [self _setDoubleTapGesturesEnabled:NO];
+        return;
+    }
+
     auto targetScale = _smartMagnificationController->zoomFactorForTargetRect(renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale);
 
     auto initialScale = [self _initialScaleFactor];