Chromium Code Reviews| 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); |