[ContentChangeObserver] Taping on a form control should always result in click.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Mar 2019 21:07:51 +0000 (21:07 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Mar 2019 21:07:51 +0000 (21:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196177

Reviewed by Simon Fraser.

Source/WebKit:

This patch enures that we send a synthetic click when the traget node is a form control (button, edit field etc) even if
the mousemove brings up some hover content.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleSyntheticClick):

LayoutTests:

* fast/events/touch/ios/content-observation/tap-on-input-type-button-element-expected.txt: Added.
* fast/events/touch/ios/content-observation/tap-on-input-type-button-element.html: Added.
* fast/events/touch/ios/content-observation/tap-on-input-type-text-element-expected.txt: Added.
* fast/events/touch/ios/content-observation/tap-on-input-type-text-element.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-button-element-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-button-element.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-text-element-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-text-element.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index db6dd4e..f7d5b9c 100644 (file)
@@ -1,5 +1,17 @@
 2019-03-23  Zalan Bujtas  <zalan@apple.com>
 
+        [ContentChangeObserver] Taping on a form control should always result in click.
+        https://bugs.webkit.org/show_bug.cgi?id=196177
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/touch/ios/content-observation/tap-on-input-type-button-element-expected.txt: Added.
+        * fast/events/touch/ios/content-observation/tap-on-input-type-button-element.html: Added.
+        * fast/events/touch/ios/content-observation/tap-on-input-type-text-element-expected.txt: Added.
+        * fast/events/touch/ios/content-observation/tap-on-input-type-text-element.html: Added.
+
+2019-03-23  Zalan Bujtas  <zalan@apple.com>
+
         [ContentChangeObserver] Add support for observing opacity.
         https://bugs.webkit.org/show_bug.cgi?id=196172
 
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-button-element-expected.txt b/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-button-element-expected.txt
new file mode 100644 (file)
index 0000000..31954a3
--- /dev/null
@@ -0,0 +1,3 @@
+PASS if 'clicked' text is shown below.
+
+clicked
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-button-element.html b/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-button-element.html
new file mode 100644 (file)
index 0000000..4167a5b
--- /dev/null
@@ -0,0 +1,54 @@
+<html>
+<head>
+<title>This tests the case when the tap target node is a form control element.</title>
+<script src="../../../../../resources/basic-gestures.js"></script>
+<style>
+#becomesVisible {
+    visibility: hidden;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+       transition-property: opacity, left;
+       transition-duration: 100ms, 200ms;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+    if (window.internals)
+        internals.settings.setContentChangeObserverEnabled(true);
+
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+
+    let rect = tapthis.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+    await tapAtPoint(x, y);
+}
+</script>
+</head>
+<body onload="test()">
+PASS if 'clicked' text is shown below.<br>
+<input type="button" value="tap this button" id=tapthis>
+<div id=becomesVisible></div>
+<pre id=result></pre>
+<script>
+tapthis.addEventListener("mousemove", function( event ) {
+    becomesVisible.style.visibility = "visible";
+}, false);
+
+becomesVisible.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked hidden";
+}, false);
+
+tapthis.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, false);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-text-element-expected.txt b/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-text-element-expected.txt
new file mode 100644 (file)
index 0000000..31954a3
--- /dev/null
@@ -0,0 +1,3 @@
+PASS if 'clicked' text is shown below.
+
+clicked
diff --git a/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-text-element.html b/LayoutTests/fast/events/touch/ios/content-observation/tap-on-input-type-text-element.html
new file mode 100644 (file)
index 0000000..c765f65
--- /dev/null
@@ -0,0 +1,54 @@
+<html>
+<head>
+<title>This tests the case when the tap target node is a text field element.</title>
+<script src="../../../../../resources/basic-gestures.js"></script>
+<style>
+#becomesVisible {
+    visibility: hidden;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+       transition-property: opacity, left;
+       transition-duration: 100ms, 200ms;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+    if (window.internals)
+        internals.settings.setContentChangeObserverEnabled(true);
+
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+
+    let rect = tapthis.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+    await tapAtPoint(x, y);
+}
+</script>
+</head>
+<body onload="test()">
+PASS if 'clicked' text is shown below.<br>
+<input type="text" value="tap this edit field" id=tapthis>
+<div id=becomesVisible></div>
+<pre id=result></pre>
+<script>
+tapthis.addEventListener("mousemove", function( event ) {
+    becomesVisible.style.visibility = "visible";
+}, false);
+
+becomesVisible.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked hidden";
+}, false);
+
+tapthis.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, false);
+</script>
+</body>
+</html>
index e396fa3..90d9add 100644 (file)
@@ -1,3 +1,16 @@
+2019-03-23  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Taping on a form control should always result in click.
+        https://bugs.webkit.org/show_bug.cgi?id=196177
+
+        Reviewed by Simon Fraser.
+
+        This patch enures that we send a synthetic click when the traget node is a form control (button, edit field etc) even if
+        the mousemove brings up some hover content.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleSyntheticClick):
+
 2019-03-23  Andy Estes  <aestes@apple.com>
 
         [Apple Pay] Stop calling PKPaymentAuthorizationViewController class methods on iOS
index bf7bcc6..0dd509d 100644 (file)
@@ -579,6 +579,11 @@ void WebPage::handleSyntheticClick(Node& nodeRespondingToClick, const WebCore::F
     if (m_isClosed)
         return;
 
+    if (is<HTMLFormControlElement>(nodeRespondingToClick)) {
+        LOG(ContentObservation, "handleSyntheticClick: Target node is a form control -> click.");
+        completeSyntheticClick(nodeRespondingToClick, location, modifiers, WebCore::OneFingerTap);
+        return;
+    }
     auto& contentChangeObserver = respondingDocument.contentChangeObserver();
     auto observedContentChange = contentChangeObserver.observedContentChange();
     if (observedContentChange == WKContentVisibilityChange) {