| 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 25 matching lines...) Expand all Loading... |
| 36 #include "components/viz/common/gl_helper.h" | 36 #include "components/viz/common/gl_helper.h" |
| 37 #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" | 37 #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" |
| 38 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 38 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
| 39 #include "content/browser/accessibility/web_contents_accessibility_android.h" | 39 #include "content/browser/accessibility/web_contents_accessibility_android.h" |
| 40 #include "content/browser/android/composited_touch_handle_drawable.h" | 40 #include "content/browser/android/composited_touch_handle_drawable.h" |
| 41 #include "content/browser/android/content_view_core.h" | 41 #include "content/browser/android/content_view_core.h" |
| 42 #include "content/browser/android/ime_adapter_android.h" | 42 #include "content/browser/android/ime_adapter_android.h" |
| 43 #include "content/browser/android/overscroll_controller_android.h" | 43 #include "content/browser/android/overscroll_controller_android.h" |
| 44 #include "content/browser/android/selection_popup_controller.h" | 44 #include "content/browser/android/selection_popup_controller.h" |
| 45 #include "content/browser/android/synchronous_compositor_host.h" | 45 #include "content/browser/android/synchronous_compositor_host.h" |
| 46 #include "content/browser/android/text_suggestion_host_android.h" |
| 46 #include "content/browser/compositor/surface_utils.h" | 47 #include "content/browser/compositor/surface_utils.h" |
| 47 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 48 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 48 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 49 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 49 #include "content/browser/gpu/compositor_util.h" | 50 #include "content/browser/gpu/compositor_util.h" |
| 50 #include "content/browser/gpu/gpu_data_manager_impl.h" | 51 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 51 #include "content/browser/gpu/gpu_process_host.h" | 52 #include "content/browser/gpu/gpu_process_host.h" |
| 52 #include "content/browser/media/android/media_web_contents_observer_android.h" | 53 #include "content/browser/media/android/media_web_contents_observer_android.h" |
| 53 #include "content/browser/renderer_host/compositor_impl_android.h" | 54 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 54 #include "content/browser/renderer_host/dip_util.h" | 55 #include "content/browser/renderer_host/dip_util.h" |
| 55 #include "content/browser/renderer_host/frame_metadata_util.h" | 56 #include "content/browser/renderer_host/frame_metadata_util.h" |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 : host_(widget_host), | 449 : host_(widget_host), |
| 449 begin_frame_source_(nullptr), | 450 begin_frame_source_(nullptr), |
| 450 outstanding_begin_frame_requests_(0), | 451 outstanding_begin_frame_requests_(0), |
| 451 is_showing_(!widget_host->is_hidden()), | 452 is_showing_(!widget_host->is_hidden()), |
| 452 is_window_visible_(true), | 453 is_window_visible_(true), |
| 453 is_window_activity_started_(true), | 454 is_window_activity_started_(true), |
| 454 is_in_vr_(false), | 455 is_in_vr_(false), |
| 455 content_view_core_(nullptr), | 456 content_view_core_(nullptr), |
| 456 ime_adapter_android_(nullptr), | 457 ime_adapter_android_(nullptr), |
| 457 selection_popup_controller_(nullptr), | 458 selection_popup_controller_(nullptr), |
| 459 text_suggestion_host_(nullptr), |
| 458 background_color_(SK_ColorWHITE), | 460 background_color_(SK_ColorWHITE), |
| 459 cached_background_color_(SK_ColorWHITE), | 461 cached_background_color_(SK_ColorWHITE), |
| 460 view_(this), | 462 view_(this), |
| 461 gesture_provider_(ui::GetGestureProviderConfig( | 463 gesture_provider_(ui::GetGestureProviderConfig( |
| 462 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 464 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 463 this), | 465 this), |
| 464 stylus_text_selector_(this), | 466 stylus_text_selector_(this), |
| 465 using_browser_compositor_(CompositorImpl::IsInitialized()), | 467 using_browser_compositor_(CompositorImpl::IsInitialized()), |
| 466 synchronous_compositor_client_(nullptr), | 468 synchronous_compositor_client_(nullptr), |
| 467 frame_evictor_(new viz::FrameEvictor(this)), | 469 frame_evictor_(new viz::FrameEvictor(this)), |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 return weak_ptr_factory_.GetWeakPtr(); | 959 return weak_ptr_factory_.GetWeakPtr(); |
| 958 } | 960 } |
| 959 | 961 |
| 960 bool RenderWidgetHostViewAndroid::OnTouchEvent( | 962 bool RenderWidgetHostViewAndroid::OnTouchEvent( |
| 961 const ui::MotionEvent& event) { | 963 const ui::MotionEvent& event) { |
| 962 if (!host_ || !host_->delegate()) | 964 if (!host_ || !host_->delegate()) |
| 963 return false; | 965 return false; |
| 964 | 966 |
| 965 ComputeEventLatencyOSTouchHistograms(event); | 967 ComputeEventLatencyOSTouchHistograms(event); |
| 966 | 968 |
| 969 // Receiving any other touch event before the double-tap timeout expires |
| 970 // cancels opening the spellcheck menu. |
| 971 if (text_suggestion_host_) |
| 972 text_suggestion_host_->StopSpellCheckMenuTimer(); |
| 973 |
| 967 // If a browser-based widget consumes the touch event, it's critical that | 974 // If a browser-based widget consumes the touch event, it's critical that |
| 968 // touch event interception be disabled. This avoids issues with | 975 // touch event interception be disabled. This avoids issues with |
| 969 // double-handling for embedder-detected gestures like side swipe. | 976 // double-handling for embedder-detected gestures like side swipe. |
| 970 if (touch_selection_controller_ && | 977 if (touch_selection_controller_ && |
| 971 touch_selection_controller_->WillHandleTouchEvent(event)) { | 978 touch_selection_controller_->WillHandleTouchEvent(event)) { |
| 972 RequestDisallowInterceptTouchEvent(); | 979 RequestDisallowInterceptTouchEvent(); |
| 973 return true; | 980 return true; |
| 974 } | 981 } |
| 975 | 982 |
| 976 if (stylus_text_selector_.OnTouchEvent(event)) { | 983 if (stylus_text_selector_.OnTouchEvent(event)) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( | 1063 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( |
| 1057 bool enabled) { | 1064 bool enabled) { |
| 1058 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); | 1065 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); |
| 1059 } | 1066 } |
| 1060 | 1067 |
| 1061 void RenderWidgetHostViewAndroid::FocusedNodeChanged( | 1068 void RenderWidgetHostViewAndroid::FocusedNodeChanged( |
| 1062 bool is_editable_node, | 1069 bool is_editable_node, |
| 1063 const gfx::Rect& node_bounds_in_screen) { | 1070 const gfx::Rect& node_bounds_in_screen) { |
| 1064 if (ime_adapter_android_) | 1071 if (ime_adapter_android_) |
| 1065 ime_adapter_android_->FocusedNodeChanged(is_editable_node); | 1072 ime_adapter_android_->FocusedNodeChanged(is_editable_node); |
| 1073 if (text_suggestion_host_) |
| 1074 text_suggestion_host_->FocusedNodeChanged(); |
| 1066 } | 1075 } |
| 1067 | 1076 |
| 1068 void RenderWidgetHostViewAndroid::RenderProcessGone( | 1077 void RenderWidgetHostViewAndroid::RenderProcessGone( |
| 1069 base::TerminationStatus status, int error_code) { | 1078 base::TerminationStatus status, int error_code) { |
| 1070 Destroy(); | 1079 Destroy(); |
| 1071 } | 1080 } |
| 1072 | 1081 |
| 1073 void RenderWidgetHostViewAndroid::Destroy() { | 1082 void RenderWidgetHostViewAndroid::Destroy() { |
| 1074 host_->ViewDestroyed(); | 1083 host_->ViewDestroyed(); |
| 1075 SetContentViewCore(NULL); | 1084 SetContentViewCore(NULL); |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 | 1820 |
| 1812 RenderWidgetHostImpl* target_host = host_; | 1821 RenderWidgetHostImpl* target_host = host_; |
| 1813 | 1822 |
| 1814 // If there are multiple widgets on the page (such as when there are | 1823 // If there are multiple widgets on the page (such as when there are |
| 1815 // out-of-process iframes), pick the one that should process this event. | 1824 // out-of-process iframes), pick the one that should process this event. |
| 1816 if (host_->delegate()) | 1825 if (host_->delegate()) |
| 1817 target_host = host_->delegate()->GetFocusedRenderWidgetHost(host_); | 1826 target_host = host_->delegate()->GetFocusedRenderWidgetHost(host_); |
| 1818 if (!target_host) | 1827 if (!target_host) |
| 1819 return; | 1828 return; |
| 1820 | 1829 |
| 1830 // Receiving a key event before the double-tap timeout expires cancels opening |
| 1831 // the spellcheck menu. If the suggestion menu is open, we close the menu. |
| 1832 if (text_suggestion_host_) |
| 1833 text_suggestion_host_->OnKeyEvent(); |
| 1834 |
| 1821 ui::LatencyInfo latency_info; | 1835 ui::LatencyInfo latency_info; |
| 1822 if (event.GetType() == blink::WebInputEvent::kRawKeyDown || | 1836 if (event.GetType() == blink::WebInputEvent::kRawKeyDown || |
| 1823 event.GetType() == blink::WebInputEvent::kChar) { | 1837 event.GetType() == blink::WebInputEvent::kChar) { |
| 1824 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); | 1838 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); |
| 1825 } | 1839 } |
| 1826 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1840 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1827 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); | 1841 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); |
| 1828 } | 1842 } |
| 1829 | 1843 |
| 1830 void RenderWidgetHostViewAndroid::SendMouseEvent( | 1844 void RenderWidgetHostViewAndroid::SendMouseEvent( |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 | 2405 |
| 2392 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2406 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2393 if (!compositor) | 2407 if (!compositor) |
| 2394 return; | 2408 return; |
| 2395 | 2409 |
| 2396 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2410 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2397 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2411 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2398 } | 2412 } |
| 2399 | 2413 |
| 2400 } // namespace content | 2414 } // namespace content |
| OLD | NEW |