Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 double kMaxClickDelay = 0.5; | |
|
aelias_OOO_until_Jul13
2017/06/20 18:57:52
Would prefer names "kClickCountInterval", "kClickC
amaralp
2017/06/21 00:33:40
Done.
| |
| 106 static const float kMaxClickDistance = 5; | |
| 105 | 107 |
| 106 class PendingReadbackLock; | 108 class PendingReadbackLock; |
| 107 | 109 |
| 108 PendingReadbackLock* g_pending_readback_lock = nullptr; | 110 PendingReadbackLock* g_pending_readback_lock = nullptr; |
| 109 | 111 |
| 110 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> { | 112 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> { |
| 111 public: | 113 public: |
| 112 PendingReadbackLock() { | 114 PendingReadbackLock() { |
| 113 DCHECK_EQ(g_pending_readback_lock, nullptr); | 115 DCHECK_EQ(g_pending_readback_lock, nullptr); |
| 114 g_pending_readback_lock = this; | 116 g_pending_readback_lock = this; |
| (...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1796 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1795 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); | 1797 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); |
| 1796 } | 1798 } |
| 1797 | 1799 |
| 1798 void RenderWidgetHostViewAndroid::SendMouseEvent( | 1800 void RenderWidgetHostViewAndroid::SendMouseEvent( |
| 1799 const ui::MotionEventAndroid& motion_event, | 1801 const ui::MotionEventAndroid& motion_event, |
| 1800 int action_button) { | 1802 int action_button) { |
| 1801 blink::WebInputEvent::Type webMouseEventType = | 1803 blink::WebInputEvent::Type webMouseEventType = |
| 1802 ui::ToWebMouseEventType(motion_event.GetAction()); | 1804 ui::ToWebMouseEventType(motion_event.GetAction()); |
| 1803 | 1805 |
| 1806 const double event_time = | |
| 1807 ui::EventTimeStampToSeconds(motion_event.GetEventTime()); | |
| 1808 if (webMouseEventType == blink::WebInputEvent::kMouseDown) { | |
|
aelias_OOO_until_Jul13
2017/06/20 18:57:52
This also should take into account which button wa
amaralp
2017/06/21 00:33:40
Made only count left-clicks.
| |
| 1809 gfx::Point mousedown_point(motion_event.GetX(0), motion_event.GetY(0)); | |
| 1810 const double time_delay = event_time - prev_mousedown_timestamp_; | |
| 1811 const float distance = (mousedown_point - prev_mousedown_point_).Length(); | |
| 1812 if (click_count_ > 2 || time_delay > kMaxClickDelay || | |
| 1813 distance > kMaxClickDistance) { | |
| 1814 click_count_ = 1; | |
|
aelias_OOO_until_Jul13
2017/06/20 18:57:52
1-based counting system feels weird. I'd prefer:
amaralp
2017/06/21 00:33:40
Done.
| |
| 1815 } else { | |
| 1816 click_count_++; | |
| 1817 } | |
| 1818 prev_mousedown_timestamp_ = event_time; | |
| 1819 prev_mousedown_point_ = mousedown_point; | |
| 1820 } | |
| 1821 | |
| 1804 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( | 1822 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( |
| 1805 webMouseEventType, | 1823 webMouseEventType, event_time, motion_event.GetX(0), motion_event.GetY(0), |
| 1806 ui::EventTimeStampToSeconds(motion_event.GetEventTime()), | 1824 motion_event.GetFlags(), |
| 1807 motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(), | 1825 motion_event.GetButtonState() ? click_count_ : 0 /* click count */, |
|
aelias_OOO_until_Jul13
2017/06/20 18:57:52
I suggest integrating this condition in the core c
amaralp
2017/06/21 00:33:40
The problem is that I don't want to set click_coun
| |
| 1808 motion_event.GetButtonState() ? 1 : 0 /* click count */, | |
| 1809 motion_event.GetPointerId(0), motion_event.GetPressure(0), | 1826 motion_event.GetPointerId(0), motion_event.GetPressure(0), |
| 1810 motion_event.GetOrientation(0), motion_event.GetTiltX(0), | 1827 motion_event.GetOrientation(0), motion_event.GetTiltX(0), |
| 1811 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); | 1828 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); |
| 1812 | 1829 |
| 1813 if (!host_ || !host_->delegate()) | 1830 if (!host_ || !host_->delegate()) |
| 1814 return; | 1831 return; |
| 1815 | 1832 |
| 1816 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1833 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 1817 host_->delegate()->GetInputEventRouter()) { | 1834 host_->delegate()->GetInputEventRouter()) { |
| 1818 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( | 1835 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2276 | 2293 |
| 2277 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2294 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2278 if (!compositor) | 2295 if (!compositor) |
| 2279 return; | 2296 return; |
| 2280 | 2297 |
| 2281 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2298 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2282 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2299 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2283 } | 2300 } |
| 2284 | 2301 |
| 2285 } // namespace content | 2302 } // namespace content |
| OLD | NEW |