Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: ui/events/event.cc

Issue 2029713002: Constructors for ui::MouseEvent/ui::TouchEvent from ui::PointerEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // MouseEvent 455 // MouseEvent
456 456
457 MouseEvent::MouseEvent(const base::NativeEvent& native_event) 457 MouseEvent::MouseEvent(const base::NativeEvent& native_event)
458 : LocatedEvent(native_event), 458 : LocatedEvent(native_event),
459 changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)), 459 changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)),
460 pointer_details_(GetMousePointerDetailsFromNative(native_event)) { 460 pointer_details_(GetMousePointerDetailsFromNative(native_event)) {
461 if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED) 461 if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED)
462 SetClickCount(GetRepeatCount(*this)); 462 SetClickCount(GetRepeatCount(*this));
463 } 463 }
464 464
465 MouseEvent::MouseEvent(const PointerEvent& pointer_event)
466 : LocatedEvent(pointer_event),
467 pointer_details_(pointer_event.pointer_details()) {
468 DCHECK(pointer_event.IsMousePointerEvent());
469 switch (pointer_event.type()) {
470 case ET_POINTER_DOWN:
471 SetType(ET_MOUSE_PRESSED);
472 break;
473
474 case ET_POINTER_MOVED:
475 SetType(ET_MOUSE_MOVED);
476 break;
477
478 case ET_POINTER_ENTERED:
479 SetType(ET_MOUSE_ENTERED);
480 break;
481
482 case ET_POINTER_EXITED:
483 SetType(ET_MOUSE_EXITED);
484 break;
485
486 case ET_POINTER_UP:
487 SetType(ET_MOUSE_RELEASED);
488 break;
489
490 default:
491 NOTREACHED();
492 }
493 }
494
465 MouseEvent::MouseEvent(EventType type, 495 MouseEvent::MouseEvent(EventType type,
466 const gfx::Point& location, 496 const gfx::Point& location,
467 const gfx::Point& root_location, 497 const gfx::Point& root_location,
468 base::TimeDelta time_stamp, 498 base::TimeDelta time_stamp,
469 int flags, 499 int flags,
470 int changed_button_flags) 500 int changed_button_flags)
471 : LocatedEvent(type, 501 : LocatedEvent(type,
472 gfx::PointF(location), 502 gfx::PointF(location),
473 gfx::PointF(root_location), 503 gfx::PointF(root_location),
474 time_stamp, 504 time_stamp,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 latency()->AddLatencyNumberWithTimestamp( 692 latency()->AddLatencyNumberWithTimestamp(
663 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 693 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
664 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); 694 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
665 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 695 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
666 696
667 FixRotationAngle(); 697 FixRotationAngle();
668 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 698 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
669 should_remove_native_touch_id_mapping_ = true; 699 should_remove_native_touch_id_mapping_ = true;
670 } 700 }
671 701
702 TouchEvent::TouchEvent(const PointerEvent& pointer_event)
703 : LocatedEvent(pointer_event),
704 touch_id_(pointer_event.pointer_id()),
705 unique_event_id_(ui::GetNextTouchEventId()),
706 rotation_angle_(0.0f),
707 may_cause_scrolling_(false),
708 should_remove_native_touch_id_mapping_(false),
709 pointer_details_(pointer_event.pointer_details()) {
710 DCHECK(pointer_event.IsTouchPointerEvent());
711 switch (pointer_event.type()) {
712 case ET_POINTER_DOWN:
713 SetType(ET_TOUCH_PRESSED);
714 break;
715
716 case ET_POINTER_MOVED:
717 SetType(ET_TOUCH_MOVED);
718 break;
719
720 case ET_POINTER_UP:
721 SetType(ET_TOUCH_RELEASED);
722 break;
723
724 case ET_POINTER_CANCELLED:
725 SetType(ET_TOUCH_CANCELLED);
726 break;
727
728 default:
729 NOTREACHED();
730 }
731 }
732
672 TouchEvent::TouchEvent(EventType type, 733 TouchEvent::TouchEvent(EventType type,
673 const gfx::Point& location, 734 const gfx::Point& location,
674 int touch_id, 735 int touch_id,
675 base::TimeDelta time_stamp) 736 base::TimeDelta time_stamp)
676 : LocatedEvent(type, 737 : LocatedEvent(type,
677 gfx::PointF(location), 738 gfx::PointF(location),
678 gfx::PointF(location), 739 gfx::PointF(location),
679 time_stamp, 740 time_stamp,
680 0), 741 0),
681 touch_id_(touch_id), 742 touch_id_(touch_id),
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 gfx::PointF(x, y), 1276 gfx::PointF(x, y),
1216 time_stamp, 1277 time_stamp,
1217 flags | EF_FROM_TOUCH), 1278 flags | EF_FROM_TOUCH),
1218 details_(details) { 1279 details_(details) {
1219 } 1280 }
1220 1281
1221 GestureEvent::~GestureEvent() { 1282 GestureEvent::~GestureEvent() {
1222 } 1283 }
1223 1284
1224 } // namespace ui 1285 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698