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

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

Issue 1479923002: Enumerate the return value of dispatchEvent so it is clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_passive_uma_add
Patch Set: Rebase Created 5 years 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<Mo useEvent> mouseEvent) 244 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<Mo useEvent> mouseEvent)
245 : EventDispatchMediator(mouseEvent) 245 : EventDispatchMediator(mouseEvent)
246 { 246 {
247 } 247 }
248 248
249 MouseEvent& MouseEventDispatchMediator::event() const 249 MouseEvent& MouseEventDispatchMediator::event() const
250 { 250 {
251 return toMouseEvent(EventDispatchMediator::event()); 251 return toMouseEvent(EventDispatchMediator::event());
252 } 252 }
253 253
254 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons t 254 WebInputEventResult MouseEventDispatchMediator::dispatchEvent(EventDispatcher& d ispatcher) const
255 { 255 {
256 MouseEvent& mouseEvent = event(); 256 MouseEvent& mouseEvent = event();
257 if (!mouseEvent.isTrusted()) { 257 if (!mouseEvent.isTrusted()) {
258 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), mouseEv ent.relatedTarget()); 258 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), mouseEv ent.relatedTarget());
259 return dispatcher.dispatch(); 259 return dispatcher.dispatch();
260 } 260 }
261 261
262 if (isDisabledFormControl(&dispatcher.node())) 262 if (isDisabledFormControl(&dispatcher.node()))
263 return false; 263 return WebInputEventResult::HandledSuppressed;
264 264
265 if (mouseEvent.type().isEmpty()) 265 if (mouseEvent.type().isEmpty())
266 return true; // Shouldn't happen. 266 return WebInputEventResult::NotHandled; // Shouldn't happen.
267 267
268 ASSERT(!mouseEvent.target() || mouseEvent.target() != mouseEvent.relatedTarg et()); 268 ASSERT(!mouseEvent.target() || mouseEvent.target() != mouseEvent.relatedTarg et());
269 269
270 EventTarget* relatedTarget = mouseEvent.relatedTarget(); 270 EventTarget* relatedTarget = mouseEvent.relatedTarget();
271 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarg et); 271 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarg et);
272 272
273 dispatcher.dispatch(); 273 WebInputEventResult result = dispatcher.dispatch();
274 bool swallowEvent = mouseEvent.defaultHandled() || mouseEvent.defaultPrevent ed();
275 274
276 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) 275 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2)
277 return !swallowEvent; 276 return result;
278 277
279 // Special case: If it's a double click event, we also send the dblclick eve nt. This is not part 278 // Special case: If it's a double click event, we also send the dblclick eve nt. This is not part
280 // of the DOM specs, but is used for compatibility with the ondblclick="" at tribute. This is treated 279 // of the DOM specs, but is used for compatibility with the ondblclick="" at tribute. This is treated
281 // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same. 280 // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
282 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); 281 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create();
283 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(), 282 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(),
284 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv ent.clientX(), mouseEvent.clientY(), 283 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv ent.clientX(), mouseEvent.clientY(),
285 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s ourceCapabilities(), mouseEvent.buttons()); 284 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s ourceCapabilities(), mouseEvent.buttons());
286 285
287 // Inherit the trusted status from the original event. 286 // Inherit the trusted status from the original event.
288 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); 287 doubleClickEvent->setTrusted(mouseEvent.isTrusted());
289 if (mouseEvent.defaultHandled()) 288 if (mouseEvent.defaultHandled())
290 doubleClickEvent->setDefaultHandled(); 289 doubleClickEvent->setDefaultHandled();
291 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); 290 WebInputEventResult doubleClickEventResult = EventDispatcher::dispatchEvent( dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent));
292 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) 291 if (result != WebInputEventResult::NotHandled)
293 return false; 292 return result;
294 return !swallowEvent; 293 return doubleClickEventResult;
295 } 294 }
296 295
297 } // namespace blink 296 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698