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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include "content/browser/compositor/surface_utils.h" | 46 #include "content/browser/compositor/surface_utils.h" |
| 47 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 47 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 48 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 48 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 49 #include "content/browser/gpu/compositor_util.h" | 49 #include "content/browser/gpu/compositor_util.h" |
| 50 #include "content/browser/gpu/gpu_data_manager_impl.h" | 50 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 51 #include "content/browser/gpu/gpu_process_host.h" | 51 #include "content/browser/gpu/gpu_process_host.h" |
| 52 #include "content/browser/media/android/media_web_contents_observer_android.h" | 52 #include "content/browser/media/android/media_web_contents_observer_android.h" |
| 53 #include "content/browser/renderer_host/compositor_impl_android.h" | 53 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 54 #include "content/browser/renderer_host/dip_util.h" | 54 #include "content/browser/renderer_host/dip_util.h" |
| 55 #include "content/browser/renderer_host/frame_metadata_util.h" | 55 #include "content/browser/renderer_host/frame_metadata_util.h" |
| 56 #include "content/browser/renderer_host/ime_adapter_android.h" | |
| 56 #include "content/browser/renderer_host/input/input_router_impl.h" | 57 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 57 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h " | 58 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h " |
| 58 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " | 59 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " |
| 59 #include "content/browser/renderer_host/render_process_host_impl.h" | 60 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 60 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 61 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 61 #include "content/browser/renderer_host/render_view_host_impl.h" | 62 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 62 #include "content/browser/renderer_host/render_widget_host_impl.h" | 63 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 63 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 64 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 64 #include "content/common/gpu_host_messages.h" | 65 #include "content/common/gpu_host_messages.h" |
| 65 #include "content/common/input_messages.h" | 66 #include "content/common/input_messages.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 RenderWidgetHostImpl* widget_host, | 443 RenderWidgetHostImpl* widget_host, |
| 443 ContentViewCoreImpl* content_view_core) | 444 ContentViewCoreImpl* content_view_core) |
| 444 : host_(widget_host), | 445 : host_(widget_host), |
| 445 begin_frame_source_(nullptr), | 446 begin_frame_source_(nullptr), |
| 446 outstanding_begin_frame_requests_(0), | 447 outstanding_begin_frame_requests_(0), |
| 447 is_showing_(!widget_host->is_hidden()), | 448 is_showing_(!widget_host->is_hidden()), |
| 448 is_window_visible_(true), | 449 is_window_visible_(true), |
| 449 is_window_activity_started_(true), | 450 is_window_activity_started_(true), |
| 450 is_in_vr_(false), | 451 is_in_vr_(false), |
| 451 content_view_core_(nullptr), | 452 content_view_core_(nullptr), |
| 452 ime_adapter_android_(this), | |
|
boliu
2017/03/22 16:55:02
you still need to initialize this
Jinsuk Kim
2017/03/23 01:17:49
Done.
| |
| 453 cached_background_color_(SK_ColorWHITE), | 453 cached_background_color_(SK_ColorWHITE), |
| 454 view_(this), | 454 view_(this), |
| 455 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), | 455 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), |
| 456 gesture_provider_(ui::GetGestureProviderConfig( | 456 gesture_provider_(ui::GetGestureProviderConfig( |
| 457 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 457 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 458 this), | 458 this), |
| 459 stylus_text_selector_(this), | 459 stylus_text_selector_(this), |
| 460 using_browser_compositor_(CompositorImpl::IsInitialized()), | 460 using_browser_compositor_(CompositorImpl::IsInitialized()), |
| 461 synchronous_compositor_client_(nullptr), | 461 synchronous_compositor_client_(nullptr), |
| 462 frame_evictor_(new DelegatedFrameEvictor(this)), | 462 frame_evictor_(new DelegatedFrameEvictor(this)), |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 489 CreateOverscrollControllerIfPossible(); | 489 CreateOverscrollControllerIfPossible(); |
| 490 | 490 |
| 491 if (GetTextInputManager()) | 491 if (GetTextInputManager()) |
| 492 GetTextInputManager()->AddObserver(this); | 492 GetTextInputManager()->AddObserver(this); |
| 493 } | 493 } |
| 494 | 494 |
| 495 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 495 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| 496 if (content_view_core_) | 496 if (content_view_core_) |
| 497 content_view_core_->RemoveObserver(this); | 497 content_view_core_->RemoveObserver(this); |
| 498 SetContentViewCore(NULL); | 498 SetContentViewCore(NULL); |
| 499 ime_adapter_android_ = nullptr; | |
| 499 DCHECK(ack_callbacks_.empty()); | 500 DCHECK(ack_callbacks_.empty()); |
| 500 DCHECK(!delegated_frame_host_); | 501 DCHECK(!delegated_frame_host_); |
| 501 } | 502 } |
| 502 | 503 |
| 503 void RenderWidgetHostViewAndroid::Blur() { | 504 void RenderWidgetHostViewAndroid::Blur() { |
| 504 host_->Blur(); | 505 host_->Blur(); |
| 505 if (overscroll_controller_) | 506 if (overscroll_controller_) |
| 506 overscroll_controller_->Disable(); | 507 overscroll_controller_->Disable(); |
| 507 } | 508 } |
| 508 | 509 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 | 697 |
| 697 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { | 698 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { |
| 698 // There are no cursors on Android. | 699 // There are no cursors on Android. |
| 699 } | 700 } |
| 700 | 701 |
| 701 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 702 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
| 702 // Do nothing. The UI notification is handled through ContentViewClient which | 703 // Do nothing. The UI notification is handled through ContentViewClient which |
| 703 // is TabContentsDelegate. | 704 // is TabContentsDelegate. |
| 704 } | 705 } |
| 705 | 706 |
| 706 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { | 707 void RenderWidgetHostViewAndroid::ConnectImeAdapter( |
| 707 return reinterpret_cast<intptr_t>(&ime_adapter_android_); | 708 ImeAdapterAndroid* ime_adapter) { |
| 709 ime_adapter_android_ = ime_adapter; | |
| 710 if (ime_adapter) | |
| 711 ime_adapter->SetRenderWidgetHostViewAndroid(weak_ptr_factory_.GetWeakPtr()); | |
| 708 } | 712 } |
| 709 | 713 |
| 710 // ----------------------------------------------------------------------------- | 714 // ----------------------------------------------------------------------------- |
| 711 // TextInputManager::Observer implementations. | 715 // TextInputManager::Observer implementations. |
| 712 void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled( | 716 void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled( |
| 713 TextInputManager* text_input_manager, | 717 TextInputManager* text_input_manager, |
| 714 RenderWidgetHostViewBase* updated_view, | 718 RenderWidgetHostViewBase* updated_view, |
| 715 bool did_change_state) { | 719 bool did_change_state) { |
| 716 DCHECK_EQ(text_input_manager_, text_input_manager); | 720 DCHECK_EQ(text_input_manager_, text_input_manager); |
| 717 // If there are no active widgets, the TextInputState.type should be reported | 721 // If there are no active widgets, the TextInputState.type should be reported |
| 718 // as none. | 722 // as none. |
| 719 const TextInputState& state = | 723 const TextInputState& state = |
| 720 GetTextInputManager()->GetActiveWidget() | 724 GetTextInputManager()->GetActiveWidget() |
| 721 ? *GetTextInputManager()->GetTextInputState() | 725 ? *GetTextInputManager()->GetTextInputState() |
| 722 : TextInputState(); | 726 : TextInputState(); |
| 723 | 727 |
| 724 if (!content_view_core_ || is_in_vr_) | 728 if (!content_view_core_ || is_in_vr_) |
| 725 return; | 729 return; |
| 726 | 730 |
| 727 content_view_core_->UpdateImeAdapter( | 731 content_view_core_->UpdateImeAdapter( |
| 728 GetNativeImeAdapter(), static_cast<int>(state.type), state.flags, | 732 static_cast<int>(state.type), state.flags, state.mode, state.value, |
| 729 state.mode, state.value, state.selection_start, state.selection_end, | 733 state.selection_start, state.selection_end, state.composition_start, |
| 730 state.composition_start, state.composition_end, state.show_ime_if_needed, | 734 state.composition_end, state.show_ime_if_needed, state.reply_to_request); |
| 731 state.reply_to_request); | |
| 732 } | 735 } |
| 733 | 736 |
| 734 void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged( | 737 void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged( |
| 735 TextInputManager* text_input_manager, | 738 TextInputManager* text_input_manager, |
| 736 RenderWidgetHostViewBase* updated_view) { | 739 RenderWidgetHostViewBase* updated_view) { |
| 737 DCHECK_EQ(text_input_manager_, text_input_manager); | 740 DCHECK_EQ(text_input_manager_, text_input_manager); |
| 738 const TextInputManager::CompositionRangeInfo* info = | 741 const TextInputManager::CompositionRangeInfo* info = |
| 739 text_input_manager_->GetCompositionRangeInfo(); | 742 text_input_manager_->GetCompositionRangeInfo(); |
| 740 if (!info) | 743 if (!info) |
| 741 return; | 744 return; |
| 742 | 745 |
| 743 std::vector<gfx::RectF> character_bounds; | 746 std::vector<gfx::RectF> character_bounds; |
| 744 for (const gfx::Rect& rect : info->character_bounds) | 747 for (const gfx::Rect& rect : info->character_bounds) |
| 745 character_bounds.emplace_back(rect); | 748 character_bounds.emplace_back(rect); |
| 746 | 749 |
| 747 ime_adapter_android_.SetCharacterBounds(character_bounds); | 750 DCHECK(ime_adapter_android_); |
| 751 ime_adapter_android_->SetCharacterBounds(character_bounds); | |
| 748 } | 752 } |
| 749 | 753 |
| 750 void RenderWidgetHostViewAndroid::OnImeCancelComposition( | 754 void RenderWidgetHostViewAndroid::OnImeCancelComposition( |
| 751 TextInputManager* text_input_manager, | 755 TextInputManager* text_input_manager, |
| 752 RenderWidgetHostViewBase* updated_view) { | 756 RenderWidgetHostViewBase* updated_view) { |
| 753 DCHECK_EQ(text_input_manager_, text_input_manager); | 757 DCHECK_EQ(text_input_manager_, text_input_manager); |
| 754 ime_adapter_android_.CancelComposition(); | 758 DCHECK(ime_adapter_android_); |
| 759 ime_adapter_android_->CancelComposition(); | |
| 755 } | 760 } |
| 756 | 761 |
| 757 void RenderWidgetHostViewAndroid::OnTextSelectionChanged( | 762 void RenderWidgetHostViewAndroid::OnTextSelectionChanged( |
| 758 TextInputManager* text_input_manager, | 763 TextInputManager* text_input_manager, |
| 759 RenderWidgetHostViewBase* updated_view) { | 764 RenderWidgetHostViewBase* updated_view) { |
| 760 DCHECK_EQ(text_input_manager_, text_input_manager); | 765 DCHECK_EQ(text_input_manager_, text_input_manager); |
| 761 | 766 |
| 762 // TODO(asimjour): remove the flag and fix text selection popup for | 767 // TODO(asimjour): remove the flag and fix text selection popup for |
| 763 // virtual reality mode. | 768 // virtual reality mode. |
| 764 if (is_in_vr_) | 769 if (is_in_vr_) |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 } | 1002 } |
| 998 | 1003 |
| 999 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( | 1004 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( |
| 1000 bool enabled) { | 1005 bool enabled) { |
| 1001 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); | 1006 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); |
| 1002 } | 1007 } |
| 1003 | 1008 |
| 1004 void RenderWidgetHostViewAndroid::FocusedNodeChanged( | 1009 void RenderWidgetHostViewAndroid::FocusedNodeChanged( |
| 1005 bool is_editable_node, | 1010 bool is_editable_node, |
| 1006 const gfx::Rect& node_bounds_in_screen) { | 1011 const gfx::Rect& node_bounds_in_screen) { |
| 1007 ime_adapter_android_.FocusedNodeChanged(is_editable_node); | 1012 DCHECK(ime_adapter_android_); |
| 1013 ime_adapter_android_->FocusedNodeChanged(is_editable_node); | |
| 1008 } | 1014 } |
| 1009 | 1015 |
| 1010 void RenderWidgetHostViewAndroid::RenderProcessGone( | 1016 void RenderWidgetHostViewAndroid::RenderProcessGone( |
| 1011 base::TerminationStatus status, int error_code) { | 1017 base::TerminationStatus status, int error_code) { |
| 1012 Destroy(); | 1018 Destroy(); |
| 1013 } | 1019 } |
| 1014 | 1020 |
| 1015 void RenderWidgetHostViewAndroid::Destroy() { | 1021 void RenderWidgetHostViewAndroid::Destroy() { |
| 1016 host_->ViewDestroyed(); | 1022 host_->ViewDestroyed(); |
| 1017 SetContentViewCore(NULL); | 1023 SetContentViewCore(NULL); |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1855 view_.RemoveFromParent(); | 1861 view_.RemoveFromParent(); |
| 1856 view_.GetLayer()->RemoveFromParent(); | 1862 view_.GetLayer()->RemoveFromParent(); |
| 1857 } | 1863 } |
| 1858 if (content_view_core) { | 1864 if (content_view_core) { |
| 1859 content_view_core->AddObserver(this); | 1865 content_view_core->AddObserver(this); |
| 1860 ui::ViewAndroid* parent_view = content_view_core->GetViewAndroid(); | 1866 ui::ViewAndroid* parent_view = content_view_core->GetViewAndroid(); |
| 1861 parent_view->AddChild(&view_); | 1867 parent_view->AddChild(&view_); |
| 1862 parent_view->GetLayer()->AddChild(view_.GetLayer()); | 1868 parent_view->GetLayer()->AddChild(view_.GetLayer()); |
| 1863 } | 1869 } |
| 1864 content_view_core_ = content_view_core; | 1870 content_view_core_ = content_view_core; |
| 1871 if (content_view_core) | |
| 1872 ConnectImeAdapter(content_view_core->ime_adapter()); | |
| 1865 } | 1873 } |
| 1866 | 1874 |
| 1867 BrowserAccessibilityManager* manager = NULL; | 1875 BrowserAccessibilityManager* manager = NULL; |
| 1868 if (host_) | 1876 if (host_) |
| 1869 manager = host_->GetRootBrowserAccessibilityManager(); | 1877 manager = host_->GetRootBrowserAccessibilityManager(); |
| 1870 if (manager) { | 1878 if (manager) { |
| 1871 base::android::ScopedJavaLocalRef<jobject> obj; | 1879 base::android::ScopedJavaLocalRef<jobject> obj; |
| 1872 if (content_view_core_) | 1880 if (content_view_core_) |
| 1873 obj = content_view_core_->GetJavaObject(); | 1881 obj = content_view_core_->GetJavaObject(); |
| 1874 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); | 1882 manager->ToBrowserAccessibilityManagerAndroid()->SetContentViewCore(obj); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2130 | 2138 |
| 2131 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2139 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2132 if (!compositor) | 2140 if (!compositor) |
| 2133 return; | 2141 return; |
| 2134 | 2142 |
| 2135 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2143 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2136 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2144 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2137 } | 2145 } |
| 2138 | 2146 |
| 2139 } // namespace content | 2147 } // namespace content |
| OLD | NEW |