Title: [209780] trunk
Revision
209780
Author
[email protected]
Date
2016-12-13 15:22:03 -0800 (Tue, 13 Dec 2016)

Log Message

:hover rule causes a single tap to not activate a slotted anchor element
https://bugs.webkit.org/show_bug.cgi?id=165551

Reviewed by Antti Koivisto.

Source/WebCore:

Fixed a bug in ancestorRespondingToClickEvents that we were traversing the ancestor nodes without taking
shadow roots and slots into account. This prevented tapping on a text node assigned to a slot inside
an anchor element to activate the hyperlink on iOS.

This bug was supposed to be fixed in r206605, and it was still broken on iOS due to the bug in
ancestorRespondingToClickEvents. It is now tested by click-text-inside-linked-slot.html.

Tests: fast/shadow-dom/click-on-slotted-anchor-with-hover.html
       fast/shadow-dom/click-text-inside-linked-slot.html

* page/ios/FrameIOS.mm:
(WebCore::ancestorRespondingToClickEvents):
(WebCore::Frame::qualifyingNodeAtViewportLocation):

LayoutTests:

Added a test for tapping on an anchor element assigned to a slot, which has been fixed in r209065.

Also added a new helper JS wrapepr, UIHelper, defined inside LayoutTests/resources/js-helper.js
to provide an abstraction around EventSender and UIScriptController.

Fixed click-text-inside-linked-slot.html on iOS using UIHelper.

* fast/shadow-dom/click-on-slotted-anchor-with-hover-expected.txt: Added.
* fast/shadow-dom/click-on-slotted-anchor-with-hover.html: Added.
* fast/shadow-dom/click-text-inside-linked-slot.html:
* platform/ios-simulator/fast/shadow-dom/click-text-inside-linked-slot-expected.txt: Added.
* resources/ui-helper.js: Added.
(window.UIHelper.isIOS):
(window.UIHelper.activateAt.return.new.Promise):
(window.UIHelper.activateAt):
(window.UIHelper.wait):
(window.UIHelper):
* platform/ios-simulator-wk2/TestExpectations: Skip the test in the open source iOS's WebKit2.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209779 => 209780)


--- trunk/LayoutTests/ChangeLog	2016-12-13 22:56:28 UTC (rev 209779)
+++ trunk/LayoutTests/ChangeLog	2016-12-13 23:22:03 UTC (rev 209780)
@@ -1,3 +1,29 @@
+2016-12-13  Ryosuke Niwa  <[email protected]>
+
+        :hover rule causes a single tap to not activate a slotted anchor element
+        https://bugs.webkit.org/show_bug.cgi?id=165551
+
+        Reviewed by Antti Koivisto.
+
+        Added a test for tapping on an anchor element assigned to a slot, which has been fixed in r209065.
+
+        Also added a new helper JS wrapepr, UIHelper, defined inside LayoutTests/resources/js-helper.js
+        to provide an abstraction around EventSender and UIScriptController.
+
+        Fixed click-text-inside-linked-slot.html on iOS using UIHelper.
+
+        * fast/shadow-dom/click-on-slotted-anchor-with-hover-expected.txt: Added.
+        * fast/shadow-dom/click-on-slotted-anchor-with-hover.html: Added.
+        * fast/shadow-dom/click-text-inside-linked-slot.html:
+        * platform/ios-simulator/fast/shadow-dom/click-text-inside-linked-slot-expected.txt: Added.
+        * resources/ui-helper.js: Added.
+        (window.UIHelper.isIOS):
+        (window.UIHelper.activateAt.return.new.Promise):
+        (window.UIHelper.activateAt):
+        (window.UIHelper.wait):
+        (window.UIHelper):
+        * platform/ios-simulator-wk2/TestExpectations: Skip the test in the open source iOS's WebKit2.
+
 2016-12-13  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Eliminate SVGPaint and SVGColor

Added: trunk/LayoutTests/fast/shadow-dom/click-on-slotted-anchor-with-hover-expected.txt (0 => 209780)


