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

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 Created 4 years, 1 month 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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,
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(),
776 static_cast<int>(params.type), params.flags, 786 static_cast<int>(state.type), state.flags,
777 params.value, params.selection_start, params.selection_end, 787 state.value, state.selection_start, state.selection_end,
778 params.composition_start, params.composition_end, 788 state.composition_start, state.composition_end,
779 params.show_ime_if_needed, params.is_non_ime_change, 789 state.show_ime_if_needed, state.is_non_ime_change,
780 params.batch_edit); 790 state.batch_edit);
781 } 791 }
782 792
783 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { 793 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) {
784 if (cached_background_color_ == color) 794 if (cached_background_color_ == color)
785 return; 795 return;
786 796
787 cached_background_color_ = color; 797 cached_background_color_ = color;
788 798
789 if (delegated_frame_host_) 799 if (delegated_frame_host_)
790 delegated_frame_host_->UpdateBackgroundColor(color); 800 delegated_frame_host_->UpdateBackgroundColor(color);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 } 934 }
925 935
926 void RenderWidgetHostViewAndroid::Destroy() { 936 void RenderWidgetHostViewAndroid::Destroy() {
927 host_->ViewDestroyed(); 937 host_->ViewDestroyed();
928 SetContentViewCore(NULL); 938 SetContentViewCore(NULL);
929 delegated_frame_host_.reset(); 939 delegated_frame_host_.reset();
930 940
931 // The RenderWidgetHost's destruction led here, so don't call it. 941 // The RenderWidgetHost's destruction led here, so don't call it.
932 host_ = NULL; 942 host_ = NULL;
933 943
944 if (GetTextInputManager() && GetTextInputManager()->HasObserver(this))
945 GetTextInputManager()->RemoveObserver(this);
946
934 delete this; 947 delete this;
935 } 948 }
936 949
937 void RenderWidgetHostViewAndroid::SetTooltipText( 950 void RenderWidgetHostViewAndroid::SetTooltipText(
938 const base::string16& tooltip_text) { 951 const base::string16& tooltip_text) {
939 // Tooltips don't makes sense on Android. 952 // Tooltips don't makes sense on Android.
940 } 953 }
941 954
942 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, 955 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text,
943 size_t offset, 956 size_t offset,
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 case ui::MotionEvent::ACTION_UP: 2003 case ui::MotionEvent::ACTION_UP:
1991 case ui::MotionEvent::ACTION_POINTER_UP: 2004 case ui::MotionEvent::ACTION_POINTER_UP:
1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 2005 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
1993 delta.InMicroseconds(), 1, 1000000, 50); 2006 delta.InMicroseconds(), 1, 1000000, 50);
1994 default: 2007 default:
1995 return; 2008 return;
1996 } 2009 }
1997 } 2010 }
1998 2011
1999 } // namespace content 2012 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698