OLD | NEW |
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<Mo
useEvent> mouseEvent) | 259 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<Mo
useEvent> mouseEvent) |
260 : EventDispatchMediator(mouseEvent) | 260 : EventDispatchMediator(mouseEvent) |
261 { | 261 { |
262 } | 262 } |
263 | 263 |
264 MouseEvent& MouseEventDispatchMediator::event() const | 264 MouseEvent& MouseEventDispatchMediator::event() const |
265 { | 265 { |
266 return toMouseEvent(EventDispatchMediator::event()); | 266 return toMouseEvent(EventDispatchMediator::event()); |
267 } | 267 } |
268 | 268 |
269 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons
t | 269 DispatchEventResult MouseEventDispatchMediator::dispatchEvent(EventDispatcher& d
ispatcher) const |
270 { | 270 { |
271 MouseEvent& mouseEvent = event(); | 271 MouseEvent& mouseEvent = event(); |
272 if (!mouseEvent.isTrusted()) { | 272 if (!mouseEvent.isTrusted()) { |
273 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), mouseEv
ent.relatedTarget()); | 273 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), mouseEv
ent.relatedTarget()); |
274 return dispatcher.dispatch(); | 274 return dispatcher.dispatch(); |
275 } | 275 } |
276 | 276 |
277 if (isDisabledFormControl(&dispatcher.node())) | 277 if (isDisabledFormControl(&dispatcher.node())) |
278 return false; | 278 return DispatchEventResult::CanceledBeforeDispatch; |
279 | 279 |
280 if (mouseEvent.type().isEmpty()) | 280 if (mouseEvent.type().isEmpty()) |
281 return true; // Shouldn't happen. | 281 return DispatchEventResult::NotCanceled; // Shouldn't happen. |
282 | 282 |
283 ASSERT(!mouseEvent.target() || mouseEvent.target() != mouseEvent.relatedTarg
et()); | 283 ASSERT(!mouseEvent.target() || mouseEvent.target() != mouseEvent.relatedTarg
et()); |
284 | 284 |
285 EventTarget* relatedTarget = mouseEvent.relatedTarget(); | 285 EventTarget* relatedTarget = mouseEvent.relatedTarget(); |
286 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarg
et); | 286 mouseEvent.eventPath().adjustForRelatedTarget(dispatcher.node(), relatedTarg
et); |
287 | 287 |
288 dispatcher.dispatch(); | 288 DispatchEventResult dispatchResult = dispatcher.dispatch(); |
289 bool swallowEvent = mouseEvent.defaultHandled() || mouseEvent.defaultPrevent
ed(); | |
290 | 289 |
291 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) | 290 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) |
292 return !swallowEvent; | 291 return dispatchResult; |
293 | 292 |
294 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part | 293 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part |
295 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated | 294 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated |
296 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. | 295 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. |
297 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); | 296 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); |
298 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven
t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(), | 297 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven
t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(), |
299 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv
ent.clientX(), mouseEvent.clientY(), | 298 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv
ent.clientX(), mouseEvent.clientY(), |
300 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s
ourceCapabilities(), mouseEvent.buttons()); | 299 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s
ourceCapabilities(), mouseEvent.buttons()); |
301 | 300 |
302 // Inherit the trusted status from the original event. | 301 // Inherit the trusted status from the original event. |
303 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); | 302 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); |
304 if (mouseEvent.defaultHandled()) | 303 if (mouseEvent.defaultHandled()) |
305 doubleClickEvent->setDefaultHandled(); | 304 doubleClickEvent->setDefaultHandled(); |
306 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator
::create(doubleClickEvent)); | 305 DispatchEventResult doubleClickDispatchResult = EventDispatcher::dispatchEve
nt(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent)); |
307 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented
()) | 306 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled) |
308 return false; | 307 return doubleClickDispatchResult; |
309 return !swallowEvent; | 308 return dispatchResult; |
310 } | 309 } |
311 | 310 |
312 } // namespace blink | 311 } // namespace blink |
OLD | NEW |