OLD | NEW |
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 #include "ui/base/events/event_utils.h" | 5 #include "ui/base/events/event_utils.h" |
6 | 6 |
7 #include "ui/base/events/event.h" | 7 #include "ui/base/events/event.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
11 namespace { | 11 namespace { |
12 int g_custom_event_types = ET_LAST; | 12 int g_custom_event_types = ET_LAST; |
13 } // namespace | 13 } // namespace |
14 | 14 |
15 bool EventCanceledDefaultHandling(const Event& event) { | 15 bool EventCanceledDefaultHandling(const Event& event) { |
16 return event.phase() == EP_POSTTARGET && event.result() != ER_UNHANDLED; | 16 return event.phase() == EP_POSTTARGET && event.result() != ER_UNHANDLED; |
17 } | 17 } |
18 | 18 |
19 int RegisterCustomEventType() { | 19 int RegisterCustomEventType() { |
20 return ++g_custom_event_types; | 20 return ++g_custom_event_types; |
21 } | 21 } |
22 | 22 |
23 base::TimeDelta EventTimeForNow() { | 23 base::TimeDelta EventTimeForNow() { |
24 return base::TimeDelta::FromInternalValue( | 24 return base::TimeDelta::FromInternalValue( |
25 base::TimeTicks::Now().ToInternalValue()); | 25 base::TimeTicks::Now().ToInternalValue()); |
26 } | 26 } |
27 | 27 |
| 28 bool IsKeyEventType(EventType type) { |
| 29 return type == ET_KEY_PRESSED || |
| 30 type == ET_KEY_RELEASED || |
| 31 type == ET_TRANSLATED_KEY_PRESS || |
| 32 type == ET_TRANSLATED_KEY_RELEASE; |
| 33 } |
| 34 |
| 35 bool IsMouseEventType(EventType type) { |
| 36 return type == ET_MOUSE_PRESSED || |
| 37 type == ET_MOUSE_DRAGGED || |
| 38 type == ET_MOUSE_RELEASED || |
| 39 type == ET_MOUSE_MOVED || |
| 40 type == ET_MOUSE_ENTERED || |
| 41 type == ET_MOUSE_EXITED || |
| 42 type == ET_MOUSEWHEEL || |
| 43 type == ET_MOUSE_CAPTURE_CHANGED; |
| 44 } |
| 45 |
| 46 bool IsTouchEventType(EventType type) { |
| 47 return type == ET_TOUCH_RELEASED || |
| 48 type == ET_TOUCH_PRESSED || |
| 49 type == ET_TOUCH_MOVED || |
| 50 type == ET_TOUCH_STATIONARY || |
| 51 type == ET_TOUCH_CANCELLED; |
| 52 } |
| 53 |
28 } // namespace ui | 54 } // namespace ui |
OLD | NEW |