| 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 "cc/trees/layer_tree_host.h" | 36 #include "cc/trees/layer_tree_host.h" |
| 37 #include "components/viz/service/display_compositor/gl_helper.h" | 37 #include "components/viz/service/display_compositor/gl_helper.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_impl.h" | 41 #include "content/browser/android/content_view_core_impl.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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 latest_confirmed_begin_frame_sequence_number_( | 450 latest_confirmed_begin_frame_sequence_number_( |
| 450 cc::BeginFrameArgs::kInvalidFrameNumber), | 451 cc::BeginFrameArgs::kInvalidFrameNumber), |
| 451 outstanding_begin_frame_requests_(0), | 452 outstanding_begin_frame_requests_(0), |
| 452 is_showing_(!widget_host->is_hidden()), | 453 is_showing_(!widget_host->is_hidden()), |
| 453 is_window_visible_(true), | 454 is_window_visible_(true), |
| 454 is_window_activity_started_(true), | 455 is_window_activity_started_(true), |
| 455 is_in_vr_(false), | 456 is_in_vr_(false), |
| 456 content_view_core_(nullptr), | 457 content_view_core_(nullptr), |
| 457 ime_adapter_android_(nullptr), | 458 ime_adapter_android_(nullptr), |
| 458 selection_popup_controller_(nullptr), | 459 selection_popup_controller_(nullptr), |
| 460 text_suggestion_host_(nullptr), |
| 459 background_color_(SK_ColorWHITE), | 461 background_color_(SK_ColorWHITE), |
| 460 cached_background_color_(SK_ColorWHITE), | 462 cached_background_color_(SK_ColorWHITE), |
| 461 view_(this), | 463 view_(this), |
| 462 gesture_provider_(ui::GetGestureProviderConfig( | 464 gesture_provider_(ui::GetGestureProviderConfig( |
| 463 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 465 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 464 this), | 466 this), |
| 465 stylus_text_selector_(this), | 467 stylus_text_selector_(this), |
| 466 using_browser_compositor_(CompositorImpl::IsInitialized()), | 468 using_browser_compositor_(CompositorImpl::IsInitialized()), |
| 467 synchronous_compositor_client_(nullptr), | 469 synchronous_compositor_client_(nullptr), |
| 468 frame_evictor_(new viz::FrameEvictor(this)), | 470 frame_evictor_(new viz::FrameEvictor(this)), |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 return weak_ptr_factory_.GetWeakPtr(); | 941 return weak_ptr_factory_.GetWeakPtr(); |
| 940 } | 942 } |
| 941 | 943 |
| 942 bool RenderWidgetHostViewAndroid::OnTouchEvent( | 944 bool RenderWidgetHostViewAndroid::OnTouchEvent( |
| 943 const ui::MotionEvent& event) { | 945 const ui::MotionEvent& event) { |
| 944 if (!host_ || !host_->delegate()) | 946 if (!host_ || !host_->delegate()) |
| 945 return false; | 947 return false; |
| 946 | 948 |
| 947 ComputeEventLatencyOSTouchHistograms(event); | 949 ComputeEventLatencyOSTouchHistograms(event); |
| 948 | 950 |
| 951 // Receiving any other touch event before the double-tap timeout expires |
| 952 // cancels opening the spellcheck menu. |
| 953 if (text_suggestion_host_) |
| 954 text_suggestion_host_->StopSpellCheckMenuTimer(); |
| 955 |
| 949 // If a browser-based widget consumes the touch event, it's critical that | 956 // If a browser-based widget consumes the touch event, it's critical that |
| 950 // touch event interception be disabled. This avoids issues with | 957 // touch event interception be disabled. This avoids issues with |
| 951 // double-handling for embedder-detected gestures like side swipe. | 958 // double-handling for embedder-detected gestures like side swipe. |
| 952 if (touch_selection_controller_ && | 959 if (touch_selection_controller_ && |
| 953 touch_selection_controller_->WillHandleTouchEvent(event)) { | 960 touch_selection_controller_->WillHandleTouchEvent(event)) { |
| 954 RequestDisallowInterceptTouchEvent(); | 961 RequestDisallowInterceptTouchEvent(); |
| 955 return true; | 962 return true; |
| 956 } | 963 } |
| 957 | 964 |
| 958 if (stylus_text_selector_.OnTouchEvent(event)) { | 965 if (stylus_text_selector_.OnTouchEvent(event)) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( | 1039 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( |
| 1033 bool enabled) { | 1040 bool enabled) { |
| 1034 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); | 1041 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); |
| 1035 } | 1042 } |
| 1036 | 1043 |
| 1037 void RenderWidgetHostViewAndroid::FocusedNodeChanged( | 1044 void RenderWidgetHostViewAndroid::FocusedNodeChanged( |
| 1038 bool is_editable_node, | 1045 bool is_editable_node, |
| 1039 const gfx::Rect& node_bounds_in_screen) { | 1046 const gfx::Rect& node_bounds_in_screen) { |
| 1040 if (ime_adapter_android_) | 1047 if (ime_adapter_android_) |
| 1041 ime_adapter_android_->FocusedNodeChanged(is_editable_node); | 1048 ime_adapter_android_->FocusedNodeChanged(is_editable_node); |
| 1049 if (text_suggestion_host_) |
| 1050 text_suggestion_host_->FocusedNodeChanged(); |
| 1042 } | 1051 } |
| 1043 | 1052 |
| 1044 void RenderWidgetHostViewAndroid::RenderProcessGone( | 1053 void RenderWidgetHostViewAndroid::RenderProcessGone( |
| 1045 base::TerminationStatus status, int error_code) { | 1054 base::TerminationStatus status, int error_code) { |
| 1046 Destroy(); | 1055 Destroy(); |
| 1047 } | 1056 } |
| 1048 | 1057 |
| 1049 void RenderWidgetHostViewAndroid::Destroy() { | 1058 void RenderWidgetHostViewAndroid::Destroy() { |
| 1050 host_->ViewDestroyed(); | 1059 host_->ViewDestroyed(); |
| 1051 SetContentViewCore(NULL); | 1060 SetContentViewCore(NULL); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 | 1793 |
| 1785 RenderWidgetHostImpl* target_host = host_; | 1794 RenderWidgetHostImpl* target_host = host_; |
| 1786 | 1795 |
| 1787 // If there are multiple widgets on the page (such as when there are | 1796 // If there are multiple widgets on the page (such as when there are |
| 1788 // out-of-process iframes), pick the one that should process this event. | 1797 // out-of-process iframes), pick the one that should process this event. |
| 1789 if (host_->delegate()) | 1798 if (host_->delegate()) |
| 1790 target_host = host_->delegate()->GetFocusedRenderWidgetHost(host_); | 1799 target_host = host_->delegate()->GetFocusedRenderWidgetHost(host_); |
| 1791 if (!target_host) | 1800 if (!target_host) |
| 1792 return; | 1801 return; |
| 1793 | 1802 |
| 1803 // Receiving a key event before the double-tap timeout expires cancels opening |
| 1804 // the spellcheck menu. |
| 1805 if (text_suggestion_host_) |
| 1806 text_suggestion_host_->StopSpellCheckMenuTimer(); |
| 1807 |
| 1794 ui::LatencyInfo latency_info; | 1808 ui::LatencyInfo latency_info; |
| 1795 if (event.GetType() == blink::WebInputEvent::kRawKeyDown || | 1809 if (event.GetType() == blink::WebInputEvent::kRawKeyDown || |
| 1796 event.GetType() == blink::WebInputEvent::kChar) { | 1810 event.GetType() == blink::WebInputEvent::kChar) { |
| 1797 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); | 1811 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); |
| 1798 } | 1812 } |
| 1799 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1813 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1800 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); | 1814 target_host->ForwardKeyboardEventWithLatencyInfo(event, latency_info); |
| 1801 } | 1815 } |
| 1802 | 1816 |
| 1803 void RenderWidgetHostViewAndroid::SendMouseEvent( | 1817 void RenderWidgetHostViewAndroid::SendMouseEvent( |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 | 2330 |
| 2317 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2331 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2318 if (!compositor) | 2332 if (!compositor) |
| 2319 return; | 2333 return; |
| 2320 | 2334 |
| 2321 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2335 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2322 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2336 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2323 } | 2337 } |
| 2324 | 2338 |
| 2325 } // namespace content | 2339 } // namespace content |
| OLD | NEW |