Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: third_party/WebKit/Source/core/events/MouseEvent.h

Issue 2650403006: Remove PlatformMouseEvent and use WebMouseEvent instead (Closed)
Patch Set: Fix nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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; }
117 105
118 Node* toElement() const; 106 Node* toElement() const;
119 Node* fromElement() const; 107 Node* fromElement() const;
120 108
121 virtual DataTransfer* getDataTransfer() const { return nullptr; } 109 virtual DataTransfer* getDataTransfer() const { return nullptr; }
122 110
123 bool fromTouch() const { 111 bool fromTouch() const { return m_syntheticEventType == FromTouch; }
124 return m_syntheticEventType == PlatformMouseEvent::FromTouch;
125 }
126 112
127 const AtomicString& interfaceName() const override; 113 const AtomicString& interfaceName() const override;
128 114
129 bool isMouseEvent() const override; 115 bool isMouseEvent() const override;
130 int which() const final; 116 int which() const final;
131 117
132 EventDispatchMediator* createMediator() override; 118 EventDispatchMediator* createMediator() override;
133 119
134 int clickCount() { return detail(); } 120 int clickCount() { return detail(); }
135 121
136 const PlatformMouseEvent* mouseEvent() const { return m_mouseEvent.get(); } 122 const WebMouseEvent* nativeEvent() const { return m_nativeEvent.get(); }
137 123
138 enum class PositionType { 124 enum class PositionType {
139 Position, 125 Position,
140 // Positionless mouse events are used, for example, for 'click' events from 126 // 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 127 // keyboard input. It's kind of surprising for a mouse event not to have a
142 // position. 128 // position.
143 Positionless 129 Positionless
144 }; 130 };
145 131
146 // Note that these values are adjusted to counter the effects of zoom, so that 132 // 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
193 // the local frame. 179 // the local frame.
194 const DoublePoint& absoluteLocation() const { return m_absoluteLocation; } 180 const DoublePoint& absoluteLocation() const { return m_absoluteLocation; }
195 181
196 DECLARE_VIRTUAL_TRACE(); 182 DECLARE_VIRTUAL_TRACE();
197 183
198 protected: 184 protected:
199 MouseEvent(const AtomicString& type, 185 MouseEvent(const AtomicString& type,
200 bool canBubble, 186 bool canBubble,
201 bool cancelable, 187 bool cancelable,
202 AbstractView*, 188 AbstractView*,
203 PlatformMouseEvent::SyntheticEventType, 189 const WebMouseEvent&,
190 int detail,
204 const String& region, 191 const String& region,
205 const WebMouseEvent&); 192 EventTarget* relatedTarget);
206 193
207 MouseEvent(const AtomicString& type, 194 MouseEvent(const AtomicString& type,
208 bool canBubble, 195 bool canBubble,
209 bool cancelable, 196 bool cancelable,
210 AbstractView*, 197 AbstractView*,
211 int detail, 198 int detail,
212 int screenX, 199 int screenX,
213 int screenY, 200 int screenY,
214 int windowX, 201 int windowX,
215 int windowY, 202 int windowY,
216 int movementX, 203 int movementX,
217 int movementY, 204 int movementY,
218 PlatformEvent::Modifiers, 205 PlatformEvent::Modifiers,
219 short button, 206 short button,
220 unsigned short buttons, 207 unsigned short buttons,
221 EventTarget* relatedTarget, 208 EventTarget* relatedTarget,
222 TimeTicks platformTimeStamp, 209 TimeTicks platformTimeStamp,
223 PlatformMouseEvent::SyntheticEventType, 210 SyntheticEventType,
224 const String& region, 211 const String& region);
225 const PlatformMouseEvent*);
226 212
227 MouseEvent(const AtomicString& type, const MouseEventInit&); 213 MouseEvent(const AtomicString& type, const MouseEventInit&);
228 214
229 MouseEvent(); 215 MouseEvent();
230 216
231 short rawButton() const { return m_button; } 217 short rawButton() const { return m_button; }
232 218
233 private: 219 private:
234 friend class MouseEventDispatchMediator; 220 friend class MouseEventDispatchMediator;
235 void initMouseEventInternal(const AtomicString& type, 221 void initMouseEventInternal(const AtomicString& type,
(...skipping 24 matching lines...) Expand all
260 246
261 DoublePoint m_pageLocation; 247 DoublePoint m_pageLocation;
262 DoublePoint m_layerLocation; 248 DoublePoint m_layerLocation;
263 DoublePoint m_offsetLocation; 249 DoublePoint m_offsetLocation;
264 DoublePoint m_absoluteLocation; 250 DoublePoint m_absoluteLocation;
265 PositionType m_positionType; 251 PositionType m_positionType;
266 bool m_hasCachedRelativePosition; 252 bool m_hasCachedRelativePosition;
267 short m_button; 253 short m_button;
268 unsigned short m_buttons; 254 unsigned short m_buttons;
269 Member<EventTarget> m_relatedTarget; 255 Member<EventTarget> m_relatedTarget;
270 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; 256 SyntheticEventType m_syntheticEventType;
271 String m_region; 257 String m_region;
272 std::unique_ptr<PlatformMouseEvent> m_mouseEvent; 258 std::unique_ptr<WebMouseEvent> m_nativeEvent;
273 }; 259 };
274 260
275 class MouseEventDispatchMediator final : public EventDispatchMediator { 261 class MouseEventDispatchMediator final : public EventDispatchMediator {
276 public: 262 public:
277 static MouseEventDispatchMediator* create(MouseEvent*); 263 static MouseEventDispatchMediator* create(MouseEvent*);
278 264
279 private: 265 private:
280 explicit MouseEventDispatchMediator(MouseEvent*); 266 explicit MouseEventDispatchMediator(MouseEvent*);
281 MouseEvent& event() const; 267 MouseEvent& event() const;
282 268
283 DispatchEventResult dispatchEvent(EventDispatcher&) const override; 269 DispatchEventResult dispatchEvent(EventDispatcher&) const override;
284 }; 270 };
285 271
286 DEFINE_EVENT_TYPE_CASTS(MouseEvent); 272 DEFINE_EVENT_TYPE_CASTS(MouseEvent);
287 273
288 } // namespace blink 274 } // namespace blink
289 275
290 #endif // MouseEvent_h 276 #endif // MouseEvent_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/DragEvent.cpp ('k') | third_party/WebKit/Source/core/events/MouseEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698