Title: [206605] trunk
Revision
206605
Author
[email protected]
Date
2016-09-29 12:49:54 -0700 (Thu, 29 Sep 2016)

Log Message

Text nodes assigned to a linked slot are not clickable
https://bugs.webkit.org/show_bug.cgi?id=162091
<rdar://problem/28383300>

Reviewed by Antti Koivisto.

Source/WebCore:

The bug was caused by updateMouseEventTargetNode adjusting the target to its parent element when
the original target was a text node. Fixed the bug by using the parent element in the composed tree.

Also fixed the bug that the hit testing was not finding the anchor element and keeping the cursor
in I-beam by traversing the composed tree instead.

Test: fast/shadow-dom/click-text-inside-linked-slot.html

* dom/Node.cpp:
(WebCore::Node::enclosingLinkEventParentOrSelf): Fixed the cursor problem.
* page/EventHandler.cpp:
(WebCore::EventHandler::updateMouseEventTargetNode): Fixed the activation problem.

LayoutTests:

Added a regression test for clicking inside a text node assigned to a slot inside a hyperlink.

Unfortunately, there is not a way to make this a W3C style test until the web platform tests
start supporting WebDriver.

* fast/shadow-dom/click-text-inside-linked-slot-expected.txt: Added.
* fast/shadow-dom/click-text-inside-linked-slot.html: Added.
* platform/ios-simulator-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206604 => 206605)


--- trunk/LayoutTests/ChangeLog	2016-09-29 19:48:25 UTC (rev 206604)
+++ trunk/LayoutTests/ChangeLog	2016-09-29 19:49:54 UTC (rev 206605)
@@ -1,3 +1,20 @@
+2016-09-28  Ryosuke Niwa  <[email protected]>
+
+        Text nodes assigned to a linked slot are not clickable
+        https://bugs.webkit.org/show_bug.cgi?id=162091
+        <rdar://problem/28383300>
+
+        Reviewed by Antti Koivisto.
+
+        Added a regression test for clicking inside a text node assigned to a slot inside a hyperlink.
+
+        Unfortunately, there is not a way to make this a W3C style test until the web platform tests
+        start supporting WebDriver.
+
+        * fast/shadow-dom/click-text-inside-linked-slot-expected.txt: Added.
+        * fast/shadow-dom/click-text-inside-linked-slot.html: Added.
+        * platform/ios-simulator-wk2/TestExpectations:
+
 2016-09-29  Ryan Haddad  <[email protected]>
 
         Marking fast/images/load-img-with-empty-src.html as crashing.

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


--- trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot-expected.txt	2016-09-29 19:49:54 UTC (rev 206605)
@@ -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: type=Hand hotSpot=0,0

Added: trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot.html (0 => 206605)


--- trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/click-text-inside-linked-slot.html	2016-09-29 19:49:54 UTC (rev 206605)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<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>
+
+var shadowHost = document.createElement('div');
+document.body.appendChild(shadowHost);
+
+shadowHost.innerHTML = `click here`;
+var shadowRoot = shadowHost.attachShadow({mode: 'closed'});
+shadowRoot.innerHTML = `<a href=""
+
+document.write('<div>Activation: <span id="activation"><span></div>');
+
+function activated() {
+    document.getElementById('activation').textContent = 'PASS';
+    if (window.internals)
+        document.getElementById('cursor').textContent = internals.getCurrentCursorInfo();
+}
+
+if (window.internals) {
+    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();
+}
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (206604 => 206605)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-09-29 19:48:25 UTC (rev 206604)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-09-29 19:49:54 UTC (rev 206605)
@@ -1765,6 +1765,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-text-inside-linked-slot.html [ Skip ]
 
 # No touch events
 http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (206604 => 206605)


--- trunk/Source/WebCore/ChangeLog	2016-09-29 19:48:25 UTC (rev 206604)
+++ trunk/Source/WebCore/ChangeLog	2016-09-29 19:49:54 UTC (rev 206605)
@@ -1,3 +1,24 @@
+2016-09-28  Ryosuke Niwa  <[email protected]>
+
+        Text nodes assigned to a linked slot are not clickable
+        https://bugs.webkit.org/show_bug.cgi?id=162091
+        <rdar://problem/28383300>
+
+        Reviewed by Antti Koivisto.
+
+        The bug was caused by updateMouseEventTargetNode adjusting the target to its parent element when
+        the original target was a text node. Fixed the bug by using the parent element in the composed tree.
+
+        Also fixed the bug that the hit testing was not finding the anchor element and keeping the cursor
+        in I-beam by traversing the composed tree instead.
+
+        Test: fast/shadow-dom/click-text-inside-linked-slot.html
+
+        * dom/Node.cpp:
+        (WebCore::Node::enclosingLinkEventParentOrSelf): Fixed the cursor problem.
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::updateMouseEventTargetNode): Fixed the activation problem.
+
 2016-09-29  Sam Weinig  <[email protected]>
 
         Allow overriding some NSURLSessionConfiguration properties on a per-NetworkProcess basis

Modified: trunk/Source/WebCore/dom/Node.cpp (206604 => 206605)


--- trunk/Source/WebCore/dom/Node.cpp	2016-09-29 19:48:25 UTC (rev 206604)
+++ trunk/Source/WebCore/dom/Node.cpp	2016-09-29 19:49:54 UTC (rev 206605)
@@ -1842,7 +1842,7 @@
 
 Element* Node::enclosingLinkEventParentOrSelf()
 {
-    for (Node* node = this; node; node = node->parentOrShadowHostNode()) {
+    for (Node* node = this; node; node = node->parentInComposedTree()) {
         // For imagemaps, the enclosing link element is the associated area element not the image itself.
         // So we don't let images be the enclosing link element, even though isLink sometimes returns
         // true for them.

Modified: trunk/Source/WebCore/page/EventHandler.cpp (206604 => 206605)


--- trunk/Source/WebCore/page/EventHandler.cpp	2016-09-29 19:48:25 UTC (rev 206604)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2016-09-29 19:49:54 UTC (rev 206605)
@@ -2362,10 +2362,9 @@
         targetElement = m_capturingMouseEventsElement.get();
     else if (targetNode) {
         // If the target node is a non-element, dispatch on the parent. <rdar://problem/4196646>
-        if (!is<Element>(*targetNode))
-            targetElement = targetNode->parentOrShadowHostElement();
-        else
-            targetElement = downcast<Element>(targetNode);
+        while (targetNode && !is<Element>(*targetNode))
+            targetNode = targetNode->parentInComposedTree();
+        targetElement = downcast<Element>(targetNode);
     }
 
     m_elementUnderMouse = targetElement;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to