Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_android.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
| index e1437b451ef82a6ccbdaa7bcdb0cfded5a8c3592..7b2cda252580dae5997d7d07fb2c124379ae0edc 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
| @@ -102,6 +102,9 @@ namespace content { |
| namespace { |
| static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; |
| +static const base::TimeDelta kClickCountInterval = |
| + base::TimeDelta::FromSecondsD(0.5); |
| +static const float kClickCountRadiusSquaredDIP = 25; |
| class PendingReadbackLock; |
| @@ -1801,11 +1804,33 @@ void RenderWidgetHostViewAndroid::SendMouseEvent( |
| blink::WebInputEvent::Type webMouseEventType = |
| ui::ToWebMouseEventType(motion_event.GetAction()); |
| + const base::TimeTicks current_time = base::TimeTicks::Now(); |
| + if (webMouseEventType == blink::WebInputEvent::kMouseDown) { |
| + if (action_button == ui::MotionEventAndroid::BUTTON_PRIMARY) { |
| + gfx::Point mousedown_point(motion_event.GetX(0), motion_event.GetY(0)); |
| + const base::TimeDelta time_delay = |
| + current_time - prev_mousedown_timestamp_; |
| + const float distance_squared = |
| + (mousedown_point - prev_mousedown_point_).LengthSquared(); |
| + if (left_click_count_ > 2 || time_delay > kClickCountInterval || |
| + distance_squared > kClickCountRadiusSquaredDIP) { |
| + left_click_count_ = 0; |
| + } |
| + prev_mousedown_timestamp_ = current_time; |
| + prev_mousedown_point_ = mousedown_point; |
| + } else { |
| + // Reset state if middle or right button was pressed. |
| + left_click_count_ = 0; |
| + prev_mousedown_timestamp_ = base::TimeTicks(); |
| + } |
| + left_click_count_++; |
| + } |
| + |
| blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( |
| webMouseEventType, |
| ui::EventTimeStampToSeconds(motion_event.GetEventTime()), |
| motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(), |
| - motion_event.GetButtonState() ? 1 : 0 /* click count */, |
| + motion_event.GetButtonState() ? left_click_count_ : 0 /* click count */, |
|
aelias_OOO_until_Jul13
2017/06/21 19:59:01
Hmm, I realized click_count needs to be set on Mou
|
| motion_event.GetPointerId(0), motion_event.GetPressure(0), |
| motion_event.GetOrientation(0), motion_event.GetTiltX(0), |
| motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); |