--- trunk/LayoutTests/fast/shadow-dom/click-on-slotted-anchor-with-hover-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/click-on-slotted-anchor-with-hover-expected.txt	2016-12-13 23:22:03 UTC (rev 209780)
@@ -0,0 +1,5 @@
+Tests for tapping or clicking on an anchor element assigned to a slot with :hover rule.
+Tapping on "Tap me" below exactly once should activate the hyperlink.
+
+Tap me
+PASS

Added: trunk/LayoutTests/fast/shadow-dom/click-on-slotted-anchor-with-hover.html (0 => 209780)


--- trunk/LayoutTests/fast/shadow-dom/click-on-slotted-anchor-with-hover.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/click-on-slotted-anchor-with-hover.html	2016-12-13 23:22:03 UTC (rev 209780)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Tests for tapping or clicking on an anchor element assigned to a slot with :hover rule.<br>
+Tapping on "Tap me" below exactly once should activate the hyperlink.</p>
+<div id="host"><a href="" _onclick_="activated();">Tap me</a></div>
+<div id="result">FAIL</div>
+<script src=""
+<script>
+
+let shadowHost = document.getElementById('host');
+shadowHost.attachShadow({mode: 'closed'}).innerHTML = '<slot></slot>';
+
+function activated() {
+    document.getElementById('result').textContent = 'PASS';
+}
+
+document._onclick_ = function () {
+    document.getElementById('result').style.display = null;
+}
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    UIHelper.wait(UIHelper.activateAt(shadowHost.offsetLeft + 5, shadowHost.offsetTop + 5));
+} else
+    document.getElementById('result').style.display = 'none';
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot.html (209779 => 209780)


--- trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot.html	2016-12-13 22:56:28 UTC (rev 209779)
+++ trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot.html	2016-12-13 23:22:03 UTC (rev 209780)
@@ -3,6 +3,7 @@
 <body>
 <p>This tests clicking on a Text node assigned to a slot inside an anchor element. The link should be activated.<br>
 To manually test, click "here" below and you should see "PASS" and the mouse cursor should indicate it's a hyperlink, not text:</p>
+<script src=""
 <script>
 
 var shadowHost = document.createElement('div');
@@ -24,9 +25,7 @@
     testRunner.dumpAsText();
     document.getElementById('activation').textContent = 'FAIL';
     document.write('<div>Cursor: <span id="cursor">FAIL<span></div>');
-    eventSender.mouseMoveTo(shadowHost.offsetLeft + 5, shadowHost.offsetTop + 5);
-    eventSender.mouseDown();
-    eventSender.mouseUp();
+    UIHelper.wait(UIHelper.activateAt(shadowHost.offsetLeft + 5, shadowHost.offsetTop + 5));
 }
 
 </script>

Added: trunk/LayoutTests/platform/ios-simulator/fast/shadow-dom/click-text-inside-linked-slot-expected.txt (0 => 209780)


--- trunk/LayoutTests/platform/ios-simulator/fast/shadow-dom/click-text-inside-linked-slot-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/shadow-dom/click-text-inside-linked-slot-expected.txt	2016-12-13 23:22:03 UTC (rev 209780)
@@ -0,0 +1,6 @@
+This tests clicking on a Text node assigned to a slot inside an anchor element. The link should be activated.
+To manually test, click "here" below and you should see "PASS" and the mouse cursor should indicate it's a hyperlink, not text:
+
+click here
+Activation: PASS
+Cursor: FAIL: Cursor details not available on this platform.

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (209779 => 209780)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-12-13 22:56:28 UTC (rev 209779)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-12-13 23:22:03 UTC (rev 209780)
@@ -1777,6 +1777,7 @@
 fast/loader/location-hash-user-gesture.html [ Skip ]
 imported/blink/editing/selection/selectstart-event-crash.html [ Skip ]
 fast/dom/Window/post-message-user-action.html [ Skip ]
+fast/shadow-dom/click-on-slotted-anchor-with-hover.html [ Skip ]
 fast/shadow-dom/click-text-inside-linked-slot.html [ Skip ]
 fast/shadow-dom/fullscreen-in-shadow-fullscreenElement.html
 fast/shadow-dom/fullscreen-in-shadow-webkitCurrentFullScreenElement.html

Added: trunk/LayoutTests/resources/ui-helper.js (0 => 209780)


