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 10 matching lines...) Expand all Loading... | |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef MouseEvent_h | 24 #ifndef MouseEvent_h |
25 #define MouseEvent_h | 25 #define MouseEvent_h |
26 | 26 |
27 #include "core/CoreExport.h" | 27 #include "core/CoreExport.h" |
28 #include "core/events/EventDispatchMediator.h" | 28 #include "core/events/EventDispatchMediator.h" |
29 #include "core/events/MouseEventInit.h" | 29 #include "core/events/MouseEventInit.h" |
30 #include "core/events/UIEventWithKeyState.h" | 30 #include "core/events/UIEventWithKeyState.h" |
31 #include "platform/PlatformMouseEvent.h" | |
32 #include "public/platform/WebMouseEvent.h" | 31 #include "public/platform/WebMouseEvent.h" |
33 | 32 |
34 namespace blink { | 33 namespace blink { |
35 class DataTransfer; | 34 class DataTransfer; |
36 class EventDispatcher; | 35 class EventDispatcher; |
37 | 36 |
38 class CORE_EXPORT MouseEvent : public UIEventWithKeyState { | 37 class CORE_EXPORT MouseEvent : public UIEventWithKeyState { |
39 DEFINE_WRAPPERTYPEINFO(); | 38 DEFINE_WRAPPERTYPEINFO(); |
40 | 39 |
41 public: | 40 public: |
41 enum SyntheticEventType { | |
42 // Real mouse input events or synthetic events that behave just like real | |
43 // events | |
44 RealOrIndistinguishable, | |
45 // Synthetic mouse events derived from touch input | |
46 FromTouch, | |
47 // Synthetic mouse events generated without a position, for example those | |
48 // generated from keyboard input. | |
49 Positionless, | |
50 }; | |
51 | |
42 static MouseEvent* create() { return new MouseEvent; } | 52 static MouseEvent* create() { return new MouseEvent; } |
43 | 53 |
44 // TODO(mustaq): Should replace most/all of these params with a | |
45 // MouseEventInit. | |
46 static MouseEvent* create(const AtomicString& type, | |
47 bool canBubble, | |
48 bool cancelable, | |
49 AbstractView*, | |
50 int detail, | |
51 int screenX, | |
52 int screenY, | |
53 int windowX, | |
54 int windowY, | |
55 int movementX, | |
56 int movementY, | |
57 PlatformEvent::Modifiers, | |
58 short button, | |
59 unsigned short buttons, | |
60 EventTarget* relatedTarget, | |
61 TimeTicks platformTimeStamp, | |
62 PlatformMouseEvent::SyntheticEventType, | |
63 const String& region, | |
64 const PlatformMouseEvent*); | |
65 | |
66 static MouseEvent* create(const AtomicString& eventType, | 54 static MouseEvent* create(const AtomicString& eventType, |
67 AbstractView*, | 55 AbstractView*, |
68 const PlatformMouseEvent&, | 56 const WebMouseEvent&, |
69 int detail, | 57 int detail, |
58 const String& canvasRegionId, | |
70 Node* relatedTarget); | 59 Node* relatedTarget); |
71 | 60 |
72 static MouseEvent* create(ScriptState*, | 61 static MouseEvent* create(ScriptState*, |
73 const AtomicString& eventType, | 62 const AtomicString& eventType, |
74 const MouseEventInit&); | 63 const MouseEventInit&); |
75 | 64 |
76 static MouseEvent* create(const AtomicString& eventType, | 65 static MouseEvent* create(const AtomicString& eventType, |
77 AbstractView*, | 66 AbstractView*, |
78 Event* underlyingEvent, | 67 Event* underlyingEvent, |
79 SimulatedClickCreationScope); | 68 SimulatedClickCreationScope); |
(...skipping 22 matching lines...) Expand all Loading... | |
102 | 91 |
103 // WinIE uses 1,4,2 for left/middle/right but not for click (just for | 92 // WinIE uses 1,4,2 for left/middle/right but not for click (just for |
104 // mousedown/up, maybe others), but we will match the standard DOM. | 93 // mousedown/up, maybe others), but we will match the standard DOM. |
105 virtual short button() const { return m_button == -1 ? 0 : m_button; } | 94 virtual short button() const { return m_button == -1 ? 0 : m_button; } |
106 unsigned short buttons() const { return m_buttons; } | 95 unsigned short buttons() const { return m_buttons; } |
107 bool buttonDown() const { return m_button != -1; } | 96 bool buttonDown() const { return m_button != -1; } |
108 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 97 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
109 void setRelatedTarget(EventTarget* relatedTarget) { | 98 void setRelatedTarget(EventTarget* relatedTarget) { |
110 m_relatedTarget = relatedTarget; | 99 m_relatedTarget = relatedTarget; |
111 } | 100 } |
112 PlatformMouseEvent::SyntheticEventType getSyntheticEventType() const { | 101 SyntheticEventType getSyntheticEventType() const { |
113 return m_syntheticEventType; | 102 return m_syntheticEventType; |
114 } | 103 } |
115 const String& region() const { return m_region; } | 104 const String& region() const { return m_region; } |
116 void setRegion(const String& region) { m_region = region; } | 105 void setRegion(const String& region) { m_region = region; } |
mustaq
2017/01/27 16:53:44
Does anybody use setRegion? I didn't find any. If
dtapuska
2017/01/27 21:00:00
Done.
| |
117 | 106 |
118 Node* toElement() const; | 107 Node* toElement() const; |
119 Node* fromElement() const; | 108 Node* fromElement() const; |
120 | 109 |
121 virtual DataTransfer* getDataTransfer() const { return nullptr; } | 110 virtual DataTransfer* getDataTransfer() const { return nullptr; } |
122 | 111 |
123 bool fromTouch() const { | 112 bool fromTouch() const { return m_syntheticEventType == FromTouch; } |
124 return m_syntheticEventType == PlatformMouseEvent::FromTouch; | |
125 } | |
126 | 113 |
127 const AtomicString& interfaceName() const override; | 114 const AtomicString& interfaceName() const override; |
128 | 115 |
129 bool isMouseEvent() const override; | 116 bool isMouseEvent() const override; |
130 int which() const final; | 117 int which() const final; |
131 | 118 |
132 EventDispatchMediator* createMediator() override; | 119 EventDispatchMediator* createMediator() override; |
133 | 120 |
134 int clickCount() { return detail(); } | 121 int clickCount() { return detail(); } |
135 | 122 |
136 const PlatformMouseEvent* mouseEvent() const { return m_mouseEvent.get(); } | 123 const WebMouseEvent* nativeEvent() const { return m_nativeEvent.get(); } |
137 | 124 |
138 enum class PositionType { | 125 enum class PositionType { |
139 Position, | 126 Position, |
140 // Positionless mouse events are used, for example, for 'click' events from | 127 // Positionless mouse events are used, for example, for 'click' events from |
141 // keyboard input. It's kind of surprising for a mouse event not to have a | 128 // keyboard input. It's kind of surprising for a mouse event not to have a |
142 // position. | 129 // position. |
143 Positionless | 130 Positionless |
144 }; | 131 }; |
145 | 132 |
146 // Note that these values are adjusted to counter the effects of zoom, so that | 133 // Note that these values are adjusted to counter the effects of zoom, so that |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 // the local frame. | 180 // the local frame. |
194 const DoublePoint& absoluteLocation() const { return m_absoluteLocation; } | 181 const DoublePoint& absoluteLocation() const { return m_absoluteLocation; } |
195 | 182 |
196 DECLARE_VIRTUAL_TRACE(); | 183 DECLARE_VIRTUAL_TRACE(); |
197 | 184 |
198 protected: | 185 protected: |
199 MouseEvent(const AtomicString& type, | 186 MouseEvent(const AtomicString& type, |
200 bool canBubble, | 187 bool canBubble, |
201 bool cancelable, | 188 bool cancelable, |
202 AbstractView*, | 189 AbstractView*, |
203 PlatformMouseEvent::SyntheticEventType, | 190 const WebMouseEvent&, |
191 int detail, | |
204 const String& region, | 192 const String& region, |
205 const WebMouseEvent&); | 193 EventTarget* relatedTarget); |
206 | 194 |
207 MouseEvent(const AtomicString& type, | 195 MouseEvent(const AtomicString& type, |
208 bool canBubble, | 196 bool canBubble, |
209 bool cancelable, | 197 bool cancelable, |
210 AbstractView*, | 198 AbstractView*, |
211 int detail, | 199 int detail, |
212 int screenX, | 200 int screenX, |
213 int screenY, | 201 int screenY, |
214 int windowX, | 202 int windowX, |
215 int windowY, | 203 int windowY, |
216 int movementX, | 204 int movementX, |
217 int movementY, | 205 int movementY, |
218 PlatformEvent::Modifiers, | 206 PlatformEvent::Modifiers, |
219 short button, | 207 short button, |
220 unsigned short buttons, | 208 unsigned short buttons, |
221 EventTarget* relatedTarget, | 209 EventTarget* relatedTarget, |
222 TimeTicks platformTimeStamp, | 210 TimeTicks platformTimeStamp, |
223 PlatformMouseEvent::SyntheticEventType, | 211 SyntheticEventType, |
224 const String& region, | 212 const String& region); |
225 const PlatformMouseEvent*); | |
226 | 213 |
227 MouseEvent(const AtomicString& type, const MouseEventInit&); | 214 MouseEvent(const AtomicString& type, const MouseEventInit&); |
228 | 215 |
229 MouseEvent(); | 216 MouseEvent(); |
230 | 217 |
231 short rawButton() const { return m_button; } | 218 short rawButton() const { return m_button; } |
232 | 219 |
233 private: | 220 private: |
234 friend class MouseEventDispatchMediator; | 221 friend class MouseEventDispatchMediator; |
235 void initMouseEventInternal(const AtomicString& type, | 222 void initMouseEventInternal(const AtomicString& type, |
(...skipping 24 matching lines...) Expand all Loading... | |
260 | 247 |
261 DoublePoint m_pageLocation; | 248 DoublePoint m_pageLocation; |
262 DoublePoint m_layerLocation; | 249 DoublePoint m_layerLocation; |
263 DoublePoint m_offsetLocation; | 250 DoublePoint m_offsetLocation; |
264 DoublePoint m_absoluteLocation; | 251 DoublePoint m_absoluteLocation; |
265 PositionType m_positionType; | 252 PositionType m_positionType; |
266 bool m_hasCachedRelativePosition; | 253 bool m_hasCachedRelativePosition; |
267 short m_button; | 254 short m_button; |
268 unsigned short m_buttons; | 255 unsigned short m_buttons; |
269 Member<EventTarget> m_relatedTarget; | 256 Member<EventTarget> m_relatedTarget; |
270 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; | 257 SyntheticEventType m_syntheticEventType; |
271 String m_region; | 258 String m_region; |
272 std::unique_ptr<PlatformMouseEvent> m_mouseEvent; | 259 std::unique_ptr<WebMouseEvent> m_nativeEvent; |
273 }; | 260 }; |
274 | 261 |
275 class MouseEventDispatchMediator final : public EventDispatchMediator { | 262 class MouseEventDispatchMediator final : public EventDispatchMediator { |
276 public: | 263 public: |
277 static MouseEventDispatchMediator* create(MouseEvent*); | 264 static MouseEventDispatchMediator* create(MouseEvent*); |
278 | 265 |
279 private: | 266 private: |
280 explicit MouseEventDispatchMediator(MouseEvent*); | 267 explicit MouseEventDispatchMediator(MouseEvent*); |
281 MouseEvent& event() const; | 268 MouseEvent& event() const; |
282 | 269 |
283 DispatchEventResult dispatchEvent(EventDispatcher&) const override; | 270 DispatchEventResult dispatchEvent(EventDispatcher&) const override; |
284 }; | 271 }; |
285 | 272 |
286 DEFINE_EVENT_TYPE_CASTS(MouseEvent); | 273 DEFINE_EVENT_TYPE_CASTS(MouseEvent); |
287 | 274 |
288 } // namespace blink | 275 } // namespace blink |
289 | 276 |
290 #endif // MouseEvent_h | 277 #endif // MouseEvent_h |
OLD | NEW |