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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2713543002: Only focus if contextmenu event was sent (Closed)
Patch Set: Adding double/triple click to Android Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698