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

Side by Side Diff: third_party/WebKit/Source/core/events/EventDispatcher.cpp

Issue 1894253002: Prevent sending click event for non primary button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing tests 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // eventPath() can be empty if event path is shrinked by relataedTarget retargeting. 113 // eventPath() can be empty if event path is shrinked by relataedTarget retargeting.
114 return DispatchEventResult::NotCanceled; 114 return DispatchEventResult::NotCanceled;
115 } 115 }
116 m_event->eventPath().ensureWindowEventContext(); 116 m_event->eventPath().ensureWindowEventContext();
117 117
118 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); 118 m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node));
119 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 119 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
120 ASSERT(m_event->target()); 120 ASSERT(m_event->target());
121 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*m_event)); 121 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*m_event));
122 EventDispatchHandlingState* preDispatchEventHandlerResult = nullptr; 122 EventDispatchHandlingState* preDispatchEventHandlerResult = nullptr;
123 if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispat ching) { 123
dtapuska 2016/04/22 18:32:30 Adding this here seems incorrect and a number of l
Navid Zolghadr 2016/04/22 19:09:58 I realized this file shouldn't be for mouse specif
dtapuska 2016/04/22 19:16:32 What about removing this and adding: if (nati
Navid Zolghadr 2016/04/25 18:37:48 Done.
124 bool isClickForNonPrimaryButtons = m_event->isMouseEvent()
125 && toMouseEvent(*m_event).type() == EventTypeNames::click
126 && toMouseEvent(*m_event).button() != MouseButton::LeftButton;
127
128 if (!isClickForNonPrimaryButtons
129 && dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDis patching) {
124 if (dispatchEventAtCapturing() == ContinueDispatching) { 130 if (dispatchEventAtCapturing() == ContinueDispatching) {
125 if (dispatchEventAtTarget() == ContinueDispatching) 131 if (dispatchEventAtTarget() == ContinueDispatching)
126 dispatchEventAtBubbling(); 132 dispatchEventAtBubbling();
127 } 133 }
128 } 134 }
129 dispatchEventPostProcess(preDispatchEventHandlerResult); 135 dispatchEventPostProcess(preDispatchEventHandlerResult);
130 136
131 // Ensure that after event dispatch, the event's target object is the 137 // Ensure that after event dispatch, the event's target object is the
132 // outermost shadow DOM boundary. 138 // outermost shadow DOM boundary.
133 m_event->setTarget(m_event->eventPath().windowEventContext().target()); 139 m_event->setTarget(m_event->eventPath().windowEventContext().target());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( )); 238 m_event->eventPath()[i].node()->defaultEventHandler(m_event.get( ));
233 ASSERT(!m_event->defaultPrevented()); 239 ASSERT(!m_event->defaultPrevented());
234 if (m_event->defaultHandled()) 240 if (m_event->defaultHandled())
235 return; 241 return;
236 } 242 }
237 } 243 }
238 } 244 }
239 } 245 }
240 246
241 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698