Chromium Code Reviews| Index: content/browser/renderer_host/input/touch_handle.cc |
| diff --git a/content/browser/renderer_host/input/touch_handle.cc b/content/browser/renderer_host/input/touch_handle.cc |
| index d5bda485dca02ced7e60a57ecea442f74a031c5d..acfe3bd70f87f1716272adbdccca88de11269f9e 100644 |
| --- a/content/browser/renderer_host/input/touch_handle.cc |
| +++ b/content/browser/renderer_host/input/touch_handle.cc |
| @@ -40,7 +40,8 @@ TouchHandle::TouchHandle(TouchHandleClient* client, |
| animate_deferred_fade_(false), |
| enabled_(true), |
| is_visible_(false), |
| - is_dragging_(false) { |
| + is_dragging_(false), |
| + is_drag_within_tap_region_(false) { |
| DCHECK_NE(orientation, TOUCH_HANDLE_ORIENTATION_UNDEFINED); |
| drawable_->SetEnabled(enabled_); |
| drawable_->SetOrientation(orientation_); |
| @@ -140,17 +141,26 @@ bool TouchHandle::WillHandleTouchEvent(const ui::MotionEvent& event) { |
| } break; |
| case ui::MotionEvent::ACTION_MOVE: { |
| - gfx::PointF new_position = |
| - gfx::PointF(event.GetX(), event.GetY()) + touch_to_focus_offset_; |
| - client_->OnHandleDragUpdate(*this, new_position); |
| + gfx::PointF touch_move_position(event.GetX(), event.GetY()); |
| + if (is_drag_within_tap_region_) { |
|
raghu
2014/08/28 03:00:33
Please correct me here if I am wrong. Do we need t
jdduke (slow)
2014/08/28 15:37:12
It will only be true until we exceed the slop regi
|
| + const float tap_slop = client_->GetTapSlop(); |
| + is_drag_within_tap_region_ = |
| + (touch_move_position - touch_down_position_).LengthSquared() < |
| + tap_slop * tap_slop; |
| + } |
| + |
| + // Note that we signal drag update even if we're inside the tap region, |
| + // as there are cases where characters are narrower than the slop length. |
| + client_->OnHandleDragUpdate(*this, |
| + touch_move_position + touch_to_focus_offset_); |
| } break; |
| case ui::MotionEvent::ACTION_UP: { |
| - // TODO(jdduke): Use the platform touch slop distance and tap delay to |
| - // properly detect a tap, crbug.com/394093. |
| - base::TimeDelta delay = event.GetEventTime() - touch_down_time_; |
| - if (delay < base::TimeDelta::FromMilliseconds(180)) |
| + if (is_drag_within_tap_region_ && |
| + (event.GetEventTime() - touch_down_time_) < |
| + client_->GetTapTimeout()) { |
| client_->OnHandleTapped(*this); |
| + } |
| EndDrag(); |
| } break; |
| @@ -192,6 +202,7 @@ void TouchHandle::BeginDrag() { |
| return; |
| EndFade(); |
| is_dragging_ = true; |
| + is_drag_within_tap_region_ = true; |
| client_->OnHandleDragBegin(*this); |
| } |
| @@ -201,6 +212,7 @@ void TouchHandle::EndDrag() { |
| return; |
| is_dragging_ = false; |
| + is_drag_within_tap_region_ = false; |
| client_->OnHandleDragEnd(*this); |
| if (deferred_orientation_ != TOUCH_HANDLE_ORIENTATION_UNDEFINED) { |