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 base::TimeDelta kClickCountInterval = | |
| 106 base::TimeDelta::FromSecondsD(0.5); | |
| 107 static const float kClickCountRadiusSquaredDIP = 25; | |
| 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 Loading... | |
| 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 if (webMouseEventType == blink::WebInputEvent::kMouseDown) | |
| 1808 UpdateLeftClickCount(action_button, motion_event.GetX(0), | |
| 1809 motion_event.GetY(0)); | |
| 1810 | |
| 1811 int click_count = 0; | |
| 1812 | |
| 1813 if (webMouseEventType == blink::WebInputEvent::kMouseDown || | |
| 1814 webMouseEventType == blink::WebInputEvent::kMouseUp) | |
| 1815 click_count = (action_button == ui::MotionEventAndroid::BUTTON_PRIMARY) | |
| 1816 ? left_click_count_ | |
| 1817 : 1; | |
| 1818 | |
| 1804 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( | 1819 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( |
| 1805 webMouseEventType, | 1820 webMouseEventType, |
| 1806 ui::EventTimeStampToSeconds(motion_event.GetEventTime()), | 1821 ui::EventTimeStampToSeconds(motion_event.GetEventTime()), |
| 1807 motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(), | 1822 motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(), |
| 1808 motion_event.GetButtonState() ? 1 : 0 /* click count */, | 1823 click_count /* click count */, motion_event.GetPointerId(0), |
|
aelias_OOO_until_Jul13
2017/06/22 01:19:49
no need for "/* click count */" anymore
| |
| 1809 motion_event.GetPointerId(0), motion_event.GetPressure(0), | 1824 motion_event.GetPressure(0), motion_event.GetOrientation(0), |
| 1810 motion_event.GetOrientation(0), motion_event.GetTiltX(0), | 1825 motion_event.GetTiltX(0), motion_event.GetTiltY(0), action_button, |
| 1811 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); | 1826 motion_event.GetToolType(0)); |
| 1812 | 1827 |
| 1813 if (!host_ || !host_->delegate()) | 1828 if (!host_ || !host_->delegate()) |
| 1814 return; | 1829 return; |
| 1815 | 1830 |
| 1816 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1831 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 1817 host_->delegate()->GetInputEventRouter()) { | 1832 host_->delegate()->GetInputEventRouter()) { |
| 1818 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( | 1833 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( |
| 1819 this, &mouse_event, ui::LatencyInfo()); | 1834 this, &mouse_event, ui::LatencyInfo()); |
| 1820 } else { | 1835 } else { |
| 1821 host_->ForwardMouseEvent(mouse_event); | 1836 host_->ForwardMouseEvent(mouse_event); |
| 1822 } | 1837 } |
| 1823 } | 1838 } |
| 1824 | 1839 |
| 1840 void RenderWidgetHostViewAndroid::UpdateLeftClickCount(int action_button, | |
| 1841 float mousedown_x, | |
| 1842 float mousedown_y) { | |
| 1843 if (action_button != ui::MotionEventAndroid::BUTTON_PRIMARY) { | |
| 1844 // Reset state if middle or right button was pressed. | |
| 1845 left_click_count_ = 0; | |
| 1846 prev_mousedown_timestamp_ = base::TimeTicks(); | |
| 1847 return; | |
| 1848 } | |
| 1849 | |
| 1850 const base::TimeTicks current_time = base::TimeTicks::Now(); | |
| 1851 const base::TimeDelta time_delay = current_time - prev_mousedown_timestamp_; | |
| 1852 const gfx::Point mousedown_point(mousedown_x, mousedown_y); | |
| 1853 const float distance_squared = | |
| 1854 (mousedown_point - prev_mousedown_point_).LengthSquared(); | |
| 1855 if (left_click_count_ > 2 || time_delay > kClickCountInterval || | |
| 1856 distance_squared > kClickCountRadiusSquaredDIP) { | |
| 1857 left_click_count_ = 0; | |
| 1858 } | |
| 1859 left_click_count_++; | |
| 1860 prev_mousedown_timestamp_ = current_time; | |
| 1861 prev_mousedown_point_ = mousedown_point; | |
| 1862 } | |
| 1863 | |
| 1825 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( | 1864 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
| 1826 const blink::WebMouseWheelEvent& event) { | 1865 const blink::WebMouseWheelEvent& event) { |
| 1827 if (!host_ || !host_->delegate()) | 1866 if (!host_ || !host_->delegate()) |
| 1828 return; | 1867 return; |
| 1829 | 1868 |
| 1830 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); | 1869 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 1831 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1870 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1832 blink::WebMouseWheelEvent wheel_event(event); | 1871 blink::WebMouseWheelEvent wheel_event(event); |
| 1833 bool should_route_event = | 1872 bool should_route_event = |
| 1834 SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1873 SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2276 | 2315 |
| 2277 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2316 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2278 if (!compositor) | 2317 if (!compositor) |
| 2279 return; | 2318 return; |
| 2280 | 2319 |
| 2281 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2320 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2282 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2321 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2283 } | 2322 } |
| 2284 | 2323 |
| 2285 } // namespace content | 2324 } // namespace content |
| OLD | NEW |