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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 view_.SetLayer(cc::Layer::Create()); | 459 view_.SetLayer(cc::Layer::Create()); |
| 460 if (using_browser_compositor_) { | 460 if (using_browser_compositor_) { |
| 461 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( | 461 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( |
| 462 &view_, cached_background_color_, | 462 &view_, cached_background_color_, |
| 463 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, | 463 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, |
| 464 weak_ptr_factory_.GetWeakPtr()))); | 464 weak_ptr_factory_.GetWeakPtr()))); |
| 465 } | 465 } |
| 466 | 466 |
| 467 host_->SetView(this); | 467 host_->SetView(this); |
| 468 SetContentViewCore(content_view_core); | 468 SetContentViewCore(content_view_core); |
| 469 | |
| 470 if (GetTextInputManager()) | |
| 471 GetTextInputManager()->AddObserver(this); | |
| 469 } | 472 } |
| 470 | 473 |
| 471 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 474 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| 472 if (content_view_core_) | 475 if (content_view_core_) |
| 473 content_view_core_->RemoveObserver(this); | 476 content_view_core_->RemoveObserver(this); |
| 474 SetContentViewCore(NULL); | 477 SetContentViewCore(NULL); |
| 475 DCHECK(ack_callbacks_.empty()); | 478 DCHECK(ack_callbacks_.empty()); |
| 476 DCHECK(!delegated_frame_host_); | 479 DCHECK(!delegated_frame_host_); |
| 477 } | 480 } |
| 478 | 481 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 | 757 |
| 755 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 758 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
| 756 // Do nothing. The UI notification is handled through ContentViewClient which | 759 // Do nothing. The UI notification is handled through ContentViewClient which |
| 757 // is TabContentsDelegate. | 760 // is TabContentsDelegate. |
| 758 } | 761 } |
| 759 | 762 |
| 760 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { | 763 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { |
| 761 return reinterpret_cast<intptr_t>(&ime_adapter_android_); | 764 return reinterpret_cast<intptr_t>(&ime_adapter_android_); |
| 762 } | 765 } |
| 763 | 766 |
| 764 void RenderWidgetHostViewAndroid::TextInputStateChanged( | 767 // ----------------------------------------------------------------------------- |
| 765 const TextInputState& params) { | 768 // TextInputManager::Observer implementations. |
| 766 if (params.is_non_ime_change) { | 769 void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled( |
| 770 TextInputManager* text_input_manager, | |
|
Charlie Reis
2016/11/02 22:23:13
RenderWidgetHostViewAura's version of this method
EhsanK
2016/11/18 19:55:59
I added it here for now but my mindeset behind thi
Charlie Reis
2016/11/23 23:27:21
Thanks-- I think it's worth keeping.
| |
| 771 RenderWidgetHostViewBase* updated_view, | |
| 772 bool did_change_state) { | |
| 773 const TextInputState& state = | |
| 774 *GetTextInputManager()->GetTextInputState(updated_view); | |
| 775 if (state.is_non_ime_change && updated_view->GetRenderWidgetHost()) { | |
| 767 // Sends an acknowledgement to the renderer of a processed IME event. | 776 // Sends an acknowledgement to the renderer of a processed IME event. |
| 768 host_->Send(new InputMsg_ImeEventAck(host_->GetRoutingID())); | 777 updated_view->GetRenderWidgetHost()->Send( |
| 778 new InputMsg_ImeEventAck(host_->GetRoutingID())); | |
| 769 } | 779 } |
| 770 | 780 |
| 771 if (!content_view_core_) | 781 if (!content_view_core_) |
| 772 return; | 782 return; |
| 773 | 783 |
| 774 content_view_core_->UpdateImeAdapter( | 784 content_view_core_->UpdateImeAdapter( |
| 775 GetNativeImeAdapter(), | 785 GetNativeImeAdapter(), static_cast<int>(state.type), state.flags, |
| 776 static_cast<int>(params.type), params.flags, | 786 state.value, state.selection_start, state.selection_end, |
| 777 params.value, params.selection_start, params.selection_end, | 787 state.composition_start, state.composition_end, state.show_ime_if_needed, |
| 778 params.composition_start, params.composition_end, | 788 state.is_non_ime_change, state.batch_edit); |
| 779 params.show_ime_if_needed, params.is_non_ime_change, | |
| 780 params.batch_edit); | |
| 781 } | 789 } |
| 782 | 790 |
| 783 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { | 791 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { |
| 784 if (cached_background_color_ == color) | 792 if (cached_background_color_ == color) |
| 785 return; | 793 return; |
| 786 | 794 |
| 787 cached_background_color_ = color; | 795 cached_background_color_ = color; |
| 788 | 796 |
| 789 if (delegated_frame_host_) | 797 if (delegated_frame_host_) |
| 790 delegated_frame_host_->UpdateBackgroundColor(color); | 798 delegated_frame_host_->UpdateBackgroundColor(color); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 } | 932 } |
| 925 | 933 |
| 926 void RenderWidgetHostViewAndroid::Destroy() { | 934 void RenderWidgetHostViewAndroid::Destroy() { |
| 927 host_->ViewDestroyed(); | 935 host_->ViewDestroyed(); |
| 928 SetContentViewCore(NULL); | 936 SetContentViewCore(NULL); |
| 929 delegated_frame_host_.reset(); | 937 delegated_frame_host_.reset(); |
| 930 | 938 |
| 931 // The RenderWidgetHost's destruction led here, so don't call it. | 939 // The RenderWidgetHost's destruction led here, so don't call it. |
| 932 host_ = NULL; | 940 host_ = NULL; |
| 933 | 941 |
| 942 if (GetTextInputManager() && GetTextInputManager()->HasObserver(this)) | |
| 943 GetTextInputManager()->RemoveObserver(this); | |
| 944 | |
| 934 delete this; | 945 delete this; |
| 935 } | 946 } |
| 936 | 947 |
| 937 void RenderWidgetHostViewAndroid::SetTooltipText( | 948 void RenderWidgetHostViewAndroid::SetTooltipText( |
| 938 const base::string16& tooltip_text) { | 949 const base::string16& tooltip_text) { |
| 939 // Tooltips don't makes sense on Android. | 950 // Tooltips don't makes sense on Android. |
| 940 } | 951 } |
| 941 | 952 |
| 942 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, | 953 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, |
| 943 size_t offset, | 954 size_t offset, |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1990 case ui::MotionEvent::ACTION_UP: | 2001 case ui::MotionEvent::ACTION_UP: |
| 1991 case ui::MotionEvent::ACTION_POINTER_UP: | 2002 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2003 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1993 delta.InMicroseconds(), 1, 1000000, 50); | 2004 delta.InMicroseconds(), 1, 1000000, 50); |
| 1994 default: | 2005 default: |
| 1995 return; | 2006 return; |
| 1996 } | 2007 } |
| 1997 } | 2008 } |
| 1998 | 2009 |
| 1999 } // namespace content | 2010 } // namespace content |
| OLD | NEW |