Changeset 200851 in webkit


Ignore:
Timestamp:
May 13, 2016, 6:26:37 AM (9 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r200414 - Clicks inside button elements are sometimes discarded when the mouse moves
https://bugs.webkit.org/show_bug.cgi?id=39620

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/events/click-over-descendant-elements.html

  • dom/Node.cpp:

(WebCore::ancestor):
(WebCore::commonAncestor): Method inspired from
http://src.chromium.org/viewvc/blink?view=revision&revision=162081.
(WebCore::commonAncestorCrossingShadowBoundary): Helper routine
that handles the case of nodes into a shadow node.

  • dom/Node.h:
  • page/EventHandler.cpp:

(WebCore::EventHandler::handleMouseReleaseEvent): Selecting click event
target node according commonAncestorOverShadowBoundary method.
(WebCore::EventHandler::targetNodeForClickEvent): Deleted.

LayoutTests:

Test coming from http://src.chromium.org/viewvc/blink?view=revision&revision=162081.
Modified to ensure click events do not end up being considered as double click events.

  • fast/events/click-over-descendant-elements-expected.txt: Added.
  • fast/events/click-over-descendant-elements.html: Added.
  • platform/ios-simulator/TestExpectations: Marked new test as failing.
Location:
releases/WebKitGTK/webkit-2.12
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog

    r200849 r200851  
     12016-05-04  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        Clicks inside button elements are sometimes discarded when the mouse moves
     4        https://bugs.webkit.org/show_bug.cgi?id=39620
     5
     6        Reviewed by Darin Adler.
     7
     8        Test coming from http://src.chromium.org/viewvc/blink?view=revision&revision=162081.
     9        Modified to ensure click events do not end up being considered as double click events.
     10
     11        * fast/events/click-over-descendant-elements-expected.txt: Added.
     12        * fast/events/click-over-descendant-elements.html: Added.
     13        * platform/ios-simulator/TestExpectations: Marked new test as failing.
     14
    1152016-04-29  Alex Christensen  <achristensen@webkit.org>
    216
  • releases/WebKitGTK/webkit-2.12/LayoutTests/platform/ios-simulator/TestExpectations

    r199991 r200851  
    16411641fast/events/tab-focus-link-in-canvas.html [ Failure ]
    16421642fast/events/tabindex-focus-blur-all.html [ Failure ]
     1643fast/events/click-over-descendant-elements.html [ Failure ]
    16431644
    16441645# Ref-test imported from W3C that is failing because type=image input elements have rounded corners on iOS.
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog

    r200850 r200851  
     12016-05-04  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        Clicks inside button elements are sometimes discarded when the mouse moves
     4        https://bugs.webkit.org/show_bug.cgi?id=39620
     5
     6        Reviewed by Darin Adler.
     7
     8        Test: fast/events/click-over-descendant-elements.html
     9
     10        * dom/Node.cpp:
     11        (WebCore::ancestor):
     12        (WebCore::commonAncestor): Method inspired from
     13        http://src.chromium.org/viewvc/blink?view=revision&revision=162081.
     14        (WebCore::commonAncestorCrossingShadowBoundary): Helper routine
     15        that handles the case of nodes into a shadow node.
     16        * dom/Node.h:
     17        * page/EventHandler.cpp:
     18        (WebCore::EventHandler::handleMouseReleaseEvent): Selecting click event
     19        target node according commonAncestorOverShadowBoundary method.
     20        (WebCore::EventHandler::targetNodeForClickEvent): Deleted.
     21
    1222016-05-04  Jiewen Tan  <jiewen_tan@apple.com>
    223
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/dom/Node.cpp

    r195927 r200851  
    939939}
    940940
     941static inline Node* ancestor(Node* node, unsigned depth)
     942{
     943    for (unsigned i = 0; i < depth; ++i)
     944        node = node->parentNode();
     945    return node;
     946}
     947
     948Node* commonAncestor(Node& thisNode, Node& otherNode)
     949{
     950    unsigned thisDepth = 0;
     951    for (auto node = &thisNode; node; node = node->parentNode()) {
     952        if (node == &otherNode)
     953            return node;
     954        thisDepth++;
     955    }
     956    unsigned otherDepth = 0;
     957    for (auto node = &otherNode; node; node = node->parentNode()) {
     958        if (node == &thisNode)
     959            return &thisNode;
     960        otherDepth++;
     961    }
     962
     963    Node* thisAncestor = &thisNode;
     964    Node* otherAncestor = &otherNode;
     965    if (thisDepth > otherDepth)
     966        thisAncestor = ancestor(thisAncestor, thisDepth - otherDepth);
     967    else if (otherDepth > thisDepth)
     968        otherAncestor = ancestor(otherAncestor, otherDepth - thisDepth);
     969
     970    for (; thisAncestor; thisAncestor = thisAncestor->parentNode()) {
     971        if (thisAncestor == otherAncestor)
     972            return thisAncestor;
     973        otherAncestor = otherAncestor->parentNode();
     974    }
     975    ASSERT(!otherAncestor);
     976    return nullptr;
     977}
     978
     979Node* commonAncestorCrossingShadowBoundary(Node& node, Node& other)
     980{
     981    if (&node == &other)
     982        return &node;
     983
     984    Element* shadowHost = node.shadowHost();
     985    // FIXME: This test might be wrong for user-authored shadow trees.
     986    if (shadowHost && shadowHost == other.shadowHost())
     987        return shadowHost;
     988
     989    TreeScope* scope = commonTreeScope(&node, &other);
     990    if (!scope)
     991        return nullptr;
     992
     993    Node* parentNode = scope->ancestorInThisScope(&node);
     994    ASSERT(parentNode);
     995    Node* parentOther = scope->ancestorInThisScope(&other);
     996    ASSERT(parentOther);
     997    return commonAncestor(*parentNode, *parentOther);
     998}
     999
    9411000Node* Node::pseudoAwarePreviousSibling() const
    9421001{
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/dom/Node.h

    r199997 r200851  
    791791}
    792792
     793Node* commonAncestor(Node&, Node&);
     794Node* commonAncestorCrossingShadowBoundary(Node&, Node&);
     795
    793796} // namespace WebCore
    794797
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/page/EventHandler.cpp

    r200846 r200851  
    19471947}
    19481948
    1949 static Node* targetNodeForClickEvent(Node* mousePressNode, Node* mouseReleaseNode)
    1950 {
    1951     if (!mousePressNode || !mouseReleaseNode)
    1952         return nullptr;
    1953 
    1954     if (mousePressNode == mouseReleaseNode)
    1955         return mouseReleaseNode;
    1956 
    1957     Element* mouseReleaseShadowHost = mouseReleaseNode->shadowHost();
    1958     if (mouseReleaseShadowHost && mouseReleaseShadowHost == mousePressNode->shadowHost()) {
    1959         // We want to dispatch the click to the shadow tree host element to give listeners the illusion that the
    1960         // shadom tree is a single element. For example, we want to give the illusion that <input type="range">
    1961         // is a single element even though it is a composition of multiple shadom tree elements.
    1962         return mouseReleaseShadowHost;
    1963     }
    1964     return nullptr;
    1965 }
    1966 
    19671949bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& platformMouseEvent)
    19681950{
     
    20262008    bool contextMenuEvent = platformMouseEvent.button() == RightButton;
    20272009
    2028     Node* nodeToClick = targetNodeForClickEvent(m_clickNode.get(), mouseEvent.targetNode());
     2010    Node* targetNode = mouseEvent.targetNode();
     2011    Node* nodeToClick = (m_clickNode && targetNode) ? commonAncestorCrossingShadowBoundary(*m_clickNode, *targetNode) : nullptr;
    20292012    bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && nodeToClick && !dispatchMouseEvent(eventNames().clickEvent, nodeToClick, true, m_clickCount, platformMouseEvent, true);
    20302013
Note: See TracChangeset for help on using the changeset viewer.