Title: [201292] trunk
Revision
201292
Author
ryanhad...@apple.com
Date
2016-05-23 13:25:03 -0700 (Mon, 23 May 2016)

Log Message

Unreviewed, rolling out r200414.

This change appears to have broken the 'write a reply' field
on Nextdoor.com

Reverted changeset:

"Clicks inside button elements are sometimes discarded when
the mouse moves"
https://bugs.webkit.org/show_bug.cgi?id=39620
http://trac.webkit.org/changeset/200414

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (201291 => 201292)


--- trunk/LayoutTests/ChangeLog	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/LayoutTests/ChangeLog	2016-05-23 20:25:03 UTC (rev 201292)
@@ -1,5 +1,19 @@
 2016-05-23  Ryan Haddad  <ryanhad...@apple.com>
 
+        Unreviewed, rolling out r200414.
+
+        This change appears to have broken the 'write a reply' field
+        on Nextdoor.com
+
+        Reverted changeset:
+
+        "Clicks inside button elements are sometimes discarded when
+        the mouse moves"
+        https://bugs.webkit.org/show_bug.cgi?id=39620
+        http://trac.webkit.org/changeset/200414
+
+2016-05-23  Ryan Haddad  <ryanhad...@apple.com>
+
         Marking fast/text-autosizing/ios/text-autosizing-after-back.html as a flaky timeout on Mac and iOS
         https://bugs.webkit.org/show_bug.cgi?id=157589
 

Deleted: trunk/LayoutTests/fast/events/click-over-descendant-elements-expected.txt (201291 => 201292)


--- trunk/LayoutTests/fast/events/click-over-descendant-elements-expected.txt	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/LayoutTests/fast/events/click-over-descendant-elements-expected.txt	2016-05-23 20:25:03 UTC (rev 201292)
@@ -1,27 +0,0 @@
-Check if any mousedown-mouseup pairs in one element dispatch click events.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Very normal click on container:
-PASS lastClickTarget is container
-Move inside container:
-PASS lastClickTarget is container
-Move from container to a child:
-PASS lastClickTarget is container
-Move from a child to container:
-PASS lastClickTarget is container
-Move from a child to another child:
-PASS lastClickTarget is container
-Move out from a child:
-PASS lastClickTarget is document.body
-Removing a child element in the light DOM during a click:
-FAIL lastClickTarget should be null. Was [object HTMLDivElement].
-Click on escaping button content:
-PASS lastClickTarget is button1
-Click on disappearing INPUT value:
-PASS lastClickTarget is input1
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/fast/events/click-over-descendant-elements.html (201291 => 201292)


