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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2943383002: Android double/triple click (Closed)
Patch Set: move incrememnt outside if 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 #include "ui/gfx/android/view_configuration.h" 95 #include "ui/gfx/android/view_configuration.h"
96 #include "ui/gfx/geometry/dip_util.h" 96 #include "ui/gfx/geometry/dip_util.h"
97 #include "ui/gfx/geometry/size_conversions.h" 97 #include "ui/gfx/geometry/size_conversions.h"
98 #include "ui/touch_selection/touch_selection_controller.h" 98 #include "ui/touch_selection/touch_selection_controller.h"
99 99
100 namespace content { 100 namespace content {
101 101
102 namespace { 102 namespace {
103 103
104 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; 104 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
105 static const base::TimeDelta kClickCountInterval =
106 base::TimeDelta::FromSecondsD(0.5);
107 static const float kClickCountRadiusDIP = 5;
105 108
106 class PendingReadbackLock; 109 class PendingReadbackLock;
107 110
108 PendingReadbackLock* g_pending_readback_lock = nullptr; 111 PendingReadbackLock* g_pending_readback_lock = nullptr;
109 112
110 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> { 113 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> {
111 public: 114 public:
112 PendingReadbackLock() { 115 PendingReadbackLock() {
113 DCHECK_EQ(g_pending_readback_lock, nullptr); 116 DCHECK_EQ(g_pending_readback_lock, nullptr);
114 g_pending_readback_lock = this; 117 g_pending_readback_lock = this;
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 1797 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
1795 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); 1798 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info);
1796 } 1799 }
1797 1800
1798 void RenderWidgetHostViewAndroid::SendMouseEvent( 1801 void RenderWidgetHostViewAndroid::SendMouseEvent(
1799 const ui::MotionEventAndroid& motion_event, 1802 const ui::MotionEventAndroid& motion_event,
1800 int action_button) { 1803 int action_button) {
1801 blink::WebInputEvent::Type webMouseEventType = 1804 blink::WebInputEvent::Type webMouseEventType =
1802 ui::ToWebMouseEventType(motion_event.GetAction()); 1805 ui::ToWebMouseEventType(motion_event.GetAction());
1803 1806
1807 const base::TimeTicks current_time = base::TimeTicks::Now();
1808 if (webMouseEventType == blink::WebInputEvent::kMouseDown) {
1809 if (action_button == ui::MotionEventAndroid::BUTTON_PRIMARY) {
1810 gfx::Point mousedown_point(motion_event.GetX(0), motion_event.GetY(0));
1811 const base::TimeDelta time_delay =
1812 current_time - prev_mousedown_timestamp_;
1813 const float distance = (mousedown_point - prev_mousedown_point_).Length();
aelias_OOO_until_Jul13 2017/06/21 01:13:12 Although this doesn't happen on mousemove I still
amaralp 2017/06/21 19:34:21 Done.
1814 if (click_count_ > 2 || time_delay > kClickCountInterval ||
1815 distance > kClickCountRadiusDIP) {
1816 click_count_ = 0;
1817 }
1818 prev_mousedown_timestamp_ = current_time;
1819 prev_mousedown_point_ = mousedown_point;
1820 } else {
1821 // Reset state if left button isn't pressed.
aelias_OOO_until_Jul13 2017/06/21 01:13:12 "if middle or right button was pressed"
amaralp 2017/06/21 19:34:21 Done.
1822 click_count_ = 0;
1823 prev_mousedown_timestamp_ = base::TimeTicks();
1824 prev_mousedown_point_ = gfx::Point();
aelias_OOO_until_Jul13 2017/06/21 01:13:12 gfx::Point(0, 0) can be a legal offset or close to
amaralp 2017/06/21 19:34:22 Done.
1825 }
1826 click_count_++;
1827 }
1828
1804 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( 1829 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build(
1805 webMouseEventType, 1830 webMouseEventType,
1806 ui::EventTimeStampToSeconds(motion_event.GetEventTime()), 1831 ui::EventTimeStampToSeconds(motion_event.GetEventTime()),
1807 motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(), 1832 motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(),
1808 motion_event.GetButtonState() ? 1 : 0 /* click count */, 1833 motion_event.GetButtonState() ? click_count_ : 0 /* click count */,
1809 motion_event.GetPointerId(0), motion_event.GetPressure(0), 1834 motion_event.GetPointerId(0), motion_event.GetPressure(0),
1810 motion_event.GetOrientation(0), motion_event.GetTiltX(0), 1835 motion_event.GetOrientation(0), motion_event.GetTiltX(0),
1811 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); 1836 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0));
1812 1837
1813 if (!host_ || !host_->delegate()) 1838 if (!host_ || !host_->delegate())
1814 return; 1839 return;
1815 1840
1816 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && 1841 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() &&
1817 host_->delegate()->GetInputEventRouter()) { 1842 host_->delegate()->GetInputEventRouter()) {
1818 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( 1843 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 2301
2277 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2302 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2278 if (!compositor) 2303 if (!compositor)
2279 return; 2304 return;
2280 2305
2281 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2306 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2282 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2307 overscroll_refresh_handler, compositor, view_.GetDipScale());
2283 } 2308 }
2284 2309
2285 } // namespace content 2310 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698