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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 const AtomicString& MouseEvent::interfaceName() const { | 266 const AtomicString& MouseEvent::interfaceName() const { |
267 return EventNames::MouseEvent; | 267 return EventNames::MouseEvent; |
268 } | 268 } |
269 | 269 |
270 bool MouseEvent::isMouseEvent() const { | 270 bool MouseEvent::isMouseEvent() const { |
271 return true; | 271 return true; |
272 } | 272 } |
273 | 273 |
274 int MouseEvent::which() const { | 274 int MouseEvent::which() const { |
275 // For the DOM, the return values for left, middle and right mouse buttons are
0, 1, 2, respectively. | 275 // For the DOM, the return values for left, middle and right mouse buttons are |
276 // For the Netscape "which" property, the return values for left, middle and r
ight mouse buttons are 1, 2, 3, respectively. | 276 // 0, 1, 2, respectively. |
| 277 // For the Netscape "which" property, the return values for left, middle and |
| 278 // right mouse buttons are 1, 2, 3, respectively. |
277 // So we must add 1. | 279 // So we must add 1. |
278 return m_button + 1; | 280 return m_button + 1; |
279 } | 281 } |
280 | 282 |
281 Node* MouseEvent::toElement() const { | 283 Node* MouseEvent::toElement() const { |
282 // MSIE extension - "the object toward which the user is moving the mouse poin
ter" | 284 // MSIE extension - "the object toward which the user is moving the mouse |
| 285 // pointer" |
283 if (type() == EventTypeNames::mouseout || | 286 if (type() == EventTypeNames::mouseout || |
284 type() == EventTypeNames::mouseleave) | 287 type() == EventTypeNames::mouseleave) |
285 return relatedTarget() ? relatedTarget()->toNode() : nullptr; | 288 return relatedTarget() ? relatedTarget()->toNode() : nullptr; |
286 | 289 |
287 return target() ? target()->toNode() : nullptr; | 290 return target() ? target()->toNode() : nullptr; |
288 } | 291 } |
289 | 292 |
290 Node* MouseEvent::fromElement() const { | 293 Node* MouseEvent::fromElement() const { |
291 // MSIE extension - "object from which activation or the mouse pointer is exit
ing during the event" (huh?) | 294 // MSIE extension - "object from which activation or the mouse pointer is |
| 295 // exiting during the event" (huh?) |
292 if (type() != EventTypeNames::mouseout && | 296 if (type() != EventTypeNames::mouseout && |
293 type() != EventTypeNames::mouseleave) | 297 type() != EventTypeNames::mouseleave) |
294 return relatedTarget() ? relatedTarget()->toNode() : nullptr; | 298 return relatedTarget() ? relatedTarget()->toNode() : nullptr; |
295 | 299 |
296 return target() ? target()->toNode() : nullptr; | 300 return target() ? target()->toNode() : nullptr; |
297 } | 301 } |
298 | 302 |
299 DEFINE_TRACE(MouseEvent) { | 303 DEFINE_TRACE(MouseEvent) { |
300 visitor->trace(m_relatedTarget); | 304 visitor->trace(m_relatedTarget); |
301 MouseRelatedEvent::trace(visitor); | 305 MouseRelatedEvent::trace(visitor); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 DCHECK(!mouseEvent.target() || | 339 DCHECK(!mouseEvent.target() || |
336 mouseEvent.target() != mouseEvent.relatedTarget()); | 340 mouseEvent.target() != mouseEvent.relatedTarget()); |
337 | 341 |
338 EventTarget* relatedTarget = mouseEvent.relatedTarget(); | 342 EventTarget* relatedTarget = mouseEvent.relatedTarget(); |
339 | 343 |
340 DispatchEventResult dispatchResult = dispatcher.dispatch(); | 344 DispatchEventResult dispatchResult = dispatcher.dispatch(); |
341 | 345 |
342 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) | 346 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) |
343 return dispatchResult; | 347 return dispatchResult; |
344 | 348 |
345 // Special case: If it's a double click event, we also send the dblclick event
. This is not part | 349 // Special case: If it's a double click event, we also send the dblclick |
346 // of the DOM specs, but is used for compatibility with the ondblclick="" attr
ibute. This is treated | 350 // event. This is not part of the DOM specs, but is used for compatibility |
347 // as a separate event in other DOM-compliant browsers like Firefox, and so we
do the same. | 351 // with the ondblclick="" attribute. This is treated as a separate event in |
| 352 // other DOM-compliant browsers like Firefox, and so we do the same. |
348 MouseEvent* doubleClickEvent = MouseEvent::create(); | 353 MouseEvent* doubleClickEvent = MouseEvent::create(); |
349 doubleClickEvent->initMouseEventInternal( | 354 doubleClickEvent->initMouseEventInternal( |
350 EventTypeNames::dblclick, mouseEvent.bubbles(), mouseEvent.cancelable(), | 355 EventTypeNames::dblclick, mouseEvent.bubbles(), mouseEvent.cancelable(), |
351 mouseEvent.view(), mouseEvent.detail(), mouseEvent.screenX(), | 356 mouseEvent.view(), mouseEvent.detail(), mouseEvent.screenX(), |
352 mouseEvent.screenY(), mouseEvent.clientX(), mouseEvent.clientY(), | 357 mouseEvent.screenY(), mouseEvent.clientX(), mouseEvent.clientY(), |
353 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, | 358 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, |
354 mouseEvent.sourceCapabilities(), mouseEvent.buttons()); | 359 mouseEvent.sourceCapabilities(), mouseEvent.buttons()); |
355 | 360 |
356 // Inherit the trusted status from the original event. | 361 // Inherit the trusted status from the original event. |
357 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); | 362 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); |
358 if (mouseEvent.defaultHandled()) | 363 if (mouseEvent.defaultHandled()) |
359 doubleClickEvent->setDefaultHandled(); | 364 doubleClickEvent->setDefaultHandled(); |
360 DispatchEventResult doubleClickDispatchResult = | 365 DispatchEventResult doubleClickDispatchResult = |
361 EventDispatcher::dispatchEvent( | 366 EventDispatcher::dispatchEvent( |
362 dispatcher.node(), | 367 dispatcher.node(), |
363 MouseEventDispatchMediator::create(doubleClickEvent)); | 368 MouseEventDispatchMediator::create(doubleClickEvent)); |
364 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled) | 369 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled) |
365 return doubleClickDispatchResult; | 370 return doubleClickDispatchResult; |
366 return dispatchResult; | 371 return dispatchResult; |
367 } | 372 } |
368 | 373 |
369 } // namespace blink | 374 } // namespace blink |
OLD | NEW |