| 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, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/events/MouseRelatedEvent.h" | 30 #include "core/events/MouseRelatedEvent.h" |
| 31 #include "platform/PlatformMouseEvent.h" | 31 #include "platform/PlatformMouseEvent.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 class DataTransfer; | 34 class DataTransfer; |
| 35 class EventDispatcher; | 35 class EventDispatcher; |
| 36 | 36 |
| 37 class CORE_EXPORT MouseEvent : public MouseRelatedEvent { | 37 class CORE_EXPORT MouseEvent : public MouseRelatedEvent { |
| 38 DEFINE_WRAPPERTYPEINFO(); | 38 DEFINE_WRAPPERTYPEINFO(); |
| 39 public: | 39 public: |
| 40 static PassRefPtrWillBeRawPtr<MouseEvent> create() | 40 static RawPtr<MouseEvent> create() |
| 41 { | 41 { |
| 42 return adoptRefWillBeNoop(new MouseEvent); | 42 return (new MouseEvent); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // TODO(mustaq): Should replace most/all of these params with a MouseEventIn
it. | 45 // TODO(mustaq): Should replace most/all of these params with a MouseEventIn
it. |
| 46 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, b
ool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 46 static RawPtr<MouseEvent> create(const AtomicString& type, bool canBubble, b
ool cancelable, RawPtr<AbstractView>, |
| 47 int detail, int screenX, int screenY, int windowX, int windowY, | 47 int detail, int screenX, int screenY, int windowX, int windowY, |
| 48 int movementX, int movementY, PlatformEvent::Modifiers, | 48 int movementX, int movementY, PlatformEvent::Modifiers, |
| 49 short button, unsigned short buttons, | 49 short button, unsigned short buttons, |
| 50 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, | 50 RawPtr<EventTarget> relatedTarget, |
| 51 double platformTimeStamp, | 51 double platformTimeStamp, |
| 52 PlatformMouseEvent::SyntheticEventType = PlatformMouseEvent::RealOrIndis
tinguishable); | 52 PlatformMouseEvent::SyntheticEventType = PlatformMouseEvent::RealOrIndis
tinguishable); |
| 53 | 53 |
| 54 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail,
PassRefPtrWillBeRawPtr<Node> relatedTarget); | 54 static RawPtr<MouseEvent> create(const AtomicString& eventType, RawPtr<Abstr
actView>, const PlatformMouseEvent&, int detail, RawPtr<Node> relatedTarget); |
| 55 | 55 |
| 56 static PassRefPtrWillBeRawPtr<MouseEvent> create(ScriptState*, const AtomicS
tring& eventType, const MouseEventInit&); | 56 static RawPtr<MouseEvent> create(ScriptState*, const AtomicString& eventType
, const MouseEventInit&); |
| 57 | 57 |
| 58 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyi
ngEvent, SimulatedClickCreationScope); | 58 static RawPtr<MouseEvent> create(const AtomicString& eventType, RawPtr<Abstr
actView>, RawPtr<Event> underlyingEvent, SimulatedClickCreationScope); |
| 59 | 59 |
| 60 ~MouseEvent() override; | 60 ~MouseEvent() override; |
| 61 | 61 |
| 62 static unsigned short platformModifiersToButtons(unsigned modifiers); | 62 static unsigned short platformModifiersToButtons(unsigned modifiers); |
| 63 static unsigned short buttonToButtons(short button); | 63 static unsigned short buttonToButtons(short button); |
| 64 | 64 |
| 65 void initMouseEvent(ScriptState*, const AtomicString& type, bool canBubble,
bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 65 void initMouseEvent(ScriptState*, const AtomicString& type, bool canBubble,
bool cancelable, RawPtr<AbstractView>, |
| 66 int detail, int screenX, int screenY, int clientX, int clientY, | 66 int detail, int screenX, int screenY, int clientX, int clientY, |
| 67 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 67 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
| 68 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigne
d short buttons = 0); | 68 short button, RawPtr<EventTarget> relatedTarget, unsigned short buttons
= 0); |
| 69 | 69 |
| 70 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused
own/up, maybe others), | 70 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused
own/up, maybe others), |
| 71 // but we will match the standard DOM. | 71 // but we will match the standard DOM. |
| 72 virtual short button() const { return m_button == -1 ? 0 : m_button; } | 72 virtual short button() const { return m_button == -1 ? 0 : m_button; } |
| 73 unsigned short buttons() const { return m_buttons; } | 73 unsigned short buttons() const { return m_buttons; } |
| 74 bool buttonDown() const { return m_button != -1; } | 74 bool buttonDown() const { return m_button != -1; } |
| 75 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 75 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
| 76 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m
_relatedTarget = relatedTarget; } | 76 void setRelatedTarget(RawPtr<EventTarget> relatedTarget) { m_relatedTarget =
relatedTarget; } |
| 77 PlatformMouseEvent::SyntheticEventType syntheticEventType() const { return m
_syntheticEventType; } | 77 PlatformMouseEvent::SyntheticEventType syntheticEventType() const { return m
_syntheticEventType; } |
| 78 | 78 |
| 79 Node* toElement() const; | 79 Node* toElement() const; |
| 80 Node* fromElement() const; | 80 Node* fromElement() const; |
| 81 | 81 |
| 82 virtual DataTransfer* dataTransfer() const { return nullptr; } | 82 virtual DataTransfer* dataTransfer() const { return nullptr; } |
| 83 | 83 |
| 84 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::
FromTouch; } | 84 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::
FromTouch; } |
| 85 | 85 |
| 86 const AtomicString& interfaceName() const override; | 86 const AtomicString& interfaceName() const override; |
| 87 | 87 |
| 88 bool isMouseEvent() const override; | 88 bool isMouseEvent() const override; |
| 89 int which() const final; | 89 int which() const final; |
| 90 | 90 |
| 91 PassRefPtrWillBeRawPtr<EventDispatchMediator> createMediator() override; | 91 RawPtr<EventDispatchMediator> createMediator() override; |
| 92 | 92 |
| 93 enum class Buttons : unsigned { | 93 enum class Buttons : unsigned { |
| 94 None = 0, | 94 None = 0, |
| 95 Left = 1 << 0, | 95 Left = 1 << 0, |
| 96 Right = 1 << 1, | 96 Right = 1 << 1, |
| 97 Middle = 1 << 2 | 97 Middle = 1 << 2 |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 DECLARE_VIRTUAL_TRACE(); | 100 DECLARE_VIRTUAL_TRACE(); |
| 101 | 101 |
| 102 protected: | 102 protected: |
| 103 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe
fPtrWillBeRawPtr<AbstractView>, | 103 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, RawPtr
<AbstractView>, |
| 104 int detail, int screenX, int screenY, int windowX, int windowY, | 104 int detail, int screenX, int screenY, int windowX, int windowY, |
| 105 int movementX, int movementY, | 105 int movementX, int movementY, |
| 106 PlatformEvent::Modifiers, short button, unsigned short buttons, | 106 PlatformEvent::Modifiers, short button, unsigned short buttons, |
| 107 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, | 107 RawPtr<EventTarget> relatedTarget, |
| 108 double platformTimeStamp, | 108 double platformTimeStamp, |
| 109 PlatformMouseEvent::SyntheticEventType); | 109 PlatformMouseEvent::SyntheticEventType); |
| 110 | 110 |
| 111 MouseEvent(const AtomicString& type, const MouseEventInit&); | 111 MouseEvent(const AtomicString& type, const MouseEventInit&); |
| 112 | 112 |
| 113 MouseEvent(); | 113 MouseEvent(); |
| 114 | 114 |
| 115 short rawButton() const { return m_button; } | 115 short rawButton() const { return m_button; } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 friend class MouseEventDispatchMediator; | 118 friend class MouseEventDispatchMediator; |
| 119 void initMouseEventInternal(const AtomicString& type, bool canBubble, bool c
ancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 119 void initMouseEventInternal(const AtomicString& type, bool canBubble, bool c
ancelable, RawPtr<AbstractView>, |
| 120 int detail, int screenX, int screenY, int clientX, int clientY, | 120 int detail, int screenX, int screenY, int clientX, int clientY, |
| 121 PlatformEvent::Modifiers, | 121 PlatformEvent::Modifiers, |
| 122 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, InputDe
viceCapabilities* sourceCapabilities, unsigned short buttons = 0); | 122 short button, RawPtr<EventTarget> relatedTarget, InputDeviceCapabilities
* sourceCapabilities, unsigned short buttons = 0); |
| 123 | 123 |
| 124 short m_button; | 124 short m_button; |
| 125 unsigned short m_buttons; | 125 unsigned short m_buttons; |
| 126 RefPtrWillBeMember<EventTarget> m_relatedTarget; | 126 Member<EventTarget> m_relatedTarget; |
| 127 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; | 127 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 class MouseEventDispatchMediator final : public EventDispatchMediator { | 130 class MouseEventDispatchMediator final : public EventDispatchMediator { |
| 131 public: | 131 public: |
| 132 static PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> create(PassRefPtrW
illBeRawPtr<MouseEvent>); | 132 static RawPtr<MouseEventDispatchMediator> create(RawPtr<MouseEvent>); |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 explicit MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent>); | 135 explicit MouseEventDispatchMediator(RawPtr<MouseEvent>); |
| 136 MouseEvent& event() const; | 136 MouseEvent& event() const; |
| 137 | 137 |
| 138 bool dispatchEvent(EventDispatcher&) const override; | 138 bool dispatchEvent(EventDispatcher&) const override; |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 DEFINE_EVENT_TYPE_CASTS(MouseEvent); | 141 DEFINE_EVENT_TYPE_CASTS(MouseEvent); |
| 142 | 142 |
| 143 } // namespace blink | 143 } // namespace blink |
| 144 | 144 |
| 145 #endif // MouseEvent_h | 145 #endif // MouseEvent_h |
| OLD | NEW |