--- trunk/LayoutTests/fast/events/click-over-descendant-elements.html	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/LayoutTests/fast/events/click-over-descendant-elements.html	2016-05-23 20:25:03 UTC (rev 201292)
@@ -1,144 +0,0 @@
-<!DOCTYPE html>
-<body>
-<script src=""
-<style>
-body {
-    margin: 0;
-    padding: 0;
-    -webkit-user-select: none;
-}
-
-#container {
-    padding: 40px;
-}
-
-#inner1, #inner2 {
-    height: 40px;
-}
-
-#button1 {
-    padding-top: 4px;
-}
-#button1:active {
-    padding-top: 40px;
-}
-</style>
-<div id="container">
-<div id="inner1"></div>
-<div id="inner2"></div>
-</div>
-<button id="button1"><span id="button-span">Click me</span></button>
-<input id="input1" value="A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.">
-<!-- Avoid to create a console element before the above elements -->
-<div id="console"></div>
-<script>
-description('Check if any mousedown-mouseup pairs in one element dispatch click events.');
-if (!window.eventSender)
-    debug('This test needs to run in a test environment.');
-
-var container = document.getElementById('container');
-var containerRect = container.getBoundingClientRect();
-var inner1 = document.getElementById('inner1');
-var inner1Rect = inner1.getBoundingClientRect();
-var inner2 = document.getElementById('inner2');
-var inner2Rect = inner2.getBoundingClientRect();
-var x = (containerRect.left + containerRect.right) / 2;
-var inContainer = (containerRect.top + inner1Rect.top) / 2;
-var inInner1 = (inner1Rect.top + inner1Rect.bottom) / 2;
-var inInner2 = (inner2Rect.top + inner2Rect.bottom) / 2;
-
-var lastClickTarget = null;
-document.addEventListener('click', function(event) {
-    lastClickTarget = event.target;
-}, false);
-
-function clearClick()
-{
-    eventSender.mouseMoveTo(0, 0);
-    eventSender.mouseDown(1);
-    eventSender.mouseUp(1);
-    lastClickTarget;
-}
-
-
-debug('Very normal click on container:');
-eventSender.mouseMoveTo(x, inContainer);
-eventSender.mouseDown();
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'container');
-clearClick();
-
-debug('Move inside container:');
-eventSender.mouseMoveTo(x, inContainer);
-eventSender.mouseDown();
-eventSender.mouseMoveTo(x + 10, inContainer);
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'container');
-clearClick();
-
-debug('Move from container to a child:');
-eventSender.mouseMoveTo(x, inContainer);
-eventSender.mouseDown();
-eventSender.mouseMoveTo(x, inInner1);
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'container');
-clearClick();
-
-debug('Move from a child to container:');
-eventSender.mouseMoveTo(x, inInner1);
-eventSender.mouseDown();
-eventSender.mouseMoveTo(x, inContainer);
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'container');
-clearClick();
-
-debug('Move from a child to another child:');
-eventSender.mouseMoveTo(x, inInner1);
-eventSender.mouseDown();
-eventSender.mouseMoveTo(x, inInner2);
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'container');
-clearClick();
-
-debug('Move out from a child:');
-eventSender.mouseMoveTo(x, inInner1);
-eventSender.mouseDown();
-eventSender.mouseMoveTo(x, containerRect.bottom + 10);
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'document.body');
-clearClick();
-
-debug('Removing a child element in the light DOM during a click:');
-eventSender.mouseMoveTo(x, inInner2);
-eventSender.mouseDown();
-inner2.remove();
-eventSender.mouseUp();
-shouldBeNull('lastClickTarget');
-clearClick();
-
-debug('Click on escaping button content:');
-var button1 = document.getElementById("button1");
-var spanRect = document.getElementById('button-span').getBoundingClientRect();
-eventSender.mouseMoveTo((spanRect.left + spanRect.right) / 2, spanRect.top + 1);
-eventSender.mouseDown();
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'button1');
-clearClick();
-
-debug('Click on disappearing INPUT value:');
-var input1 = document.getElementById('input1');
-input1.addEventListener('focus', function() { input1.value = ""; }, false);
-var inputRect = input1.getBoundingClientRect();
-eventSender.mouseMoveTo(inputRect.left + 8, (inputRect.top + inputRect.bottom) / 2);
-eventSender.mouseDown();
-eventSender.mouseUp();
-shouldBe('lastClickTarget', 'input1');
-clearClick();
-
-container.remove();
-button1.remove();
-input1.remove();
-
-</script>
-<script src=""
-</body>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (201291 => 201292)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-05-23 20:25:03 UTC (rev 201292)
@@ -1654,7 +1654,6 @@
 fast/events/show-modal-dialog-onblur-onfocus.html [ Failure ]
 fast/events/tab-focus-link-in-canvas.html [ Failure ]
 fast/events/tabindex-focus-blur-all.html [ Failure ]
-fast/events/click-over-descendant-elements.html [ Failure ]
 
 # Ref-test imported from W3C that is failing because type=image input elements have rounded corners on iOS.
 imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/image01.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (201291 => 201292)


--- trunk/Source/WebCore/ChangeLog	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/Source/WebCore/ChangeLog	2016-05-23 20:25:03 UTC (rev 201292)
@@ -1,3 +1,17 @@
+2016-05-23  Ryan Haddad  <ryanhad...@apple.com>
+
+        Unreviewed, rolling out r200414.
+
+        This change appears to have broken the 'write a reply' field
+        on Nextdoor.com
+
+        Reverted changeset:
+
+        "Clicks inside button elements are sometimes discarded when
+        the mouse moves"
+        https://bugs.webkit.org/show_bug.cgi?id=39620
+        http://trac.webkit.org/changeset/200414
+
 2016-05-23  Chris Dumez  <cdu...@apple.com>
 
         Clean up / Modernize the CSS Parser

Modified: trunk/Source/WebCore/dom/Node.cpp (201291 => 201292)


--- trunk/Source/WebCore/dom/Node.cpp	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/Source/WebCore/dom/Node.cpp	2016-05-23 20:25:03 UTC (rev 201292)
@@ -937,65 +937,6 @@
     return false;
 }
 
