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

Unified 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, 4 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 4ba7e9154a65e0b942cb9f24ebf8e49e79547750..809c5a20f1600bfb0db9ffdfff878c0a7810c13f 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -1655,8 +1655,21 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEvent::CtrlKey)
contextMenuEvent = true;
#endif
-
- bool swallowClickEvent = m_clickCount > 0 && !contextMenuEvent && mouseIsReleasedOnPressedElement(mev.targetNode(), m_clickNode.get()) && !dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
+ bool isMiddleOnLink = false;
+ if (mouseEvent.button() == MiddleButton) {
+ // Middle clicks on links result in the links being opened in a background tab. It's important to not also
+ // dispatch a click event since that might make the link execute twice.
+ WebCore::Node* node = mev.targetNode();
abarth-chromium 2013/09/06 05:01:25 "WebCore::" <-- no need for this namespace. We're
+ while (node && !node->isLink())
+ node = node->parentNode();
abarth-chromium 2013/09/06 05:01:25 Hum... This crawling around the DOM doesn't seem
+ if (node)
+ isMiddleOnLink = true;
+ }
+ bool swallowClickEvent = false;
+ if (m_clickCount > 0 && !contextMenuEvent && !isMiddleOnLink && mouseIsReleasedOnPressedElement(mev.targetNode(), m_clickNode.get())) {
+ // Turn the Mouse Button Released event into a click event since all requirements are fulfilled.
+ swallowClickEvent = !dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
+ }
if (m_resizeLayer) {
m_resizeLayer->setInResizeMode(false);
« 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