| 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 case ET_POINTER_EXITED: | 492 case ET_POINTER_EXITED: |
| 493 SetType(ET_MOUSE_EXITED); | 493 SetType(ET_MOUSE_EXITED); |
| 494 break; | 494 break; |
| 495 | 495 |
| 496 case ET_POINTER_UP: | 496 case ET_POINTER_UP: |
| 497 SetType(ET_MOUSE_RELEASED); | 497 SetType(ET_MOUSE_RELEASED); |
| 498 break; | 498 break; |
| 499 | 499 |
| 500 case ET_POINTER_WHEEL_CHANGED: | 500 case ET_POINTER_WHEEL_CHANGED: |
| 501 SetType(ET_MOUSEWHEEL); | 501 // Explicitly not setting a type here. MouseWheelEvent should be converted |
| 502 // from PointerEvent using its own ctor. |
| 502 break; | 503 break; |
| 503 | 504 |
| 504 case ET_POINTER_CAPTURE_CHANGED: | 505 case ET_POINTER_CAPTURE_CHANGED: |
| 505 SetType(ET_MOUSE_CAPTURE_CHANGED); | 506 SetType(ET_MOUSE_CAPTURE_CHANGED); |
| 506 break; | 507 break; |
| 507 | 508 |
| 508 default: | 509 default: |
| 509 NOTREACHED(); | 510 NOTREACHED(); |
| 510 } | 511 } |
| 511 } | 512 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 else if (flags() & EF_IS_DOUBLE_CLICK) | 620 else if (flags() & EF_IS_DOUBLE_CLICK) |
| 620 return 2; | 621 return 2; |
| 621 else | 622 else |
| 622 return 1; | 623 return 1; |
| 623 } | 624 } |
| 624 | 625 |
| 625 void MouseEvent::SetClickCount(int click_count) { | 626 void MouseEvent::SetClickCount(int click_count) { |
| 626 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED) | 627 if (type() != ET_MOUSE_PRESSED && type() != ET_MOUSE_RELEASED) |
| 627 return; | 628 return; |
| 628 | 629 |
| 629 DCHECK(click_count > 0); | 630 DCHECK_LT(0, click_count); |
| 630 DCHECK(click_count <= 3); | 631 DCHECK_GE(3, click_count); |
| 631 | 632 |
| 632 int f = flags(); | 633 int f = flags(); |
| 633 switch (click_count) { | 634 switch (click_count) { |
| 634 case 1: | 635 case 1: |
| 635 f &= ~EF_IS_DOUBLE_CLICK; | 636 f &= ~EF_IS_DOUBLE_CLICK; |
| 636 f &= ~EF_IS_TRIPLE_CLICK; | 637 f &= ~EF_IS_TRIPLE_CLICK; |
| 637 break; | 638 break; |
| 638 case 2: | 639 case 2: |
| 639 f |= EF_IS_DOUBLE_CLICK; | 640 f |= EF_IS_DOUBLE_CLICK; |
| 640 f &= ~EF_IS_TRIPLE_CLICK; | 641 f &= ~EF_IS_TRIPLE_CLICK; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 655 offset_(GetMouseWheelOffset(native_event)) { | 656 offset_(GetMouseWheelOffset(native_event)) { |
| 656 } | 657 } |
| 657 | 658 |
| 658 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) | 659 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) |
| 659 : MouseEvent(scroll_event), | 660 : MouseEvent(scroll_event), |
| 660 offset_(gfx::ToRoundedInt(scroll_event.x_offset()), | 661 offset_(gfx::ToRoundedInt(scroll_event.x_offset()), |
| 661 gfx::ToRoundedInt(scroll_event.y_offset())) { | 662 gfx::ToRoundedInt(scroll_event.y_offset())) { |
| 662 SetType(ET_MOUSEWHEEL); | 663 SetType(ET_MOUSEWHEEL); |
| 663 } | 664 } |
| 664 | 665 |
| 666 MouseWheelEvent::MouseWheelEvent(const PointerEvent& pointer_event) |
| 667 : MouseEvent(pointer_event), |
| 668 offset_(pointer_event.pointer_details().offset.x(), |
| 669 pointer_event.pointer_details().offset.y()) { |
| 670 SetType(ET_MOUSEWHEEL); |
| 671 } |
| 672 |
| 665 MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event, | 673 MouseWheelEvent::MouseWheelEvent(const MouseEvent& mouse_event, |
| 666 int x_offset, | 674 int x_offset, |
| 667 int y_offset) | 675 int y_offset) |
| 668 : MouseEvent(mouse_event), offset_(x_offset, y_offset) { | 676 : MouseEvent(mouse_event), offset_(x_offset, y_offset) { |
| 669 SetType(ET_MOUSEWHEEL); | 677 SetType(ET_MOUSEWHEEL); |
| 670 } | 678 } |
| 671 | 679 |
| 672 MouseWheelEvent::MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event) | 680 MouseWheelEvent::MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event) |
| 673 : MouseEvent(mouse_wheel_event), | 681 : MouseEvent(mouse_wheel_event), |
| 674 offset_(mouse_wheel_event.offset()) { | 682 offset_(mouse_wheel_event.offset()) { |
| 675 DCHECK(type() == ET_MOUSEWHEEL); | 683 DCHECK_EQ(ET_MOUSEWHEEL, type()); |
| 676 } | 684 } |
| 677 | 685 |
| 678 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, | 686 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, |
| 679 const gfx::Point& location, | 687 const gfx::Point& location, |
| 680 const gfx::Point& root_location, | 688 const gfx::Point& root_location, |
| 681 base::TimeTicks time_stamp, | 689 base::TimeTicks time_stamp, |
| 682 int flags, | 690 int flags, |
| 683 int changed_button_flags) | 691 int changed_button_flags) |
| 684 : MouseEvent(ui::ET_UNKNOWN, | 692 : MouseEvent(ui::ET_UNKNOWN, |
| 685 location, | 693 location, |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 | 1153 |
| 1146 base::char16 KeyEvent::GetCharacter() const { | 1154 base::char16 KeyEvent::GetCharacter() const { |
| 1147 // Determination of key_ may be done lazily. | 1155 // Determination of key_ may be done lazily. |
| 1148 if (key_ == DomKey::NONE) | 1156 if (key_ == DomKey::NONE) |
| 1149 ApplyLayout(); | 1157 ApplyLayout(); |
| 1150 if (key_.IsCharacter()) { | 1158 if (key_.IsCharacter()) { |
| 1151 // Historically ui::KeyEvent has held only BMP characters. | 1159 // Historically ui::KeyEvent has held only BMP characters. |
| 1152 // Until this explicitly changes, require |key_| to hold a BMP character. | 1160 // Until this explicitly changes, require |key_| to hold a BMP character. |
| 1153 DomKey::Base utf32_character = key_.ToCharacter(); | 1161 DomKey::Base utf32_character = key_.ToCharacter(); |
| 1154 base::char16 ucs2_character = static_cast<base::char16>(utf32_character); | 1162 base::char16 ucs2_character = static_cast<base::char16>(utf32_character); |
| 1155 DCHECK(static_cast<DomKey::Base>(ucs2_character) == utf32_character); | 1163 DCHECK_EQ(static_cast<DomKey::Base>(ucs2_character), utf32_character); |
| 1156 // Check if the control character is down. Note that ALTGR is represented | 1164 // Check if the control character is down. Note that ALTGR is represented |
| 1157 // on Windows as CTRL|ALT, so we need to make sure that is not set. | 1165 // on Windows as CTRL|ALT, so we need to make sure that is not set. |
| 1158 if ((flags() & (EF_ALTGR_DOWN | EF_CONTROL_DOWN)) == EF_CONTROL_DOWN) { | 1166 if ((flags() & (EF_ALTGR_DOWN | EF_CONTROL_DOWN)) == EF_CONTROL_DOWN) { |
| 1159 // For a control character, key_ contains the corresponding printable | 1167 // For a control character, key_ contains the corresponding printable |
| 1160 // character. To preserve existing behaviour for now, return the control | 1168 // character. To preserve existing behaviour for now, return the control |
| 1161 // character here; this will likely change -- see e.g. crbug.com/471488. | 1169 // character here; this will likely change -- see e.g. crbug.com/471488. |
| 1162 if (ucs2_character >= 0x20 && ucs2_character <= 0x7E) | 1170 if (ucs2_character >= 0x20 && ucs2_character <= 0x7E) |
| 1163 return ucs2_character & 0x1F; | 1171 return ucs2_character & 0x1F; |
| 1164 if (ucs2_character == '\r') | 1172 if (ucs2_character == '\r') |
| 1165 return '\n'; | 1173 return '\n'; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 gfx::PointF(x, y), | 1314 gfx::PointF(x, y), |
| 1307 time_stamp, | 1315 time_stamp, |
| 1308 flags | EF_FROM_TOUCH), | 1316 flags | EF_FROM_TOUCH), |
| 1309 details_(details), | 1317 details_(details), |
| 1310 unique_touch_event_id_(unique_touch_event_id) {} | 1318 unique_touch_event_id_(unique_touch_event_id) {} |
| 1311 | 1319 |
| 1312 GestureEvent::~GestureEvent() { | 1320 GestureEvent::~GestureEvent() { |
| 1313 } | 1321 } |
| 1314 | 1322 |
| 1315 } // namespace ui | 1323 } // namespace ui |
| OLD | NEW |