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 23 matching lines...) Expand all Loading... |
34 #include "cc/resources/single_release_callback.h" | 34 #include "cc/resources/single_release_callback.h" |
35 #include "cc/surfaces/surface.h" | 35 #include "cc/surfaces/surface.h" |
36 #include "cc/surfaces/surface_factory.h" | 36 #include "cc/surfaces/surface_factory.h" |
37 #include "cc/surfaces/surface_hittest.h" | 37 #include "cc/surfaces/surface_hittest.h" |
38 #include "cc/surfaces/surface_manager.h" | 38 #include "cc/surfaces/surface_manager.h" |
39 #include "cc/trees/layer_tree_host.h" | 39 #include "cc/trees/layer_tree_host.h" |
40 #include "components/display_compositor/gl_helper.h" | 40 #include "components/display_compositor/gl_helper.h" |
41 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 41 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
42 #include "content/browser/android/composited_touch_handle_drawable.h" | 42 #include "content/browser/android/composited_touch_handle_drawable.h" |
43 #include "content/browser/android/content_view_core_impl.h" | 43 #include "content/browser/android/content_view_core_impl.h" |
44 #include "content/browser/android/ime_adapter_android.h" | |
45 #include "content/browser/android/overscroll_controller_android.h" | 44 #include "content/browser/android/overscroll_controller_android.h" |
46 #include "content/browser/android/synchronous_compositor_host.h" | 45 #include "content/browser/android/synchronous_compositor_host.h" |
47 #include "content/browser/compositor/surface_utils.h" | 46 #include "content/browser/compositor/surface_utils.h" |
48 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 47 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
49 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 48 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
50 #include "content/browser/gpu/compositor_util.h" | 49 #include "content/browser/gpu/compositor_util.h" |
51 #include "content/browser/gpu/gpu_data_manager_impl.h" | 50 #include "content/browser/gpu/gpu_data_manager_impl.h" |
52 #include "content/browser/gpu/gpu_process_host.h" | 51 #include "content/browser/gpu/gpu_process_host.h" |
53 #include "content/browser/media/android/media_web_contents_observer_android.h" | 52 #include "content/browser/media/android/media_web_contents_observer_android.h" |
54 #include "content/browser/renderer_host/compositor_impl_android.h" | 53 #include "content/browser/renderer_host/compositor_impl_android.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 begin_frame_source_(nullptr), | 443 begin_frame_source_(nullptr), |
445 latest_confirmed_begin_frame_source_id_(0), | 444 latest_confirmed_begin_frame_source_id_(0), |
446 latest_confirmed_begin_frame_sequence_number_( | 445 latest_confirmed_begin_frame_sequence_number_( |
447 cc::BeginFrameArgs::kInvalidFrameNumber), | 446 cc::BeginFrameArgs::kInvalidFrameNumber), |
448 outstanding_begin_frame_requests_(0), | 447 outstanding_begin_frame_requests_(0), |
449 is_showing_(!widget_host->is_hidden()), | 448 is_showing_(!widget_host->is_hidden()), |
450 is_window_visible_(true), | 449 is_window_visible_(true), |
451 is_window_activity_started_(true), | 450 is_window_activity_started_(true), |
452 is_in_vr_(false), | 451 is_in_vr_(false), |
453 content_view_core_(nullptr), | 452 content_view_core_(nullptr), |
454 ime_adapter_android_(nullptr), | 453 ime_adapter_android_(this), |
455 cached_background_color_(SK_ColorWHITE), | 454 cached_background_color_(SK_ColorWHITE), |
456 view_(this), | 455 view_(this), |
457 gesture_provider_(ui::GetGestureProviderConfig( | 456 gesture_provider_(ui::GetGestureProviderConfig( |
458 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 457 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
459 this), | 458 this), |
460 stylus_text_selector_(this), | 459 stylus_text_selector_(this), |
461 using_browser_compositor_(CompositorImpl::IsInitialized()), | 460 using_browser_compositor_(CompositorImpl::IsInitialized()), |
462 synchronous_compositor_client_(nullptr), | 461 synchronous_compositor_client_(nullptr), |
463 frame_evictor_(new DelegatedFrameEvictor(this)), | 462 frame_evictor_(new DelegatedFrameEvictor(this)), |
464 observing_root_window_(false), | 463 observing_root_window_(false), |
(...skipping 25 matching lines...) Expand all Loading... |
490 CreateOverscrollControllerIfPossible(); | 489 CreateOverscrollControllerIfPossible(); |
491 | 490 |
492 if (GetTextInputManager()) | 491 if (GetTextInputManager()) |
493 GetTextInputManager()->AddObserver(this); | 492 GetTextInputManager()->AddObserver(this); |
494 } | 493 } |
495 | 494 |
496 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 495 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
497 if (content_view_core_) | 496 if (content_view_core_) |
498 content_view_core_->RemoveObserver(this); | 497 content_view_core_->RemoveObserver(this); |
499 SetContentViewCore(NULL); | 498 SetContentViewCore(NULL); |
500 ime_adapter_android_ = nullptr; | |
501 DCHECK(ack_callbacks_.empty()); | 499 DCHECK(ack_callbacks_.empty()); |
502 DCHECK(!delegated_frame_host_); | 500 DCHECK(!delegated_frame_host_); |
503 } | 501 } |
504 | 502 |
505 void RenderWidgetHostViewAndroid::Blur() { | 503 void RenderWidgetHostViewAndroid::Blur() { |
506 host_->Blur(); | 504 host_->Blur(); |
507 if (overscroll_controller_) | 505 if (overscroll_controller_) |
508 overscroll_controller_->Disable(); | 506 overscroll_controller_->Disable(); |
509 } | 507 } |
510 | 508 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 696 |
699 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { | 697 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { |
700 // There are no cursors on Android. | 698 // There are no cursors on Android. |
701 } | 699 } |
702 | 700 |
703 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 701 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
704 // Do nothing. The UI notification is handled through ContentViewClient which | 702 // Do nothing. The UI notification is handled through ContentViewClient which |
705 // is TabContentsDelegate. | 703 // is TabContentsDelegate. |
706 } | 704 } |
707 | 705 |
| 706 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { |
| 707 return reinterpret_cast<intptr_t>(&ime_adapter_android_); |
| 708 } |
| 709 |
708 // ----------------------------------------------------------------------------- | 710 // ----------------------------------------------------------------------------- |
709 // TextInputManager::Observer implementations. | 711 // TextInputManager::Observer implementations. |
710 void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled( | 712 void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled( |
711 TextInputManager* text_input_manager, | 713 TextInputManager* text_input_manager, |
712 RenderWidgetHostViewBase* updated_view, | 714 RenderWidgetHostViewBase* updated_view, |
713 bool did_change_state) { | 715 bool did_change_state) { |
714 DCHECK_EQ(text_input_manager_, text_input_manager); | 716 DCHECK_EQ(text_input_manager_, text_input_manager); |
715 // If there are no active widgets, the TextInputState.type should be reported | 717 // If there are no active widgets, the TextInputState.type should be reported |
716 // as none. | 718 // as none. |
717 const TextInputState& state = | 719 const TextInputState& state = |
718 GetTextInputManager()->GetActiveWidget() | 720 GetTextInputManager()->GetActiveWidget() |
719 ? *GetTextInputManager()->GetTextInputState() | 721 ? *GetTextInputManager()->GetTextInputState() |
720 : TextInputState(); | 722 : TextInputState(); |
721 | 723 |
722 if (!content_view_core_ || is_in_vr_) | 724 if (!content_view_core_ || is_in_vr_) |
723 return; | 725 return; |
724 | 726 |
725 content_view_core_->UpdateImeAdapter( | 727 content_view_core_->UpdateImeAdapter( |
726 static_cast<int>(state.type), state.flags, state.mode, state.value, | 728 GetNativeImeAdapter(), static_cast<int>(state.type), state.flags, |
727 state.selection_start, state.selection_end, state.composition_start, | 729 state.mode, state.value, state.selection_start, state.selection_end, |
728 state.composition_end, state.show_ime_if_needed, state.reply_to_request); | 730 state.composition_start, state.composition_end, state.show_ime_if_needed, |
| 731 state.reply_to_request); |
729 } | 732 } |
730 | 733 |
731 void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged( | 734 void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged( |
732 TextInputManager* text_input_manager, | 735 TextInputManager* text_input_manager, |
733 RenderWidgetHostViewBase* updated_view) { | 736 RenderWidgetHostViewBase* updated_view) { |
734 DCHECK_EQ(text_input_manager_, text_input_manager); | 737 DCHECK_EQ(text_input_manager_, text_input_manager); |
735 const TextInputManager::CompositionRangeInfo* info = | 738 const TextInputManager::CompositionRangeInfo* info = |
736 text_input_manager_->GetCompositionRangeInfo(); | 739 text_input_manager_->GetCompositionRangeInfo(); |
737 if (!info) | 740 if (!info) |
738 return; | 741 return; |
739 | 742 |
740 std::vector<gfx::RectF> character_bounds; | 743 std::vector<gfx::RectF> character_bounds; |
741 for (const gfx::Rect& rect : info->character_bounds) | 744 for (const gfx::Rect& rect : info->character_bounds) |
742 character_bounds.emplace_back(rect); | 745 character_bounds.emplace_back(rect); |
743 | 746 |
744 if (ime_adapter_android_) | 747 ime_adapter_android_.SetCharacterBounds(character_bounds); |
745 ime_adapter_android_->SetCharacterBounds(character_bounds); | |
746 } | 748 } |
747 | 749 |
748 void RenderWidgetHostViewAndroid::OnImeCancelComposition( | 750 void RenderWidgetHostViewAndroid::OnImeCancelComposition( |
749 TextInputManager* text_input_manager, | 751 TextInputManager* text_input_manager, |
750 RenderWidgetHostViewBase* updated_view) { | 752 RenderWidgetHostViewBase* updated_view) { |
751 DCHECK_EQ(text_input_manager_, text_input_manager); | 753 DCHECK_EQ(text_input_manager_, text_input_manager); |
752 if (ime_adapter_android_) | 754 ime_adapter_android_.CancelComposition(); |
753 ime_adapter_android_->CancelComposition(); | |
754 } | 755 } |
755 | 756 |
756 void RenderWidgetHostViewAndroid::OnTextSelectionChanged( | 757 void RenderWidgetHostViewAndroid::OnTextSelectionChanged( |
757 TextInputManager* text_input_manager, | 758 TextInputManager* text_input_manager, |
758 RenderWidgetHostViewBase* updated_view) { | 759 RenderWidgetHostViewBase* updated_view) { |
759 DCHECK_EQ(text_input_manager_, text_input_manager); | 760 DCHECK_EQ(text_input_manager_, text_input_manager); |
760 | 761 |
761 // TODO(asimjour): remove the flag and fix text selection popup for | 762 // TODO(asimjour): remove the flag and fix text selection popup for |
762 // virtual reality mode. | 763 // virtual reality mode. |
763 if (is_in_vr_) | 764 if (is_in_vr_) |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 } | 997 } |
997 | 998 |
998 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( | 999 void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled( |
999 bool enabled) { | 1000 bool enabled) { |
1000 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); | 1001 gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); |
1001 } | 1002 } |
1002 | 1003 |
1003 void RenderWidgetHostViewAndroid::FocusedNodeChanged( | 1004 void RenderWidgetHostViewAndroid::FocusedNodeChanged( |
1004 bool is_editable_node, | 1005 bool is_editable_node, |
1005 const gfx::Rect& node_bounds_in_screen) { | 1006 const gfx::Rect& node_bounds_in_screen) { |
1006 if (ime_adapter_android_) | 1007 ime_adapter_android_.FocusedNodeChanged(is_editable_node); |
1007 ime_adapter_android_->FocusedNodeChanged(is_editable_node); | |
1008 } | 1008 } |
1009 | 1009 |
1010 void RenderWidgetHostViewAndroid::RenderProcessGone( | 1010 void RenderWidgetHostViewAndroid::RenderProcessGone( |
1011 base::TerminationStatus status, int error_code) { | 1011 base::TerminationStatus status, int error_code) { |
1012 Destroy(); | 1012 Destroy(); |
1013 } | 1013 } |
1014 | 1014 |
1015 void RenderWidgetHostViewAndroid::Destroy() { | 1015 void RenderWidgetHostViewAndroid::Destroy() { |
1016 host_->ViewDestroyed(); | 1016 host_->ViewDestroyed(); |
1017 SetContentViewCore(NULL); | 1017 SetContentViewCore(NULL); |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 | 2159 |
2160 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2160 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
2161 if (!compositor) | 2161 if (!compositor) |
2162 return; | 2162 return; |
2163 | 2163 |
2164 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2164 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
2165 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2165 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
2166 } | 2166 } |
2167 | 2167 |
2168 } // namespace content | 2168 } // namespace content |
OLD | NEW |