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

Unified Diff: Source/core/events/EventDispatcher.cpp

Issue 894913002: Prevent default actions for JS-generated mouse events other than click (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TIL, gclient sync may rebase changes back in time Created 5 years, 6 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 | « Source/core/dom/Node.cpp ('k') | Source/core/events/MouseEvent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/events/EventDispatcher.cpp
diff --git a/Source/core/events/EventDispatcher.cpp b/Source/core/events/EventDispatcher.cpp
index 1cd6cd67a3a2bf89cb6cb9c2699dba3e0695282e..4a0fd1bfbb1569e8d4257df785bcc00bc3473289 100644
--- a/Source/core/events/EventDispatcher.cpp
+++ b/Source/core/events/EventDispatcher.cpp
@@ -206,7 +206,13 @@ inline void EventDispatcher::dispatchEventPostProcess(void* preDispatchEventHand
// Call default event handlers. While the DOM does have a concept of preventing
// default handling, the detail of which handlers are called is an internal
// implementation detail and not part of the DOM.
- if (!m_event->defaultPrevented() && !m_event->defaultHandled()) {
+
+ // The DOM Events spec says that events dispatched by JS (other than "click")
+ // should not have their default handlers invoked. (issue #423975)
+ // To begin with, only apply to mouse events.
+ bool isScriptedMouseEventOtherThanClick = m_event->isMouseEvent() && toMouseEvent(*m_event).fromScript() && toMouseEvent(*m_event).type() != EventTypeNames::click;
+
+ if (!m_event->defaultPrevented() && !m_event->defaultHandled() && !isScriptedMouseEventOtherThanClick) {
// Non-bubbling events call only one default event handler, the one for the target.
m_node->willCallDefaultEventHandler(*m_event);
m_node->defaultEventHandler(m_event.get());
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/events/MouseEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698