Changeset 67261 in webkit


Ignore:
Timestamp:
Sep 10, 2010 6:16:12 PM (14 years ago)
Author:
pkasting@chromium.org
Message:

Make middle clicks not fire DOM onclick events.
https://bugs.webkit.org/show_bug.cgi?id=22382

Reviewed by Darin Adler.

WebCore:

  • html/HTMLAnchorElement.cpp: Explicitly include middle-clicks in the

computation of what constitutes a link click, since they're no longer
implicitly included.
(WebCore::isLinkClick):

  • html/HTMLInputElement.cpp: Removed unneeded checks that click events

are coming from the left mouse button, since they all are now.
(WebCore::HTMLInputElement::preDispatchEventHandler):
(WebCore::HTMLInputElement::postDispatchEventHandler):
(WebCore::HTMLInputElement::defaultEventHandler):

  • page/EventHandler.cpp: Changed logic to send a click event only for

the left button.
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):

LayoutTests:

  • fast/events/mouse-click-events-expected.txt:
  • fast/events/script-tests/mouse-click-events.js:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r67256 r67261  
     12010-09-10  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Make middle clicks not fire DOM onclick events.
     6        https://bugs.webkit.org/show_bug.cgi?id=22382
     7
     8        * fast/events/mouse-click-events-expected.txt:
     9        * fast/events/script-tests/mouse-click-events.js:
     10
    1112010-09-10  Dirk Pranke  <dpranke@chromium.org>
    212
  • trunk/LayoutTests/fast/events/mouse-click-events-expected.txt

    r50926 r67261  
    77PASS eventLog is "mousedown(0) mouseup(0) click(0) mousedown(0) mouseup(0) click(0) dblclick(0) "
    88Middle Mouse Button
    9 PASS eventLog is "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) "
     9PASS eventLog is "mousedown(1) mouseup(1) mousedown(1) mouseup(1) "
    1010Right Mouse Button
    1111PASS eventLog is "mousedown(2) mouseup(2) mousedown(2) mouseup(2) "
    12124th Mouse Button
    13 PASS eventLog is "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) "
     13PASS eventLog is "mousedown(1) mouseup(1) mousedown(1) mouseup(1) "
    1414PASS successfullyParsed is true
    1515
  • trunk/LayoutTests/fast/events/script-tests/mouse-click-events.js

    r50926 r67261  
    5050if (window.eventSender) {
    5151    testEvents("Left Mouse Button", 0, "mousedown(0) mouseup(0) click(0) mousedown(0) mouseup(0) click(0) dblclick(0) ");
    52     testEvents("Middle Mouse Button", 1, "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) ");
     52    testEvents("Middle Mouse Button", 1, "mousedown(1) mouseup(1) mousedown(1) mouseup(1) ");
    5353    testEvents("Right Mouse Button", 2, "mousedown(2) mouseup(2) mousedown(2) mouseup(2) ");
    54     testEvents("4th Mouse Button", 3, "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) ");
     54    testEvents("4th Mouse Button", 3, "mousedown(1) mouseup(1) mousedown(1) mouseup(1) ");
    5555}
    5656
  • trunk/WebCore/ChangeLog

    r67257 r67261  
     12010-09-10  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Make middle clicks not fire DOM onclick events.
     6        https://bugs.webkit.org/show_bug.cgi?id=22382
     7
     8        * html/HTMLAnchorElement.cpp: Explicitly include middle-clicks in the
     9        computation of what constitutes a link click, since they're no longer
     10        implicitly included.
     11        (WebCore::isLinkClick):
     12        * html/HTMLInputElement.cpp: Removed unneeded checks that click events
     13        are coming from the left mouse button, since they all are now.
     14        (WebCore::HTMLInputElement::preDispatchEventHandler):
     15        (WebCore::HTMLInputElement::postDispatchEventHandler):
     16        (WebCore::HTMLInputElement::defaultEventHandler):
     17        * page/EventHandler.cpp: Changed logic to send a click event only for
     18        the left button.
     19        (WebCore::EventHandler::handleMouseDoubleClickEvent):
     20        (WebCore::EventHandler::handleMouseReleaseEvent):
     21
    1222010-09-10  Adam Barth  <abarth@webkit.org>
    223
     
    100121        * rendering/RenderThemeWin.h:
    101122
    102 2010-09-109  Peter Kasting  <pkasting@google.com>
     1232010-09-10  Peter Kasting  <pkasting@google.com>
    103124
    104125        Reviewed by Darin Adler.
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r67246 r67261  
    515515bool isLinkClick(Event* event)
    516516{
    517     return event->type() == eventNames().clickEvent && (!event->isMouseEvent() || static_cast<MouseEvent*>(event)->button() != RightButton);
     517    return event->type() == eventNames().clickEvent || (event->type() == eventNames().mouseupEvent && isMiddleMouseButtonEvent(event));
    518518}
    519519
  • trunk/WebCore/html/HTMLInputElement.cpp

    r67208 r67261  
    21562156};
    21572157
    2158 void* HTMLInputElement::preDispatchEventHandler(Event *evt)
     2158void* HTMLInputElement::preDispatchEventHandler(Event* evt)
    21592159{
    21602160    // preventDefault or "return false" are used to reverse the automatic checking/selection we do here.
    21612161    // This result gives us enough info to perform the "undo" in postDispatch of the action we take here.
    21622162    void* result = 0;
    2163     if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent()
    2164             && evt->type() == eventNames().clickEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
    2165        
     2163    if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->type() == eventNames().clickEvent) {
    21662164        OwnPtr<EventHandlingState> state = adoptPtr(new EventHandlingState(indeterminate(), checked()));
    2167 
    21682165        if (inputType() == CHECKBOX) {
    21692166            if (indeterminate())
     
    21932190void HTMLInputElement::postDispatchEventHandler(Event *evt, void* data)
    21942191{
    2195     if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent()
    2196             && evt->type() == eventNames().clickEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
     2192    if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->type() == eventNames().clickEvent) {
    21972193       
    21982194        if (EventHandlingState* state = reinterpret_cast<EventHandlingState*>(data)) {
     
    22772273    }
    22782274
    2279     if (inputType() == RADIO
    2280             && evt->isMouseEvent()
    2281             && evt->type() == eventNames().clickEvent
    2282             && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
     2275    if (inputType() == RADIO && evt->type() == eventNames().clickEvent) {
    22832276        evt->setDefaultHandled();
    22842277        return;
  • trunk/WebCore/page/EventHandler.cpp

    r67238 r67261  
    13761376    bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
    13771377
    1378     bool swallowClickEvent = false;
    1379     // Don't ever dispatch click events for right clicks
    1380     if (mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode)
    1381         swallowClickEvent = dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
     1378    bool swallowClickEvent = mouseEvent.button() == LeftButton && mev.targetNode() == m_clickNode && dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
    13821379
    13831380    if (m_lastScrollbarUnderMouse)
    13841381        swallowMouseUpEvent = m_lastScrollbarUnderMouse->mouseUp();
    1385            
    1386     bool swallowMouseReleaseEvent = false;
    1387     if (!swallowMouseUpEvent)
    1388         swallowMouseReleaseEvent = handleMouseReleaseEvent(mev);
     1382
     1383    bool swallowMouseReleaseEvent = !swallowMouseUpEvent && handleMouseReleaseEvent(mev);
    13891384
    13901385    invalidateClick();
     
    15721567    bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
    15731568
    1574     // Don't ever dispatch click events for right clicks
    1575     bool swallowClickEvent = false;
    1576     if (m_clickCount > 0 && mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode)
    1577         swallowClickEvent = dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
     1569    bool swallowClickEvent = m_clickCount > 0 && mouseEvent.button() == LeftButton && mev.targetNode() == m_clickNode && dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
    15781570
    15791571    if (m_resizeLayer) {
Note: See TracChangeset for help on using the changeset viewer.