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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1894253002: Prevent sending click event for non primary button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing the test Created 4 years, 8 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
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 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 && !(selectionController().hasExtendedSelection() && isLinkSelection(mev )); 1480 && !(selectionController().hasExtendedSelection() && isLinkSelection(mev ));
1481 if (shouldDispatchClickEvent) { 1481 if (shouldDispatchClickEvent) {
1482 // Updates distribution because a 'mouseup' event listener can make the 1482 // Updates distribution because a 'mouseup' event listener can make the
1483 // tree dirty at dispatchMouseEvent() invocation above. 1483 // tree dirty at dispatchMouseEvent() invocation above.
1484 // Unless distribution is updated, commonAncestor would hit ASSERT. 1484 // Unless distribution is updated, commonAncestor would hit ASSERT.
1485 // Both m_clickNode and mev.innerNode() don't need to be updated 1485 // Both m_clickNode and mev.innerNode() don't need to be updated
1486 // because commonAncestor() will exit early if their documents are diffe rent. 1486 // because commonAncestor() will exit early if their documents are diffe rent.
1487 m_clickNode->updateDistribution(); 1487 m_clickNode->updateDistribution();
1488 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( 1488 if (Node* clickTargetNode = mev.innerNode()->commonAncestor(
1489 *m_clickNode, parentForClickEvent)) { 1489 *m_clickNode, parentForClickEvent)) {
1490
1491 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents 1490 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents
1492 // because the mouseup dispatch above has already updated it 1491 // because the mouseup dispatch above has already updated it
1493 // correctly. Moreover, clickTargetNode is different from 1492 // correctly. Moreover, clickTargetNode is different from
1494 // mev.innerNode at drag-release. 1493 // mev.innerNode at drag-release.
1495 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(), 1494
1496 EventTypeNames::click, m_clickCount)); 1495 MouseEvent* event = MouseEvent::create(
1496 EventTypeNames::click,
1497 clickTargetNode->document().domWindow(),
1498 mev.event(), m_clickCount, nullptr);
1499
1500 // This is to suppress sending click events for non-primary buttons.
1501 // But still doing default action like opening a new tab for middle
1502 // click (crbug.com/255).
1503 if (mev.event().button() != MouseButton::LeftButton)
1504 event->stopPropagation();
1505
1506 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchEv ent(event));
1497 } 1507 }
1498 } 1508 }
1499 1509
1500 if (m_resizeScrollableArea) { 1510 if (m_resizeScrollableArea) {
1501 m_resizeScrollableArea->setInResizeMode(false); 1511 m_resizeScrollableArea->setInResizeMode(false);
1502 m_resizeScrollableArea = nullptr; 1512 m_resizeScrollableArea = nullptr;
1503 } 1513 }
1504 1514
1505 if (eventResult == WebInputEventResult::NotHandled) 1515 if (eventResult == WebInputEventResult::NotHandled)
1506 eventResult = handleMouseReleaseEvent(mev); 1516 eventResult = handleMouseReleaseEvent(mev);
(...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4159 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4150 { 4160 {
4151 #if OS(MACOSX) 4161 #if OS(MACOSX)
4152 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4162 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4153 #else 4163 #else
4154 return PlatformEvent::AltKey; 4164 return PlatformEvent::AltKey;
4155 #endif 4165 #endif
4156 } 4166 }
4157 4167
4158 } // namespace blink 4168 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698