-static inline Node* ancestor(Node* node, unsigned depth)
-{
-    for (unsigned i = 0; i < depth; ++i)
-        node = node->parentNode();
-    return node;
-}
-
-Node* commonAncestor(Node& thisNode, Node& otherNode)
-{
-    unsigned thisDepth = 0;
-    for (auto node = &thisNode; node; node = node->parentNode()) {
-        if (node == &otherNode)
-            return node;
-        thisDepth++;
-    }
-    unsigned otherDepth = 0;
-    for (auto node = &otherNode; node; node = node->parentNode()) {
-        if (node == &thisNode)
-            return &thisNode;
-        otherDepth++;
-    }
-
-    Node* thisAncestor = &thisNode;
-    Node* otherAncestor = &otherNode;
-    if (thisDepth > otherDepth)
-        thisAncestor = ancestor(thisAncestor, thisDepth - otherDepth);
-    else if (otherDepth > thisDepth)
-        otherAncestor = ancestor(otherAncestor, otherDepth - thisDepth);
-
-    for (; thisAncestor; thisAncestor = thisAncestor->parentNode()) {
-        if (thisAncestor == otherAncestor)
-            return thisAncestor;
-        otherAncestor = otherAncestor->parentNode();
-    }
-    ASSERT(!otherAncestor);
-    return nullptr;
-}
-
-Node* commonAncestorCrossingShadowBoundary(Node& node, Node& other)
-{
-    if (&node == &other)
-        return &node;
-
-    Element* shadowHost = node.shadowHost();
-    // FIXME: This test might be wrong for user-authored shadow trees.
-    if (shadowHost && shadowHost == other.shadowHost())
-        return shadowHost;
-
-    TreeScope* scope = commonTreeScope(&node, &other);
-    if (!scope)
-        return nullptr;
-
-    Node* parentNode = scope->ancestorInThisScope(&node);
-    ASSERT(parentNode);
-    Node* parentOther = scope->ancestorInThisScope(&other);
-    ASSERT(parentOther);
-    return commonAncestor(*parentNode, *parentOther);
-}
-
 Node* Node::pseudoAwarePreviousSibling() const
 {
     Element* parentOrHost = is<PseudoElement>(*this) ? downcast<PseudoElement>(*this).hostElement() : parentElement();

Modified: trunk/Source/WebCore/dom/Node.h (201291 => 201292)


--- trunk/Source/WebCore/dom/Node.h	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/Source/WebCore/dom/Node.h	2016-05-23 20:25:03 UTC (rev 201292)
@@ -784,9 +784,6 @@
 
 #endif
 
-Node* commonAncestor(Node&, Node&);
-Node* commonAncestorCrossingShadowBoundary(Node&, Node&);
-
 } // namespace WebCore
 
 #if ENABLE(TREE_DEBUGGING)

Modified: trunk/Source/WebCore/page/EventHandler.cpp (201291 => 201292)


--- trunk/Source/WebCore/page/EventHandler.cpp	2016-05-23 20:14:45 UTC (rev 201291)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2016-05-23 20:25:03 UTC (rev 201292)
@@ -1955,6 +1955,24 @@
     m_clickNode = nullptr;
 }
 
+static Node* targetNodeForClickEvent(Node* mousePressNode, Node* mouseReleaseNode)
+{
+    if (!mousePressNode || !mouseReleaseNode)
+        return nullptr;
+
+    if (mousePressNode == mouseReleaseNode)
+        return mouseReleaseNode;
+
+    Element* mouseReleaseShadowHost = mouseReleaseNode->shadowHost();
+    if (mouseReleaseShadowHost && mouseReleaseShadowHost == mousePressNode->shadowHost()) {
+        // We want to dispatch the click to the shadow tree host element to give listeners the illusion that the
+        // shadom tree is a single element. For example, we want to give the illusion that <input type="range">
+        // is a single element even though it is a composition of multiple shadom tree elements.
+        return mouseReleaseShadowHost;
+    }
+    return nullptr;
+}
+
 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent)
 {
     RefPtr<FrameView> protector(m_frame.view());
@@ -2016,8 +2034,7 @@
 
     bool contextMenuEvent = platformMouseEvent.button() == RightButton;
 
-    Node* targetNode = mouseEvent.targetNode();
-    Node* nodeToClick = (m_clickNode && targetNode) ? commonAncestorCrossingShadowBoundary(*m_clickNode, *targetNode) : nullptr;
+    Node* nodeToClick = targetNodeForClickEvent(m_clickNode.get(), mouseEvent.targetNode());
     bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && nodeToClick && !dispatchMouseEvent(eventNames().clickEvent, nodeToClick, true, m_clickCount, platformMouseEvent, true);
 
     if (m_resizeLayer) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to