Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2354793003: Browser Side TextInputState Tracking for Android (Closed)
Patch Set: Rebased + Removed unused Forward Dec Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 view_.SetLayer(cc::Layer::Create()); 461 view_.SetLayer(cc::Layer::Create());
462 if (using_browser_compositor_) { 462 if (using_browser_compositor_) {
463 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( 463 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid(
464 &view_, cached_background_color_, 464 &view_, cached_background_color_,
465 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, 465 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources,
466 weak_ptr_factory_.GetWeakPtr()))); 466 weak_ptr_factory_.GetWeakPtr())));
467 } 467 }
468 468
469 host_->SetView(this); 469 host_->SetView(this);
470 SetContentViewCore(content_view_core); 470 SetContentViewCore(content_view_core);
471
472 if (GetTextInputManager())
473 GetTextInputManager()->AddObserver(this);
471 } 474 }
472 475
473 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 476 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
474 if (content_view_core_) 477 if (content_view_core_)
475 content_view_core_->RemoveObserver(this); 478 content_view_core_->RemoveObserver(this);
476 SetContentViewCore(NULL); 479 SetContentViewCore(NULL);
477 DCHECK(ack_callbacks_.empty()); 480 DCHECK(ack_callbacks_.empty());
478 DCHECK(!delegated_frame_host_); 481 DCHECK(!delegated_frame_host_);
479 } 482 }
480 483
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 753
751 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { 754 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) {
752 // Do nothing. The UI notification is handled through ContentViewClient which 755 // Do nothing. The UI notification is handled through ContentViewClient which
753 // is TabContentsDelegate. 756 // is TabContentsDelegate.
754 } 757 }
755 758
756 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { 759 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() {
757 return reinterpret_cast<intptr_t>(&ime_adapter_android_); 760 return reinterpret_cast<intptr_t>(&ime_adapter_android_);
758 } 761 }
759 762
760 void RenderWidgetHostViewAndroid::TextInputStateChanged( 763 // -----------------------------------------------------------------------------
761 const TextInputState& params) { 764 // TextInputManager::Observer implementations.
762 if (params.is_non_ime_change) { 765 void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled(
766 TextInputManager* text_input_manager,
767 RenderWidgetHostViewBase* updated_view,
768 bool did_change_state) {
769 DCHECK_EQ(text_input_manager_, text_input_manager);
770 const TextInputState& state =
771 *GetTextInputManager()->GetTextInputState(updated_view);
772 if (state.is_non_ime_change && updated_view->GetRenderWidgetHost()) {
763 // Sends an acknowledgement to the renderer of a processed IME event. 773 // Sends an acknowledgement to the renderer of a processed IME event.
764 host_->Send(new InputMsg_ImeEventAck(host_->GetRoutingID())); 774 updated_view->GetRenderWidgetHost()->Send(
775 new InputMsg_ImeEventAck(host_->GetRoutingID()));
765 } 776 }
766 777
767 if (!content_view_core_) 778 if (!content_view_core_)
768 return; 779 return;
769 780
770 content_view_core_->UpdateImeAdapter( 781 content_view_core_->UpdateImeAdapter(
771 GetNativeImeAdapter(), 782 GetNativeImeAdapter(), static_cast<int>(state.type), state.flags,
772 static_cast<int>(params.type), params.flags, 783 state.value, state.selection_start, state.selection_end,
773 params.value, params.selection_start, params.selection_end, 784 state.composition_start, state.composition_end, state.show_ime_if_needed,
774 params.composition_start, params.composition_end, 785 state.is_non_ime_change);
775 params.show_ime_if_needed, params.is_non_ime_change);
776 } 786 }
777 787
778 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { 788 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) {
779 if (cached_background_color_ == color) 789 if (cached_background_color_ == color)
780 return; 790 return;
781 791
782 cached_background_color_ = color; 792 cached_background_color_ = color;
783 793
784 if (delegated_frame_host_) 794 if (delegated_frame_host_)
785 delegated_frame_host_->UpdateBackgroundColor(color); 795 delegated_frame_host_->UpdateBackgroundColor(color);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 929 }
920 930
921 void RenderWidgetHostViewAndroid::Destroy() { 931 void RenderWidgetHostViewAndroid::Destroy() {
922 host_->ViewDestroyed(); 932 host_->ViewDestroyed();
923 SetContentViewCore(NULL); 933 SetContentViewCore(NULL);
924 delegated_frame_host_.reset(); 934 delegated_frame_host_.reset();
925 935
926 // The RenderWidgetHost's destruction led here, so don't call it. 936 // The RenderWidgetHost's destruction led here, so don't call it.
927 host_ = NULL; 937 host_ = NULL;
928 938
939 if (GetTextInputManager() && GetTextInputManager()->HasObserver(this))
940 GetTextInputManager()->RemoveObserver(this);
941
929 delete this; 942 delete this;
930 } 943 }
931 944
932 void RenderWidgetHostViewAndroid::SetTooltipText( 945 void RenderWidgetHostViewAndroid::SetTooltipText(
933 const base::string16& tooltip_text) { 946 const base::string16& tooltip_text) {
934 // Tooltips don't makes sense on Android. 947 // Tooltips don't makes sense on Android.
935 } 948 }
936 949
937 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, 950 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text,
938 size_t offset, 951 size_t offset,
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 case ui::MotionEvent::ACTION_UP: 1990 case ui::MotionEvent::ACTION_UP:
1978 case ui::MotionEvent::ACTION_POINTER_UP: 1991 case ui::MotionEvent::ACTION_POINTER_UP:
1979 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
1980 delta.InMicroseconds(), 1, 1000000, 50); 1993 delta.InMicroseconds(), 1, 1000000, 50);
1981 default: 1994 default:
1982 return; 1995 return;
1983 } 1996 }
1984 } 1997 }
1985 1998
1986 } // namespace content 1999 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698