--- trunk/LayoutTests/resources/ui-helper.js	                        (rev 0)
+++ trunk/LayoutTests/resources/ui-helper.js	2016-12-13 23:22:03 UTC (rev 209780)
@@ -0,0 +1,32 @@
+
+window.UIHelper = class UIHelper {
+    static isIOS()
+    {
+        return navigator.userAgent.includes('iPhone');
+    }
+
+    static activateAt(x, y)
+    {
+        if (!testRunner.runUIScript || !this.isIOS()) {
+            eventSender.mouseMoveTo(x, y);
+            eventSender.mouseDown();
+            eventSender.mouseUp();
+            return Promise.resolve();
+        }
+
+        return new Promise((resolve) => {
+            testRunner.runUIScript(`
+                uiController.singleTapAtPoint(${x}, ${y}, function() {
+                    uiController.uiScriptComplete('Done');
+                });`, resolve);
+        });
+    }
+
+    static wait(promise)
+    {
+        testRunner.waitUntilDone();
+        return promise.then(
+            function () { testRunner.notifyDone(); },
+            function (error) { testRunner.notifyDone(); return Promise.reject(error); });
+    }
+}

Modified: trunk/Source/WebCore/ChangeLog (209779 => 209780)


--- trunk/Source/WebCore/ChangeLog	2016-12-13 22:56:28 UTC (rev 209779)
+++ trunk/Source/WebCore/ChangeLog	2016-12-13 23:22:03 UTC (rev 209780)
@@ -1,3 +1,24 @@
+2016-12-13  Ryosuke Niwa  <[email protected]>
+
+        :hover rule causes a single tap to not activate a slotted anchor element
+        https://bugs.webkit.org/show_bug.cgi?id=165551
+
+        Reviewed by Antti Koivisto.
+
+        Fixed a bug in ancestorRespondingToClickEvents that we were traversing the ancestor nodes without taking
+        shadow roots and slots into account. This prevented tapping on a text node assigned to a slot inside
+        an anchor element to activate the hyperlink on iOS.
+
+        This bug was supposed to be fixed in r206605, and it was still broken on iOS due to the bug in
+        ancestorRespondingToClickEvents. It is now tested by click-text-inside-linked-slot.html.
+
+        Tests: fast/shadow-dom/click-on-slotted-anchor-with-hover.html
+               fast/shadow-dom/click-text-inside-linked-slot.html
+
+        * page/ios/FrameIOS.mm:
+        (WebCore::ancestorRespondingToClickEvents):
+        (WebCore::Frame::qualifyingNodeAtViewportLocation):
+
 2016-12-13  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Eliminate SVGPaint and SVGColor

Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (209779 => 209780)


--- trunk/Source/WebCore/page/ios/FrameIOS.mm	2016-12-13 22:56:28 UTC (rev 209779)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm	2016-12-13 23:22:03 UTC (rev 209780)
@@ -59,6 +59,7 @@
 #import "RenderTextControl.h"
 #import "RenderView.h"
 #import "RenderedDocumentMarker.h"
+#import "ShadowRoot.h"
 #import "TextBoundaries.h"
 #import "TextIterator.h"
 #import "VisiblePosition.h"
@@ -258,8 +259,8 @@
         *nodeBounds = IntRect();
 
     Node* pointerCursorNode = nullptr;
-    for (Node* node = hitTestResult.innerNode(); node && node != terminationNode; node = node->parentNode()) {
-        ASSERT(!node->isInShadowTree());
+    for (Node* node = hitTestResult.innerNode(); node && node != terminationNode; node = node->parentInComposedTree()) {
+        ASSERT(!node->isInShadowTree() || node->containingShadowRoot()->mode() != ShadowRootMode::UserAgent);
 
         // We only accept pointer nodes before reaching the body tag.
         if (node->hasTagName(HTMLNames::bodyTag)) {
@@ -405,7 +406,7 @@
         Node* failedNode = candidate;
 
         while (candidate && !candidate->isElementNode())
-            candidate = candidate->parentNode();
+            candidate = candidate->parentInComposedTree();
 
         if (candidate)
             failedNode = candidate;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to