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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 base::TimeTicks time_stamp, | 515 base::TimeTicks time_stamp, |
516 int flags, | 516 int flags, |
517 int changed_button_flags) | 517 int changed_button_flags) |
518 : LocatedEvent(type, | 518 : LocatedEvent(type, |
519 gfx::PointF(location), | 519 gfx::PointF(location), |
520 gfx::PointF(root_location), | 520 gfx::PointF(root_location), |
521 time_stamp, | 521 time_stamp, |
522 flags), | 522 flags), |
523 changed_button_flags_(changed_button_flags), | 523 changed_button_flags_(changed_button_flags), |
524 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { | 524 pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) { |
| 525 DCHECK_NE(ET_MOUSEWHEEL, type); |
525 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 526 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
526 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) | 527 if (this->type() == ET_MOUSE_MOVED && IsAnyButton()) |
527 SetType(ET_MOUSE_DRAGGED); | 528 SetType(ET_MOUSE_DRAGGED); |
528 } | 529 } |
529 | 530 |
530 // static | 531 // static |
531 bool MouseEvent::IsRepeatedClickEvent( | 532 bool MouseEvent::IsRepeatedClickEvent( |
532 const MouseEvent& event1, | 533 const MouseEvent& event1, |
533 const MouseEvent& event2) { | 534 const MouseEvent& event2) { |
534 // These values match the Windows defaults. | 535 // These values match the Windows defaults. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 offset_(mouse_wheel_event.offset()) { | 673 offset_(mouse_wheel_event.offset()) { |
673 DCHECK(type() == ET_MOUSEWHEEL); | 674 DCHECK(type() == ET_MOUSEWHEEL); |
674 } | 675 } |
675 | 676 |
676 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, | 677 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, |
677 const gfx::Point& location, | 678 const gfx::Point& location, |
678 const gfx::Point& root_location, | 679 const gfx::Point& root_location, |
679 base::TimeTicks time_stamp, | 680 base::TimeTicks time_stamp, |
680 int flags, | 681 int flags, |
681 int changed_button_flags) | 682 int changed_button_flags) |
682 : MouseEvent(ui::ET_MOUSEWHEEL, | 683 : MouseEvent(ui::ET_UNKNOWN, |
683 location, | 684 location, |
684 root_location, | 685 root_location, |
685 time_stamp, | 686 time_stamp, |
686 flags, | 687 flags, |
687 changed_button_flags), | 688 changed_button_flags), |
688 offset_(offset) {} | 689 offset_(offset) { |
| 690 // Set event type to ET_UNKNOWN initially in MouseEvent() to pass the |
| 691 // DCHECK for type to enforce that we use MouseWheelEvent() to create |
| 692 // a MouseWheelEvent. |
| 693 SetType(ui::ET_MOUSEWHEEL); |
| 694 } |
689 | 695 |
690 #if defined(OS_WIN) | 696 #if defined(OS_WIN) |
691 // This value matches windows WHEEL_DELTA. | 697 // This value matches windows WHEEL_DELTA. |
692 // static | 698 // static |
693 const int MouseWheelEvent::kWheelDelta = 120; | 699 const int MouseWheelEvent::kWheelDelta = 120; |
694 #else | 700 #else |
695 // This value matches GTK+ wheel scroll amount. | 701 // This value matches GTK+ wheel scroll amount. |
696 const int MouseWheelEvent::kWheelDelta = 53; | 702 const int MouseWheelEvent::kWheelDelta = 53; |
697 #endif | 703 #endif |
698 | 704 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 gfx::PointF(x, y), | 1305 gfx::PointF(x, y), |
1300 time_stamp, | 1306 time_stamp, |
1301 flags | EF_FROM_TOUCH), | 1307 flags | EF_FROM_TOUCH), |
1302 details_(details), | 1308 details_(details), |
1303 unique_touch_event_id_(unique_touch_event_id) {} | 1309 unique_touch_event_id_(unique_touch_event_id) {} |
1304 | 1310 |
1305 GestureEvent::~GestureEvent() { | 1311 GestureEvent::~GestureEvent() { |
1306 } | 1312 } |
1307 | 1313 |
1308 } // namespace ui | 1314 } // namespace ui |
OLD | NEW |