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

Side by Side Diff: ui/events/event.h

Issue 2374213003: Refactored static_cast'ing of events to use the AsXXXEvent() methods. (Closed)
Patch Set: Added IsCancelModeEvent() & AsCancelModeEvent() methods to Event Created 4 years, 2 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
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/event.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_EVENTS_EVENT_H_ 5 #ifndef UI_EVENTS_EVENT_H_
6 #define UI_EVENTS_EVENT_H_ 6 #define UI_EVENTS_EVENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 12 matching lines...) Expand all
23 #include "ui/events/keycodes/keyboard_codes.h" 23 #include "ui/events/keycodes/keyboard_codes.h"
24 #include "ui/events/latency_info.h" 24 #include "ui/events/latency_info.h"
25 #include "ui/gfx/geometry/point.h" 25 #include "ui/gfx/geometry/point.h"
26 #include "ui/gfx/geometry/point_conversions.h" 26 #include "ui/gfx/geometry/point_conversions.h"
27 27
28 namespace gfx { 28 namespace gfx {
29 class Transform; 29 class Transform;
30 } 30 }
31 31
32 namespace ui { 32 namespace ui {
33 class CancelModeEvent;
33 class EventTarget; 34 class EventTarget;
34 class KeyEvent; 35 class KeyEvent;
35 class LocatedEvent; 36 class LocatedEvent;
36 class MouseEvent; 37 class MouseEvent;
37 class MouseWheelEvent; 38 class MouseWheelEvent;
38 class PointerEvent; 39 class PointerEvent;
39 class ScrollEvent; 40 class ScrollEvent;
40 class TouchEvent; 41 class TouchEvent;
41 enum class DomCode; 42 enum class DomCode;
42 class Event; 43 class Event;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 // The following methods return true if the respective keys were pressed at 102 // The following methods return true if the respective keys were pressed at
102 // the time the event was created. 103 // the time the event was created.
103 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } 104 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; }
104 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } 105 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; }
105 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } 106 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; }
106 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; } 107 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; }
107 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; } 108 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; }
108 bool IsCapsLockOn() const { return (flags_ & EF_CAPS_LOCK_ON) != 0; } 109 bool IsCapsLockOn() const { return (flags_ & EF_CAPS_LOCK_ON) != 0; }
109 110
111 bool IsCancelModeEvent() const {
112 return type_ == ET_CANCEL_MODE;
113 }
114
110 bool IsKeyEvent() const { 115 bool IsKeyEvent() const {
111 return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED; 116 return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
112 } 117 }
113 118
114 bool IsMouseEvent() const { 119 bool IsMouseEvent() const {
115 return type_ == ET_MOUSE_PRESSED || 120 return type_ == ET_MOUSE_PRESSED ||
116 type_ == ET_MOUSE_DRAGGED || 121 type_ == ET_MOUSE_DRAGGED ||
117 type_ == ET_MOUSE_RELEASED || 122 type_ == ET_MOUSE_RELEASED ||
118 type_ == ET_MOUSE_MOVED || 123 type_ == ET_MOUSE_MOVED ||
119 type_ == ET_MOUSE_ENTERED || 124 type_ == ET_MOUSE_ENTERED ||
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 218
214 bool IsMouseWheelEvent() const { 219 bool IsMouseWheelEvent() const {
215 return type_ == ET_MOUSEWHEEL; 220 return type_ == ET_MOUSEWHEEL;
216 } 221 }
217 222
218 bool IsLocatedEvent() const { 223 bool IsLocatedEvent() const {
219 return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() || 224 return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() ||
220 IsGestureEvent() || IsPointerEvent(); 225 IsGestureEvent() || IsPointerEvent();
221 } 226 }
222 227
228 // Convenience methods to cast |this| to a CancelModeEvent.
229 // IsCancelModeEvent() must be true as a precondition to calling these
230 // methods.
231 CancelModeEvent* AsCancelModeEvent();
232 const CancelModeEvent* AsCancelModeEvent() const;
233
223 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() 234 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent()
224 // must be true as a precondition to calling these methods. 235 // must be true as a precondition to calling these methods.
225 GestureEvent* AsGestureEvent(); 236 GestureEvent* AsGestureEvent();
226 const GestureEvent* AsGestureEvent() const; 237 const GestureEvent* AsGestureEvent() const;
227 238
228 // Convenience methods to cast |this| to a KeyEvent. IsKeyEvent() 239 // Convenience methods to cast |this| to a KeyEvent. IsKeyEvent()
229 // must be true as a precondition to calling these methods. 240 // must be true as a precondition to calling these methods.
230 KeyEvent* AsKeyEvent(); 241 KeyEvent* AsKeyEvent();
231 const KeyEvent* AsKeyEvent() const; 242 const KeyEvent* AsKeyEvent() const;
232 243
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // dispatched. This field gets a non-zero value only for gestures that are 1037 // dispatched. This field gets a non-zero value only for gestures that are
1027 // released through TouchDispositionGestureFilter::SendGesture. The gesture 1038 // released through TouchDispositionGestureFilter::SendGesture. The gesture
1028 // events that aren't fired directly in response to processing a touch-event 1039 // events that aren't fired directly in response to processing a touch-event
1029 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. 1040 // (e.g. timer fired ones), this id is zero. See crbug.com/618738.
1030 uint32_t unique_touch_event_id_; 1041 uint32_t unique_touch_event_id_;
1031 }; 1042 };
1032 1043
1033 } // namespace ui 1044 } // namespace ui
1034 1045
1035 #endif // UI_EVENTS_EVENT_H_ 1046 #endif // UI_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/event.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698