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 #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 "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/events/latency_info.h" | 22 #include "ui/events/latency_info.h" |
23 #include "ui/gfx/geometry/point.h" | 23 #include "ui/gfx/geometry/point.h" |
24 #include "ui/gfx/geometry/point_conversions.h" | 24 #include "ui/gfx/geometry/point_conversions.h" |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 class Transform; | 27 class Transform; |
28 } | 28 } |
29 | 29 |
30 namespace ui { | 30 namespace ui { |
31 class EventTarget; | 31 class EventTarget; |
| 32 class PointerEvent; |
32 enum class DomCode; | 33 enum class DomCode; |
33 | 34 |
34 class EVENTS_EXPORT Event { | 35 class EVENTS_EXPORT Event { |
35 public: | 36 public: |
36 static scoped_ptr<Event> Clone(const Event& event); | 37 static scoped_ptr<Event> Clone(const Event& event); |
37 | 38 |
38 virtual ~Event(); | 39 virtual ~Event(); |
39 | 40 |
40 class DispatcherApi { | 41 class DispatcherApi { |
41 public: | 42 public: |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return type_ == ET_SCROLL_FLING_CANCEL || | 192 return type_ == ET_SCROLL_FLING_CANCEL || |
192 type_ == ET_SCROLL_FLING_START; | 193 type_ == ET_SCROLL_FLING_START; |
193 } | 194 } |
194 | 195 |
195 bool IsMouseWheelEvent() const { | 196 bool IsMouseWheelEvent() const { |
196 return type_ == ET_MOUSEWHEEL; | 197 return type_ == ET_MOUSEWHEEL; |
197 } | 198 } |
198 | 199 |
199 bool IsLocatedEvent() const { | 200 bool IsLocatedEvent() const { |
200 return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() || | 201 return IsMouseEvent() || IsScrollEvent() || IsTouchEvent() || |
201 IsGestureEvent(); | 202 IsGestureEvent() || IsPointerEvent(); |
202 } | 203 } |
203 | 204 |
204 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() | 205 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() |
205 // must be true as a precondition to calling these methods. | 206 // must be true as a precondition to calling these methods. |
206 GestureEvent* AsGestureEvent(); | 207 GestureEvent* AsGestureEvent(); |
207 const GestureEvent* AsGestureEvent() const; | 208 const GestureEvent* AsGestureEvent() const; |
208 | 209 |
| 210 // Convenience methods to cast |this| to a PointerEvent. IsPointerEvent() |
| 211 // must be true as a precondition to calling these methods. |
| 212 PointerEvent* AsPointerEvent(); |
| 213 const PointerEvent* AsPointerEvent() const; |
| 214 |
209 // Returns true if the event has a valid |native_event_|. | 215 // Returns true if the event has a valid |native_event_|. |
210 bool HasNativeEvent() const; | 216 bool HasNativeEvent() const; |
211 | 217 |
212 // Immediately stops the propagation of the event. This must be called only | 218 // Immediately stops the propagation of the event. This must be called only |
213 // from an EventHandler during an event-dispatch. Any event handler that may | 219 // from an EventHandler during an event-dispatch. Any event handler that may |
214 // be in the list will not receive the event after this is called. | 220 // be in the list will not receive the event after this is called. |
215 // Note that StopPropagation() can be called only for cancelable events. | 221 // Note that StopPropagation() can be called only for cancelable events. |
216 void StopPropagation(); | 222 void StopPropagation(); |
217 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } | 223 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } |
218 | 224 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 bool should_remove_native_touch_id_mapping_; | 647 bool should_remove_native_touch_id_mapping_; |
642 | 648 |
643 // Structure for holding pointer details for implementing PointerEvents API. | 649 // Structure for holding pointer details for implementing PointerEvents API. |
644 PointerDetails pointer_details_; | 650 PointerDetails pointer_details_; |
645 }; | 651 }; |
646 | 652 |
647 class EVENTS_EXPORT PointerEvent : public LocatedEvent { | 653 class EVENTS_EXPORT PointerEvent : public LocatedEvent { |
648 public: | 654 public: |
649 static const int32_t kMousePointerId; | 655 static const int32_t kMousePointerId; |
650 | 656 |
| 657 explicit PointerEvent(const PointerEvent& pointer_event); |
651 explicit PointerEvent(const MouseEvent& mouse_event); | 658 explicit PointerEvent(const MouseEvent& mouse_event); |
652 explicit PointerEvent(const TouchEvent& touch_event); | 659 explicit PointerEvent(const TouchEvent& touch_event); |
653 | 660 |
654 int32_t pointer_id() const { return pointer_id_; } | 661 int32_t pointer_id() const { return pointer_id_; } |
655 const PointerDetails& pointer_details() const { return details_; } | 662 const PointerDetails& pointer_details() const { return details_; } |
656 | 663 |
657 private: | 664 private: |
658 int32_t pointer_id_; | 665 int32_t pointer_id_; |
659 PointerDetails details_; | 666 PointerDetails details_; |
660 }; | 667 }; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 | 940 |
934 const GestureEventDetails& details() const { return details_; } | 941 const GestureEventDetails& details() const { return details_; } |
935 | 942 |
936 private: | 943 private: |
937 GestureEventDetails details_; | 944 GestureEventDetails details_; |
938 }; | 945 }; |
939 | 946 |
940 } // namespace ui | 947 } // namespace ui |
941 | 948 |
942 #endif // UI_EVENTS_EVENT_H_ | 949 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |