| 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; |
| 106 static const int kMaxClickSquaredDistance = 25; |
| 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) { |
| 1809 const double time_delay = event_time - prev_mousedown_timestamp_; |
| 1810 const int distance_squared = (motion_event.GetX(0) - prev_mousedown_x) * |
| 1811 (motion_event.GetX(0) - prev_mousedown_x) + |
| 1812 (motion_event.GetY(0) - prev_mousedown_y) * |
| 1813 (motion_event.GetY(0) - prev_mousedown_y); |
| 1814 if (click_count_ > 2 || time_delay > kMaxClickDelay || |
| 1815 distance_squared > kMaxClickSquaredDistance) { |
| 1816 click_count_ = 1; |
| 1817 } else { |
| 1818 click_count_++; |
| 1819 } |
| 1820 prev_mousedown_timestamp_ = event_time; |
| 1821 prev_mousedown_x = motion_event.GetX(0); |
| 1822 prev_mousedown_y = motion_event.GetY(0); |
| 1823 } |
| 1824 |
| 1804 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( | 1825 blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build( |
| 1805 webMouseEventType, | 1826 webMouseEventType, event_time, motion_event.GetX(0), motion_event.GetY(0), |
| 1806 ui::EventTimeStampToSeconds(motion_event.GetEventTime()), | 1827 motion_event.GetFlags(), |
| 1807 motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(), | 1828 motion_event.GetButtonState() ? click_count_ : 0 /* click count */, |
| 1808 motion_event.GetButtonState() ? 1 : 0 /* click count */, | |
| 1809 motion_event.GetPointerId(0), motion_event.GetPressure(0), | 1829 motion_event.GetPointerId(0), motion_event.GetPressure(0), |
| 1810 motion_event.GetOrientation(0), motion_event.GetTiltX(0), | 1830 motion_event.GetOrientation(0), motion_event.GetTiltX(0), |
| 1811 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); | 1831 motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0)); |
| 1812 | 1832 |
| 1813 if (!host_ || !host_->delegate()) | 1833 if (!host_ || !host_->delegate()) |
| 1814 return; | 1834 return; |
| 1815 | 1835 |
| 1816 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1836 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 1817 host_->delegate()->GetInputEventRouter()) { | 1837 host_->delegate()->GetInputEventRouter()) { |
| 1818 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( | 1838 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( |
| 1819 this, &mouse_event, ui::LatencyInfo()); | 1839 this, &mouse_event, ui::LatencyInfo()); |
| 1820 } else { | 1840 } else { |
| 1821 host_->ForwardMouseEvent(mouse_event); | 1841 host_->ForwardMouseEvent(mouse_event); |
| 1822 } | 1842 } |
| 1823 } | 1843 } |
| 1824 | 1844 |
| 1845 void UpdateClickCount(double event_time) {} |
| 1846 |
| 1825 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( | 1847 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
| 1826 const blink::WebMouseWheelEvent& event) { | 1848 const blink::WebMouseWheelEvent& event) { |
| 1827 if (!host_ || !host_->delegate()) | 1849 if (!host_ || !host_->delegate()) |
| 1828 return; | 1850 return; |
| 1829 | 1851 |
| 1830 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); | 1852 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 1831 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1853 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1832 blink::WebMouseWheelEvent wheel_event(event); | 1854 blink::WebMouseWheelEvent wheel_event(event); |
| 1833 bool should_route_event = | 1855 bool should_route_event = |
| 1834 SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1856 SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 | 2298 |
| 2277 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2299 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2278 if (!compositor) | 2300 if (!compositor) |
| 2279 return; | 2301 return; |
| 2280 | 2302 |
| 2281 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2303 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2282 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2304 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2283 } | 2305 } |
| 2284 | 2306 |
| 2285 } // namespace content | 2307 } // namespace content |
| OLD | NEW |