Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 23060022: Don't turn middleclicks into click events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: After multi-browser analysis and with testcases. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/events/script-tests/mouse-click-events.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 return true; 1648 return true;
1649 1649
1650 bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, me v.targetNode(), true, m_clickCount, mouseEvent, false); 1650 bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, me v.targetNode(), true, m_clickCount, mouseEvent, false);
1651 1651
1652 bool contextMenuEvent = mouseEvent.button() == RightButton; 1652 bool contextMenuEvent = mouseEvent.button() == RightButton;
1653 #if OS(DARWIN) 1653 #if OS(DARWIN)
1654 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations. 1654 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations.
1655 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey) 1655 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey)
1656 contextMenuEvent = true; 1656 contextMenuEvent = true;
1657 #endif 1657 #endif
1658 1658 bool isMiddleOnLink = false;
1659 bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && mouseIsRel easedOnPressedElement(mev.targetNode(), m_clickNode.get()) && !dispatchMouseEven t(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, tru e); 1659 if (mouseEvent.button() == MiddleButton) {
1660 // Middle clicks on links result in the links being opened in a backgrou nd tab. It's important to not also
1661 // dispatch a click event since that might make the link execute twice.
1662 WebCore::Node* node = mev.targetNode();
abarth-chromium 2013/09/06 05:01:25 "WebCore::" <-- no need for this namespace. We're
1663 while (node && !node->isLink())
1664 node = node->parentNode();
abarth-chromium 2013/09/06 05:01:25 Hum... This crawling around the DOM doesn't seem
1665 if (node)
1666 isMiddleOnLink = true;
1667 }
1668 bool swallowClickEvent = false;
1669 if (m_clickCount > 0 && !contextMenuEvent && !isMiddleOnLink && mouseIsRelea sedOnPressedElement(mev.targetNode(), m_clickNode.get())) {
1670 // Turn the Mouse Button Released event into a click event since all req uirements are fulfilled.
1671 swallowClickEvent = !dispatchMouseEvent(eventNames().clickEvent, mev.tar getNode(), true, m_clickCount, mouseEvent, true);
1672 }
1660 1673
1661 if (m_resizeLayer) { 1674 if (m_resizeLayer) {
1662 m_resizeLayer->setInResizeMode(false); 1675 m_resizeLayer->setInResizeMode(false);
1663 m_resizeLayer = 0; 1676 m_resizeLayer = 0;
1664 } 1677 }
1665 1678
1666 bool swallowMouseReleaseEvent = false; 1679 bool swallowMouseReleaseEvent = false;
1667 if (!swallowMouseUpEvent) 1680 if (!swallowMouseUpEvent)
1668 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev); 1681 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev);
1669 1682
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 unsigned EventHandler::accessKeyModifiers() 3857 unsigned EventHandler::accessKeyModifiers()
3845 { 3858 {
3846 #if OS(DARWIN) 3859 #if OS(DARWIN)
3847 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3860 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3848 #else 3861 #else
3849 return PlatformEvent::AltKey; 3862 return PlatformEvent::AltKey;
3850 #endif 3863 #endif
3851 } 3864 }
3852 3865
3853 } // namespace WebCore 3866 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/script-tests/mouse-click-events.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698