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. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/events/MouseEvent.h" | 24 #include "core/events/MouseEvent.h" |
25 | 25 |
26 #include "core/dom/Clipboard.h" | 26 #include "core/dom/Clipboard.h" |
27 #include "core/dom/Element.h" | 27 #include "core/dom/Element.h" |
28 #include "core/events/EventDispatcher.h" | 28 #include "core/events/EventDispatcher.h" |
29 #include "core/events/EventRetargeter.h" | |
30 #include "core/events/ThreadLocalEventNames.h" | 29 #include "core/events/ThreadLocalEventNames.h" |
31 #include "platform/PlatformMouseEvent.h" | 30 #include "platform/PlatformMouseEvent.h" |
32 | 31 |
33 namespace WebCore { | 32 namespace WebCore { |
34 | 33 |
35 MouseEventInit::MouseEventInit() | 34 MouseEventInit::MouseEventInit() |
36 : screenX(0) | 35 : screenX(0) |
37 , screenY(0) | 36 , screenY(0) |
38 , clientX(0) | 37 , clientX(0) |
39 , clientY(0) | 38 , clientY(0) |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 243 } |
245 | 244 |
246 MouseEvent* MouseEventDispatchMediator::event() const | 245 MouseEvent* MouseEventDispatchMediator::event() const |
247 { | 246 { |
248 return toMouseEvent(EventDispatchMediator::event()); | 247 return toMouseEvent(EventDispatchMediator::event()); |
249 } | 248 } |
250 | 249 |
251 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons
t | 250 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) cons
t |
252 { | 251 { |
253 if (isSyntheticMouseEvent()) { | 252 if (isSyntheticMouseEvent()) { |
254 EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event()); | 253 event()->eventPath().adjustForRelatedTarget(dispatcher->node(), event()-
>relatedTarget()); |
255 return dispatcher->dispatch(); | 254 return dispatcher->dispatch(); |
256 } | 255 } |
257 | 256 |
258 if (isDisabledFormControl(dispatcher->node())) | 257 if (isDisabledFormControl(dispatcher->node())) |
259 return false; | 258 return false; |
260 | 259 |
261 if (event()->type().isEmpty()) | 260 if (event()->type().isEmpty()) |
262 return true; // Shouldn't happen. | 261 return true; // Shouldn't happen. |
263 | 262 |
264 ASSERT(!event()->target() || event()->target() != event()->relatedTarget()); | 263 ASSERT(!event()->target() || event()->target() != event()->relatedTarget()); |
265 | 264 |
266 EventTarget* relatedTarget = event()->relatedTarget(); | 265 EventTarget* relatedTarget = event()->relatedTarget(); |
267 EventRetargeter::adjustForMouseEvent(dispatcher->node(), *event()); | 266 event()->eventPath().adjustForRelatedTarget(dispatcher->node(), relatedTarge
t); |
268 | 267 |
269 dispatcher->dispatch(); | 268 dispatcher->dispatch(); |
270 bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented()
; | 269 bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented()
; |
271 | 270 |
272 if (event()->type() != EventTypeNames::click || event()->detail() != 2) | 271 if (event()->type() != EventTypeNames::click || event()->detail() != 2) |
273 return !swallowEvent; | 272 return !swallowEvent; |
274 | 273 |
275 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part | 274 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part |
276 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated | 275 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated |
277 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. | 276 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. |
278 RefPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); | 277 RefPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); |
279 doubleClickEvent->initMouseEvent(EventTypeNames::dblclick, event()->bubbles(
), event()->cancelable(), event()->view(), | 278 doubleClickEvent->initMouseEvent(EventTypeNames::dblclick, event()->bubbles(
), event()->cancelable(), event()->view(), |
280 event()->detail(), event()->screenX(), even
t()->screenY(), event()->clientX(), event()->clientY(), | 279 event()->detail(), event()->screenX(), even
t()->screenY(), event()->clientX(), event()->clientY(), |
281 event()->ctrlKey(), event()->altKey(), even
t()->shiftKey(), event()->metaKey(), | 280 event()->ctrlKey(), event()->altKey(), even
t()->shiftKey(), event()->metaKey(), |
282 event()->button(), relatedTarget); | 281 event()->button(), relatedTarget); |
283 if (event()->defaultHandled()) | 282 if (event()->defaultHandled()) |
284 doubleClickEvent->setDefaultHandled(); | 283 doubleClickEvent->setDefaultHandled(); |
285 EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediato
r::create(doubleClickEvent)); | 284 EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediato
r::create(doubleClickEvent)); |
286 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented
()) | 285 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented
()) |
287 return false; | 286 return false; |
288 return !swallowEvent; | 287 return !swallowEvent; |
289 } | 288 } |
290 | 289 |
291 } // namespace WebCore | 290 } // namespace WebCore |
OLD | NEW |