| 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/events/event.h" | 5 #include "ui/events/event.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 | 10 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 const PointerId PointerDetails::kUnknownPointerId = -1; | 565 const PointerId PointerDetails::kUnknownPointerId = -1; |
| 566 | 566 |
| 567 //////////////////////////////////////////////////////////////////////////////// | 567 //////////////////////////////////////////////////////////////////////////////// |
| 568 // MouseEvent | 568 // MouseEvent |
| 569 | 569 |
| 570 MouseEvent::MouseEvent(const base::NativeEvent& native_event) | 570 MouseEvent::MouseEvent(const base::NativeEvent& native_event) |
| 571 : LocatedEvent(native_event), | 571 : LocatedEvent(native_event), |
| 572 changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)), | 572 changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)), |
| 573 pointer_details_(GetMousePointerDetailsFromNative(native_event)) { | 573 pointer_details_(GetMousePointerDetailsFromNative(native_event)) { |
| 574 latency()->AddLatencyNumberWithTimestamp( | 574 latency()->AddLatencyNumberWithTimestamp( |
| 575 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, | 575 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, |
| 576 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); | 576 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); |
| 577 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 577 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0); |
| 578 if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED) | 578 if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED) |
| 579 SetClickCount(GetRepeatCount(*this)); | 579 SetClickCount(GetRepeatCount(*this)); |
| 580 } | 580 } |
| 581 | 581 |
| 582 MouseEvent::MouseEvent(const PointerEvent& pointer_event) | 582 MouseEvent::MouseEvent(const PointerEvent& pointer_event) |
| 583 : LocatedEvent(pointer_event), | 583 : LocatedEvent(pointer_event), |
| 584 changed_button_flags_(pointer_event.changed_button_flags()), | 584 changed_button_flags_(pointer_event.changed_button_flags()), |
| 585 pointer_details_(pointer_event.pointer_details()) { | 585 pointer_details_(pointer_event.pointer_details()) { |
| 586 DCHECK(pointer_event.IsMousePointerEvent()); | 586 DCHECK(pointer_event.IsMousePointerEvent()); |
| 587 switch (pointer_event.type()) { | 587 switch (pointer_event.type()) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 int changed_button_flags, | 633 int changed_button_flags, |
| 634 const PointerDetails& pointer_details) | 634 const PointerDetails& pointer_details) |
| 635 : LocatedEvent(type, | 635 : LocatedEvent(type, |
| 636 gfx::PointF(location), | 636 gfx::PointF(location), |
| 637 gfx::PointF(root_location), | 637 gfx::PointF(root_location), |
| 638 time_stamp, | 638 time_stamp, |
| 639 flags), | 639 flags), |
| 640 changed_button_flags_(changed_button_flags), | 640 changed_button_flags_(changed_button_flags), |
| 641 pointer_details_(pointer_details) { | 641 pointer_details_(pointer_details) { |
| 642 DCHECK_NE(ET_MOUSEWHEEL, type); | 642 DCHECK_NE(ET_MOUSEWHEEL, type); |
| 643 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 643 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0); |
| 644 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) | 644 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) |
| 645 SetType(ET_MOUSE_DRAGGED); | 645 SetType(ET_MOUSE_DRAGGED); |
| 646 } | 646 } |
| 647 | 647 |
| 648 // static | 648 // static |
| 649 bool MouseEvent::IsRepeatedClickEvent( | 649 bool MouseEvent::IsRepeatedClickEvent( |
| 650 const MouseEvent& event1, | 650 const MouseEvent& event1, |
| 651 const MouseEvent& event2) { | 651 const MouseEvent& event2) { |
| 652 // These values match the Windows defaults. | 652 // These values match the Windows defaults. |
| 653 static const int kDoubleClickTimeMS = 500; | 653 static const int kDoubleClickTimeMS = 500; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 // TouchEvent | 833 // TouchEvent |
| 834 | 834 |
| 835 TouchEvent::TouchEvent(const base::NativeEvent& native_event) | 835 TouchEvent::TouchEvent(const base::NativeEvent& native_event) |
| 836 : LocatedEvent(native_event), | 836 : LocatedEvent(native_event), |
| 837 unique_event_id_(ui::GetNextTouchEventId()), | 837 unique_event_id_(ui::GetNextTouchEventId()), |
| 838 rotation_angle_(GetTouchAngle(native_event)), | 838 rotation_angle_(GetTouchAngle(native_event)), |
| 839 may_cause_scrolling_(false), | 839 may_cause_scrolling_(false), |
| 840 should_remove_native_touch_id_mapping_(false), | 840 should_remove_native_touch_id_mapping_(false), |
| 841 pointer_details_(GetTouchPointerDetailsFromNative(native_event)) { | 841 pointer_details_(GetTouchPointerDetailsFromNative(native_event)) { |
| 842 latency()->AddLatencyNumberWithTimestamp( | 842 latency()->AddLatencyNumberWithTimestamp( |
| 843 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, | 843 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, |
| 844 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); | 844 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); |
| 845 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 845 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0); |
| 846 | 846 |
| 847 FixRotationAngle(); | 847 FixRotationAngle(); |
| 848 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) | 848 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) |
| 849 should_remove_native_touch_id_mapping_ = true; | 849 should_remove_native_touch_id_mapping_ = true; |
| 850 } | 850 } |
| 851 | 851 |
| 852 TouchEvent::TouchEvent(const PointerEvent& pointer_event) | 852 TouchEvent::TouchEvent(const PointerEvent& pointer_event) |
| 853 : LocatedEvent(pointer_event), | 853 : LocatedEvent(pointer_event), |
| 854 unique_event_id_(ui::GetNextTouchEventId()), | 854 unique_event_id_(ui::GetNextTouchEventId()), |
| 855 rotation_angle_(0.0f), | 855 rotation_angle_(0.0f), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 : LocatedEvent(type, | 888 : LocatedEvent(type, |
| 889 gfx::PointF(location), | 889 gfx::PointF(location), |
| 890 gfx::PointF(location), | 890 gfx::PointF(location), |
| 891 time_stamp, | 891 time_stamp, |
| 892 flags), | 892 flags), |
| 893 unique_event_id_(ui::GetNextTouchEventId()), | 893 unique_event_id_(ui::GetNextTouchEventId()), |
| 894 rotation_angle_(angle), | 894 rotation_angle_(angle), |
| 895 may_cause_scrolling_(false), | 895 may_cause_scrolling_(false), |
| 896 should_remove_native_touch_id_mapping_(false), | 896 should_remove_native_touch_id_mapping_(false), |
| 897 pointer_details_(pointer_details) { | 897 pointer_details_(pointer_details) { |
| 898 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 898 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0); |
| 899 FixRotationAngle(); | 899 FixRotationAngle(); |
| 900 } | 900 } |
| 901 | 901 |
| 902 TouchEvent::TouchEvent(const TouchEvent& copy) | 902 TouchEvent::TouchEvent(const TouchEvent& copy) |
| 903 : LocatedEvent(copy), | 903 : LocatedEvent(copy), |
| 904 unique_event_id_(copy.unique_event_id_), | 904 unique_event_id_(copy.unique_event_id_), |
| 905 rotation_angle_(copy.rotation_angle_), | 905 rotation_angle_(copy.rotation_angle_), |
| 906 may_cause_scrolling_(copy.may_cause_scrolling_), | 906 may_cause_scrolling_(copy.may_cause_scrolling_), |
| 907 should_remove_native_touch_id_mapping_(false), | 907 should_remove_native_touch_id_mapping_(false), |
| 908 pointer_details_(copy.pointer_details_) { | 908 pointer_details_(copy.pointer_details_) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 | 1142 |
| 1143 KeyEvent::KeyEvent(const base::NativeEvent& native_event) | 1143 KeyEvent::KeyEvent(const base::NativeEvent& native_event) |
| 1144 : KeyEvent(native_event, EventFlagsFromNative(native_event)) {} | 1144 : KeyEvent(native_event, EventFlagsFromNative(native_event)) {} |
| 1145 | 1145 |
| 1146 KeyEvent::KeyEvent(const base::NativeEvent& native_event, int event_flags) | 1146 KeyEvent::KeyEvent(const base::NativeEvent& native_event, int event_flags) |
| 1147 : Event(native_event, EventTypeFromNative(native_event), event_flags), | 1147 : Event(native_event, EventTypeFromNative(native_event), event_flags), |
| 1148 key_code_(KeyboardCodeFromNative(native_event)), | 1148 key_code_(KeyboardCodeFromNative(native_event)), |
| 1149 code_(CodeFromNative(native_event)), | 1149 code_(CodeFromNative(native_event)), |
| 1150 is_char_(IsCharFromNative(native_event)) { | 1150 is_char_(IsCharFromNative(native_event)) { |
| 1151 latency()->AddLatencyNumberWithTimestamp( | 1151 latency()->AddLatencyNumberWithTimestamp( |
| 1152 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, | 1152 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, |
| 1153 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); | 1153 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); |
| 1154 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1154 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0); |
| 1155 | 1155 |
| 1156 if (IsRepeated(*this)) | 1156 if (IsRepeated(*this)) |
| 1157 set_flags(flags() | ui::EF_IS_REPEAT); | 1157 set_flags(flags() | ui::EF_IS_REPEAT); |
| 1158 | 1158 |
| 1159 #if defined(USE_X11) | 1159 #if defined(USE_X11) |
| 1160 NormalizeFlags(); | 1160 NormalizeFlags(); |
| 1161 #endif | 1161 #endif |
| 1162 #if defined(OS_WIN) | 1162 #if defined(OS_WIN) |
| 1163 // Only Windows has native character events. | 1163 // Only Windows has native character events. |
| 1164 if (is_char_) | 1164 if (is_char_) |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 flags | EF_FROM_TOUCH), | 1458 flags | EF_FROM_TOUCH), |
| 1459 details_(details), | 1459 details_(details), |
| 1460 unique_touch_event_id_(unique_touch_event_id) { | 1460 unique_touch_event_id_(unique_touch_event_id) { |
| 1461 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | 1461 latency()->set_source_event_type(ui::SourceEventType::TOUCH); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 GestureEvent::~GestureEvent() { | 1464 GestureEvent::~GestureEvent() { |
| 1465 } | 1465 } |
| 1466 | 1466 |
| 1467 } // namespace ui | 1467 } // namespace ui |
| OLD | NEW |