From d29c68068138dde6f35da3fb7fc6adad40e97638 Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 23 Oct 2015 13:43:05 -0700 Subject: chromeos: Remove implicit Point to PointF conversions. The implicit conversion operator is going away. The code currently throws away the decimal part of event locations while passing them through the touch exploration controller from one event to another, this fixes some of those. R=dmazzoni@chromium.org BUG=342848 Review URL: https://codereview.chromium.org/1407133008 Cr-Commit-Position: refs/heads/master@{#355875} --- ui/chromeos/touch_exploration_controller.cc | 83 ++++++++++++----------------- ui/chromeos/touch_exploration_controller.h | 2 +- 2 files changed, 34 insertions(+), 51 deletions(-) (limited to 'ui/chromeos') diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc index 4fdd821..5661d1d 100644 --- a/ui/chromeos/touch_exploration_controller.cc +++ b/ui/chromeos/touch_exploration_controller.cc @@ -365,17 +365,14 @@ ui::EventRewriteStatus TouchExplorationController::InDoubleTapPending( return EVENT_REWRITE_DISCARD; scoped_ptr touch_press; - touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, - last_touch_exploration_->location(), - initial_press_->touch_id(), - event.time_stamp())); + touch_press.reset(new ui::TouchEvent( + ui::ET_TOUCH_PRESSED, last_touch_exploration_->location_f(), + initial_press_->touch_id(), event.time_stamp())); DispatchEvent(touch_press.get()); - rewritten_event->reset( - new ui::TouchEvent(ui::ET_TOUCH_RELEASED, - last_touch_exploration_->location(), - initial_press_->touch_id(), - event.time_stamp())); + rewritten_event->reset(new ui::TouchEvent( + ui::ET_TOUCH_RELEASED, last_touch_exploration_->location_f(), + initial_press_->touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); SET_STATE(NO_FINGERS_DOWN); return ui::EVENT_REWRITE_REWRITTEN; @@ -394,11 +391,9 @@ ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending( if (current_touch_ids_.size() != 0) return EVENT_REWRITE_DISCARD; - rewritten_event->reset( - new ui::TouchEvent(ui::ET_TOUCH_RELEASED, - last_touch_exploration_->location(), - initial_press_->touch_id(), - event.time_stamp())); + rewritten_event->reset(new ui::TouchEvent( + ui::ET_TOUCH_RELEASED, last_touch_exploration_->location_f(), + initial_press_->touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); SET_STATE(NO_FINGERS_DOWN); return ui::EVENT_REWRITE_REWRITTEN; @@ -415,11 +410,9 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration( // Handle split-tap. initial_press_.reset(new TouchEvent(event)); tap_timer_.Stop(); - rewritten_event->reset( - new ui::TouchEvent(ui::ET_TOUCH_PRESSED, - last_touch_exploration_->location(), - event.touch_id(), - event.time_stamp())); + rewritten_event->reset(new ui::TouchEvent( + ui::ET_TOUCH_PRESSED, last_touch_exploration_->location_f(), + event.touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); return ui::EVENT_REWRITE_REWRITTEN; @@ -433,7 +426,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration( } // Rewrite as a mouse-move event. - *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); + *rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags()); last_touch_exploration_.reset(new TouchEvent(event)); return ui::EVENT_REWRITE_REWRITTEN; } @@ -473,7 +466,7 @@ ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( } rewritten_event->reset(new ui::TouchEvent( - type, event.location(), event.touch_id(), event.time_stamp())); + type, event.location_f(), event.touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); if (current_touch_ids_.size() == 0) @@ -492,10 +485,8 @@ ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( return ui::EVENT_REWRITE_DISCARD; } rewritten_event->reset( - new ui::TouchEvent(event.type(), - event.location() - passthrough_offset_, - event.touch_id(), - event.time_stamp())); + new ui::TouchEvent(event.type(), event.location_f() - passthrough_offset_, + event.touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); if (current_touch_ids_.size() == 0) { @@ -514,11 +505,9 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( // through. The user enters the wait state, Since there has already been // a press dispatched when split tap began, the touch needs to be // cancelled. - rewritten_event->reset( - new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, - last_touch_exploration_->location(), - initial_press_->touch_id(), - event.time_stamp())); + rewritten_event->reset(new ui::TouchEvent( + ui::ET_TOUCH_CANCELLED, last_touch_exploration_->location_f(), + initial_press_->touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); SET_STATE(WAIT_FOR_NO_FINGERS); return ui::EVENT_REWRITE_REWRITTEN; @@ -540,13 +529,11 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( // fingers in place is a bit harder. If the user has left the slop, the // split tap press (which was previous dispatched) is lifted with a touch // cancelled, and the user enters the wait state. - if ((event.location() - original_touch->location()).Length() > + if ((event.location_f() - original_touch->location_f()).Length() > GetSplitTapTouchSlop()) { - rewritten_event->reset( - new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, - last_touch_exploration_->location(), - initial_press_->touch_id(), - event.time_stamp())); + rewritten_event->reset(new ui::TouchEvent( + ui::ET_TOUCH_CANCELLED, last_touch_exploration_->location_f(), + initial_press_->touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); SET_STATE(WAIT_FOR_NO_FINGERS); return ui::EVENT_REWRITE_REWRITTEN; @@ -567,11 +554,9 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( return EVENT_REWRITE_DISCARD; // Rewrite at location of last touch exploration. - rewritten_event->reset( - new ui::TouchEvent(ui::ET_TOUCH_RELEASED, - last_touch_exploration_->location(), - initial_press_->touch_id(), - event.time_stamp())); + rewritten_event->reset(new ui::TouchEvent( + ui::ET_TOUCH_RELEASED, last_touch_exploration_->location_f(), + initial_press_->touch_id(), event.time_stamp())); (*rewritten_event)->set_flags(event.flags()); SET_STATE(TOUCH_EXPLORATION); EnterTouchToMouseMode(); @@ -705,13 +690,11 @@ void TouchExplorationController::OnTapTimerFired() { return; case DOUBLE_TAP_PENDING: { SET_STATE(ONE_FINGER_PASSTHROUGH); - passthrough_offset_ = last_unused_finger_event_->location() - - last_touch_exploration_->location(); - scoped_ptr passthrough_press( - new ui::TouchEvent(ui::ET_TOUCH_PRESSED, - last_touch_exploration_->location(), - last_unused_finger_event_->touch_id(), - Now())); + passthrough_offset_ = last_unused_finger_event_->location_f() - + last_touch_exploration_->location_f(); + scoped_ptr passthrough_press(new ui::TouchEvent( + ui::ET_TOUCH_PRESSED, last_touch_exploration_->location_f(), + last_unused_finger_event_->touch_id(), Now())); DispatchEvent(passthrough_press.get()); return; } @@ -735,8 +718,8 @@ void TouchExplorationController::OnTapTimerFired() { return; } EnterTouchToMouseMode(); - scoped_ptr mouse_move = - CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); + scoped_ptr mouse_move = CreateMouseMoveEvent( + initial_press_->location_f(), initial_press_->flags()); DispatchEvent(mouse_move.get()); last_touch_exploration_.reset(new TouchEvent(*initial_press_)); } diff --git a/ui/chromeos/touch_exploration_controller.h b/ui/chromeos/touch_exploration_controller.h index d023ec9..96a7798 100644 --- a/ui/chromeos/touch_exploration_controller.h +++ b/ui/chromeos/touch_exploration_controller.h @@ -424,7 +424,7 @@ class UI_CHROMEOS_EXPORT TouchExplorationController // In one finger passthrough, the touch is displaced relative to the // last touch exploration location. - gfx::Vector2d passthrough_offset_; + gfx::Vector2dF passthrough_offset_; // Stores the most recent event from a finger that is currently not // sending events through, but might in the future (e.g. before a finger -- cgit v1.1