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

Side by Side Diff: Source/core/events/MouseEvent.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: address bokan's feedback Created 5 years, 9 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) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 MouseEvent& MouseEventDispatchMediator::event() const 254 MouseEvent& MouseEventDispatchMediator::event() const
255 { 255 {
256 return toMouseEvent(EventDispatchMediator::event()); 256 return toMouseEvent(EventDispatchMediator::event());
257 } 257 }
258 258
259 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons t 259 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons t
260 { 260 {
261 if (isSyntheticMouseEvent()) { 261 if (isSyntheticMouseEvent()) {
262 event().eventPath().adjustForRelatedTarget(dispatcher.node(), event().re latedTarget()); 262 event().eventPath().adjustForRelatedTarget(dispatcher.node(), event().re latedTarget());
263 event().markAsSynthetic();
263 return dispatcher.dispatch(); 264 return dispatcher.dispatch();
264 } 265 }
265 266
266 if (isDisabledFormControl(&dispatcher.node())) 267 if (isDisabledFormControl(&dispatcher.node()))
267 return false; 268 return false;
268 269
269 if (event().type().isEmpty()) 270 if (event().type().isEmpty())
270 return true; // Shouldn't happen. 271 return true; // Shouldn't happen.
271 272
272 ASSERT(!event().target() || event().target() != event().relatedTarget()); 273 ASSERT(!event().target() || event().target() != event().relatedTarget());
(...skipping 17 matching lines...) Expand all
290 event().button(), relatedTarget, event().buttons()); 291 event().button(), relatedTarget, event().buttons());
291 if (event().defaultHandled()) 292 if (event().defaultHandled())
292 doubleClickEvent->setDefaultHandled(); 293 doubleClickEvent->setDefaultHandled();
293 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); 294 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent));
294 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) 295 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ())
295 return false; 296 return false;
296 return !swallowEvent; 297 return !swallowEvent;
297 } 298 }
298 299
299 } // namespace blink 300 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698