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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 gesture_provider_(ui::GetGestureProviderConfig( | 457 gesture_provider_(ui::GetGestureProviderConfig( |
458 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 458 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
459 this), | 459 this), |
460 stylus_text_selector_(this), | 460 stylus_text_selector_(this), |
461 using_browser_compositor_(CompositorImpl::IsInitialized()), | 461 using_browser_compositor_(CompositorImpl::IsInitialized()), |
462 synchronous_compositor_client_(nullptr), | 462 synchronous_compositor_client_(nullptr), |
463 frame_evictor_(new viz::FrameEvictor(this)), | 463 frame_evictor_(new viz::FrameEvictor(this)), |
464 observing_root_window_(false), | 464 observing_root_window_(false), |
465 prev_top_shown_pix_(0.f), | 465 prev_top_shown_pix_(0.f), |
466 prev_bottom_shown_pix_(0.f), | 466 prev_bottom_shown_pix_(0.f), |
| 467 mouse_wheel_phase_handler_(widget_host, this), |
467 weak_ptr_factory_(this) { | 468 weak_ptr_factory_(this) { |
468 // Set the layer which will hold the content layer for this view. The content | 469 // Set the layer which will hold the content layer for this view. The content |
469 // layer is managed by the DelegatedFrameHost. | 470 // layer is managed by the DelegatedFrameHost. |
470 view_.SetLayer(cc::Layer::Create()); | 471 view_.SetLayer(cc::Layer::Create()); |
471 view_.SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); | 472 view_.SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); |
472 | 473 |
473 if (using_browser_compositor_) { | 474 if (using_browser_compositor_) { |
474 cc::FrameSinkId frame_sink_id = | 475 cc::FrameSinkId frame_sink_id = |
475 host_->AllocateFrameSinkId(false /* is_guest_view_hack */); | 476 host_->AllocateFrameSinkId(false /* is_guest_view_hack */); |
476 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( | 477 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 } | 1814 } |
1814 } | 1815 } |
1815 | 1816 |
1816 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( | 1817 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
1817 const blink::WebMouseWheelEvent& event) { | 1818 const blink::WebMouseWheelEvent& event) { |
1818 if (!host_ || !host_->delegate()) | 1819 if (!host_ || !host_->delegate()) |
1819 return; | 1820 return; |
1820 | 1821 |
1821 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); | 1822 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
1822 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1823 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
1823 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1824 blink::WebMouseWheelEvent wheel_event(event); |
1824 host_->delegate()->GetInputEventRouter()) { | 1825 bool should_route_event = |
1825 blink::WebMouseWheelEvent wheel_event(event); | 1826 SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 1827 host_->delegate()->GetInputEventRouter(); |
| 1828 if (wheel_scroll_latching_enabled()) { |
| 1829 mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent( |
| 1830 wheel_event, should_route_event); |
| 1831 } |
| 1832 if (should_route_event) { |
1826 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 1833 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
1827 this, &wheel_event, latency_info); | 1834 this, &wheel_event, latency_info); |
1828 } else { | 1835 } else { |
1829 host_->ForwardWheelEventWithLatencyInfo(event, latency_info); | 1836 host_->ForwardWheelEventWithLatencyInfo(wheel_event, latency_info); |
1830 } | 1837 } |
1831 } | 1838 } |
1832 | 1839 |
1833 void RenderWidgetHostViewAndroid::SendGestureEvent( | 1840 void RenderWidgetHostViewAndroid::SendGestureEvent( |
1834 const blink::WebGestureEvent& event) { | 1841 const blink::WebGestureEvent& event) { |
1835 // Sending a gesture that may trigger overscroll should resume the effect. | 1842 // Sending a gesture that may trigger overscroll should resume the effect. |
1836 if (overscroll_controller_) | 1843 if (overscroll_controller_) |
1837 overscroll_controller_->Enable(); | 1844 overscroll_controller_->Enable(); |
1838 | 1845 |
1839 if (!host_ || !host_->delegate()) | 1846 if (!host_ || !host_->delegate()) |
1840 return; | 1847 return; |
1841 | 1848 |
1842 ui::LatencyInfo latency_info = | 1849 ui::LatencyInfo latency_info = |
1843 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(event); | 1850 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(event); |
1844 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1851 if (wheel_scroll_latching_enabled()) { |
1845 host_->delegate()->GetInputEventRouter()) { | 1852 if (event.source_device == |
| 1853 blink::WebGestureDevice::kWebGestureDeviceTouchscreen) { |
| 1854 if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin) { |
| 1855 // If there is a current scroll going on and a new scroll that isn't |
| 1856 // wheel based, send a synthetic wheel event with kPhaseEnded to cancel |
| 1857 // the current scroll. |
| 1858 mouse_wheel_phase_handler_.DispatchPendingWheelEndEvent(); |
| 1859 } else if (event.GetType() == blink::WebInputEvent::kGestureScrollEnd) { |
| 1860 // Make sure that the next wheel event will have phase = |kPhaseBegan|. |
| 1861 // This is for maintaining the correct phase info when some of the wheel |
| 1862 // events get ignored while a touchscreen scroll is going on. |
| 1863 mouse_wheel_phase_handler_.IgnorePendingWheelEndEvent(); |
| 1864 } |
| 1865 |
| 1866 } else if (event.GetType() == blink::WebInputEvent::kGestureFlingStart && |
| 1867 event.source_device == |
| 1868 blink::WebGestureDevice::kWebGestureDeviceTouchpad) { |
| 1869 // Ignore the pending wheel end event to avoid sending a wheel event with |
| 1870 // kPhaseEnded before a GFS. |
| 1871 mouse_wheel_phase_handler_.IgnorePendingWheelEndEvent(); |
| 1872 } |
| 1873 } |
| 1874 bool should_route_event = |
| 1875 SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 1876 host_->delegate()->GetInputEventRouter(); |
| 1877 if (should_route_event) { |
1846 blink::WebGestureEvent gesture_event(event); | 1878 blink::WebGestureEvent gesture_event(event); |
1847 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 1879 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
1848 this, &gesture_event, latency_info); | 1880 this, &gesture_event, latency_info); |
1849 } else { | 1881 } else { |
1850 host_->ForwardGestureEventWithLatencyInfo(event, latency_info); | 1882 host_->ForwardGestureEventWithLatencyInfo(event, latency_info); |
1851 } | 1883 } |
1852 } | 1884 } |
1853 | 1885 |
1854 void RenderWidgetHostViewAndroid::ResolveTapDisambiguation( | 1886 void RenderWidgetHostViewAndroid::ResolveTapDisambiguation( |
1855 double timestamp_seconds, | 1887 double timestamp_seconds, |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 | 2274 |
2243 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2275 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
2244 if (!compositor) | 2276 if (!compositor) |
2245 return; | 2277 return; |
2246 | 2278 |
2247 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2279 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
2248 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2280 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
2249 } | 2281 } |
2250 | 2282 |
2251 } // namespace content | 2283 } // namespace content |
OLD | NEW |