Chromium Code Reviews| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 // Returns true if the event has a valid |native_event_|. | 205 // Returns true if the event has a valid |native_event_|. |
| 206 bool HasNativeEvent() const; | 206 bool HasNativeEvent() const; |
| 207 | 207 |
| 208 // Immediately stops the propagation of the event. This must be called only | 208 // Immediately stops the propagation of the event. This must be called only |
| 209 // from an EventHandler during an event-dispatch. Any event handler that may | 209 // from an EventHandler during an event-dispatch. Any event handler that may |
| 210 // be in the list will not receive the event after this is called. | 210 // be in the list will not receive the event after this is called. |
| 211 // Note that StopPropagation() can be called only for cancelable events. | 211 // Note that StopPropagation() can be called only for cancelable events. |
| 212 void StopPropagation(); | 212 void StopPropagation(); |
| 213 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } | 213 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } |
| 214 | 214 |
| 215 | 215 // Marks the event as having been handled. A handled event does not reach the |
| 216 // next event phase. For example, if an event is handled during the pre-target | 216 // next event phase. For example, if an event is handled during the pre-target |
| 217 // phase, then the event is dispatched to all pre-target handlers, but not to | 217 // phase, then the event is dispatched to all pre-target handlers, but not to |
| 218 // the target or post-target handlers. | 218 // the target or post-target handlers. |
| 219 // Note that SetHandled() can be called only for cancelable events. | 219 // Note that SetHandled() can be called only for cancelable events. |
| 220 void SetHandled(); | 220 void SetHandled(); |
| 221 bool handled() const { return result_ != ER_UNHANDLED; } | 221 bool handled() const { return result_ != ER_UNHANDLED; } |
| 222 | 222 |
| 223 protected: | 223 protected: |
| 224 Event(EventType type, base::TimeDelta time_stamp, int flags); | 224 Event(EventType type, base::TimeDelta time_stamp, int flags); |
| 225 Event(const base::NativeEvent& native_event, EventType type, int flags); | 225 Event(const base::NativeEvent& native_event, EventType type, int flags); |
| 226 Event(const Event& copy); | 226 Event(const Event& copy); |
| 227 void SetType(EventType type); | 227 void SetType(EventType type); |
| 228 void set_delete_native_event(bool delete_native_event) { | |
| 229 delete_native_event_ = delete_native_event; | |
| 230 } | |
| 231 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } | 228 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } |
| 232 | 229 |
| 233 void set_time_stamp(const base::TimeDelta& time_stamp) { | 230 void set_time_stamp(const base::TimeDelta& time_stamp) { |
| 234 time_stamp_ = time_stamp; | 231 time_stamp_ = time_stamp; |
| 235 } | 232 } |
| 236 | 233 |
| 237 void set_name(const std::string& name) { name_ = name; } | 234 void set_name(const std::string& name) { name_ = name; } |
| 238 | 235 |
| 239 private: | 236 private: |
| 240 friend class EventTestApi; | 237 friend class EventTestApi; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 // converted from |source| coordinate system to |target| coordinate system. | 485 // converted from |source| coordinate system to |target| coordinate system. |
| 489 template <class T> | 486 template <class T> |
| 490 TouchEvent(const TouchEvent& model, T* source, T* target) | 487 TouchEvent(const TouchEvent& model, T* source, T* target) |
| 491 : LocatedEvent(model, source, target), | 488 : LocatedEvent(model, source, target), |
| 492 touch_id_(model.touch_id_), | 489 touch_id_(model.touch_id_), |
| 493 unique_event_id_(model.unique_event_id_), | 490 unique_event_id_(model.unique_event_id_), |
| 494 radius_x_(model.radius_x_), | 491 radius_x_(model.radius_x_), |
| 495 radius_y_(model.radius_y_), | 492 radius_y_(model.radius_y_), |
| 496 rotation_angle_(model.rotation_angle_), | 493 rotation_angle_(model.rotation_angle_), |
| 497 force_(model.force_), | 494 force_(model.force_), |
| 498 may_cause_scrolling_(model.may_cause_scrolling_) {} | 495 should_remove_native_touch_id_mapping_(false) {} |
| 499 | 496 |
| 500 TouchEvent(EventType type, | 497 TouchEvent(EventType type, |
| 501 const gfx::PointF& location, | 498 const gfx::PointF& location, |
| 502 int touch_id, | 499 int touch_id, |
| 503 base::TimeDelta time_stamp); | 500 base::TimeDelta time_stamp); |
| 504 | 501 |
| 505 TouchEvent(EventType type, | 502 TouchEvent(EventType type, |
| 506 const gfx::PointF& location, | 503 const gfx::PointF& location, |
| 507 int flags, | 504 int flags, |
| 508 int touch_id, | 505 int touch_id, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 525 float rotation_angle() const { return rotation_angle_; } | 522 float rotation_angle() const { return rotation_angle_; } |
| 526 float force() const { return force_; } | 523 float force() const { return force_; } |
| 527 | 524 |
| 528 void set_may_cause_scrolling(bool causes) { may_cause_scrolling_ = causes; } | 525 void set_may_cause_scrolling(bool causes) { may_cause_scrolling_ = causes; } |
| 529 bool may_cause_scrolling() const { return may_cause_scrolling_; } | 526 bool may_cause_scrolling() const { return may_cause_scrolling_; } |
| 530 | 527 |
| 531 // Used for unit tests. | 528 // Used for unit tests. |
| 532 void set_radius_x(const float r) { radius_x_ = r; } | 529 void set_radius_x(const float r) { radius_x_ = r; } |
| 533 void set_radius_y(const float r) { radius_y_ = r; } | 530 void set_radius_y(const float r) { radius_y_ = r; } |
| 534 | 531 |
| 532 void set_should_remove_native_touch_id_mapping( | |
| 533 bool should_remove_native_touch_id_mapping) { | |
| 534 should_remove_native_touch_id_mapping_ = | |
| 535 should_remove_native_touch_id_mapping; | |
| 536 } | |
| 537 | |
| 535 // Overridden from LocatedEvent. | 538 // Overridden from LocatedEvent. |
| 536 void UpdateForRootTransform( | 539 void UpdateForRootTransform( |
| 537 const gfx::Transform& inverted_root_transform) override; | 540 const gfx::Transform& inverted_root_transform) override; |
| 538 | 541 |
| 539 // Marks the event as not participating in synchronous gesture recognition. | 542 // Marks the event as not participating in synchronous gesture recognition. |
| 540 void DisableSynchronousHandling(); | 543 void DisableSynchronousHandling(); |
| 541 bool synchronous_handling_disabled() const { | 544 bool synchronous_handling_disabled() const { |
| 542 return !!(result() & ER_DISABLE_SYNC_HANDLING); | 545 return !!(result() & ER_DISABLE_SYNC_HANDLING); |
| 543 } | 546 } |
| 544 | 547 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 563 // less than 180 and non-negative. | 566 // less than 180 and non-negative. |
| 564 float rotation_angle_; | 567 float rotation_angle_; |
| 565 | 568 |
| 566 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 569 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
| 567 float force_; | 570 float force_; |
| 568 | 571 |
| 569 // Whether the (unhandled) touch event will produce a scroll event (e.g., a | 572 // Whether the (unhandled) touch event will produce a scroll event (e.g., a |
| 570 // touchmove that exceeds the platform slop region, or a touchend that | 573 // touchmove that exceeds the platform slop region, or a touchend that |
| 571 // causes a fling). Defaults to false. | 574 // causes a fling). Defaults to false. |
| 572 bool may_cause_scrolling_; | 575 bool may_cause_scrolling_; |
| 576 | |
| 577 // True if this event should remove the mapping between the native | |
| 578 // event id and the chromium touch id. This should only be the case | |
|
sadrul
2015/01/26 18:49:46
s/chromium touch id/touch_id_/
tdresser
2015/01/27 21:43:05
Done.
| |
| 579 // for release and cancel events where the associated touch press | |
| 580 // event created a mapping between the native id and the chromium | |
| 581 // touch id. | |
| 582 bool should_remove_native_touch_id_mapping_; | |
| 573 }; | 583 }; |
| 574 | 584 |
| 575 // An interface that individual platforms can use to store additional data on | 585 // An interface that individual platforms can use to store additional data on |
| 576 // KeyEvent. | 586 // KeyEvent. |
| 577 // | 587 // |
| 578 // Currently only used in mojo. | 588 // Currently only used in mojo. |
| 579 class EVENTS_EXPORT ExtendedKeyEventData { | 589 class EVENTS_EXPORT ExtendedKeyEventData { |
| 580 public: | 590 public: |
| 581 virtual ~ExtendedKeyEventData() {} | 591 virtual ~ExtendedKeyEventData() {} |
| 582 | 592 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 | 875 |
| 866 const GestureEventDetails& details() const { return details_; } | 876 const GestureEventDetails& details() const { return details_; } |
| 867 | 877 |
| 868 private: | 878 private: |
| 869 GestureEventDetails details_; | 879 GestureEventDetails details_; |
| 870 }; | 880 }; |
| 871 | 881 |
| 872 } // namespace ui | 882 } // namespace ui |
| 873 | 883 |
| 874 #endif // UI_EVENTS_EVENT_H_ | 884 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |