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..39692117b041785135901c93070fbffc5046afc5 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,8 @@ namespace content { |
namespace { |
static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; |
+static const double kMaxClickDelay = 0.5; |
+static const int kMaxClickSquaredDistance = 25; |
class PendingReadbackLock; |
@@ -1801,11 +1803,29 @@ void RenderWidgetHostViewAndroid::SendMouseEvent( |
blink::WebInputEvent::Type webMouseEventType = |
ui::ToWebMouseEventType(motion_event.GetAction()); |
+ const double event_time = |
+ ui::EventTimeStampToSeconds(motion_event.GetEventTime()); |
+ if (webMouseEventType == blink::WebInputEvent::kMouseDown) { |
+ const double time_delay = event_time - prev_mousedown_timestamp_; |
+ const int distance_squared = (motion_event.GetX(0) - prev_mousedown_x) * |
+ (motion_event.GetX(0) - prev_mousedown_x) + |
+ (motion_event.GetY(0) - prev_mousedown_y) * |
+ (motion_event.GetY(0) - prev_mousedown_y); |
+ if (click_count_ > 2 || time_delay > kMaxClickDelay || |
+ distance_squared > kMaxClickSquaredDistance) { |
+ click_count_ = 1; |
+ } else { |
+ click_count_++; |
+ } |
+ prev_mousedown_timestamp_ = event_time; |
+ prev_mousedown_x = motion_event.GetX(0); |
+ prev_mousedown_y = motion_event.GetY(0); |
+ } |
+ |
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 */, |
+ webMouseEventType, event_time, motion_event.GetX(0), motion_event.GetY(0), |
+ motion_event.GetFlags(), |
+ motion_event.GetButtonState() ? click_count_ : 0 /* click count */, |
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)); |
@@ -1822,6 +1842,8 @@ void RenderWidgetHostViewAndroid::SendMouseEvent( |
} |
} |
+void UpdateClickCount(double event_time) {} |
+ |
void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
const blink::WebMouseWheelEvent& event) { |
if (!host_ || !host_->delegate()) |