[iOS] Do not get stuck in indeterminate content observation state.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2018 05:46:48 +0000 (05:46 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2018 05:46:48 +0000 (05:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191719

Reviewed by Simon Fraser.

Source/WebCore:

Reset the _WKContentChange flag to WKContentNoChange when the last observing timer is removed and we are in
the "can't decide yet if it's a hover or click" state.
This bug prevents us from firing click event when JS installs and removes the same set of timer(s) during mouse-move dispatch.

Test: fast/events/touch/ios/stuck-with-hover-state.html

* platform/ios/wak/WKContentObservation.cpp:
(WebThreadRemoveObservedContentModifier):

LayoutTests:

* fast/events/touch/ios/stuck-with-hover-state-expected.txt: Added.
* fast/events/touch/ios/stuck-with-hover-state.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/stuck-with-hover-state-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/stuck-with-hover-state.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ios/wak/WKContentObservation.cpp

index e996394..1ea555c 100644 (file)
@@ -1,3 +1,13 @@
+2018-11-15  Zalan Bujtas  <zalan@apple.com>
+
+        [iOS] Do not get stuck in indeterminate content observation state.
+        https://bugs.webkit.org/show_bug.cgi?id=191719
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/touch/ios/stuck-with-hover-state-expected.txt: Added.
+        * fast/events/touch/ios/stuck-with-hover-state.html: Added.
+
 2018-11-15  Simon Fraser  <simon.fraser@apple.com>
 
         Add layout test for iframe contents disappearing on view unparent/reparent
diff --git a/LayoutTests/fast/events/touch/ios/stuck-with-hover-state-expected.txt b/LayoutTests/fast/events/touch/ios/stuck-with-hover-state-expected.txt
new file mode 100644 (file)
index 0000000..65fae53
--- /dev/null
@@ -0,0 +1,2 @@
+PASS if clicked.
+clicked
diff --git a/LayoutTests/fast/events/touch/ios/stuck-with-hover-state.html b/LayoutTests/fast/events/touch/ios/stuck-with-hover-state.html
new file mode 100644 (file)
index 0000000..47d0d8d
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+<head>
+<title>This test that we trigger click when hover would not display non-clickable content.</title>
+<script src="../../../../resources/basic-gestures.js"></script>
+<style>
+#tapthis {
+    width: 400px;
+    height: 400px;
+    border: 1px solid green;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    let rect = tapthis.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+       await tapAtPoint(x, y);
+
+    testRunner.notifyDone();
+}
+</script>
+</head>
+<body onload="test()">
+<div id=tapthis>PASS if clicked.</div>
+<pre id=result></pre>
+<script>
+tapthis.addEventListener("mouseover", function( event ) {
+       clearTimeout(setTimeout(function() { tapthis.innerHTML = "should not see this"; }, 50));
+}, false);
+
+tapthis.addEventListener("click", function( event ) {   
+       result.innerHTML = "clicked";
+}, false);
+</script>
+</body>
+</html>
index 59207c1..6378519 100644 (file)
@@ -1,3 +1,19 @@
+2018-11-15  Zalan Bujtas  <zalan@apple.com>
+
+        [iOS] Do not get stuck in indeterminate content observation state.
+        https://bugs.webkit.org/show_bug.cgi?id=191719
+
+        Reviewed by Simon Fraser.
+
+        Reset the _WKContentChange flag to WKContentNoChange when the last observing timer is removed and we are in
+        the "can't decide yet if it's a hover or click" state.
+        This bug prevents us from firing click event when JS installs and removes the same set of timer(s) during mouse-move dispatch.
+
+        Test: fast/events/touch/ios/stuck-with-hover-state.html
+
+        * platform/ios/wak/WKContentObservation.cpp:
+        (WebThreadRemoveObservedContentModifier):
+
 2018-11-15  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r238090) Composited iframes that resize from zero don't show
index 35ab2ec..4369000 100644 (file)
@@ -106,6 +106,12 @@ void WebThreadAddObservedContentModifier(void * aContentModifier)
 void WebThreadRemoveObservedContentModifier(void * aContentModifier)
 {
     WebThreadGetObservedContentModifiers()->remove(aContentModifier);
+    // Force reset the content change flag when the last observed content modifier is removed. We should not be in indeterminate state anymore.
+    if (WebThreadCountOfObservedContentModifiers())
+        return;
+    if (WKObservedContentChange() != WKContentIndeterminateChange)
+        return;
+    _WKContentChange = WKContentNoChange;
 }
 
 #endif // PLATFORM(IOS_FAMILY)