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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2354793003: Browser Side TextInputState Tracking for Android (Closed)
Patch Set: Addressing kenrb@'s comments 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index d23f88aab5afd5fdc02799d8e395bac3895bc024..ef22caf773728baf478a9274d95d0f9442d34185 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -466,6 +466,9 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
host_->SetView(this);
SetContentViewCore(content_view_core);
+
+ if (GetTextInputManager())
+ GetTextInputManager()->AddObserver(this);
}
RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
@@ -761,23 +764,28 @@ long RenderWidgetHostViewAndroid::GetNativeImeAdapter() {
return reinterpret_cast<intptr_t>(&ime_adapter_android_);
}
-void RenderWidgetHostViewAndroid::TextInputStateChanged(
- const TextInputState& params) {
- if (params.is_non_ime_change) {
+// -----------------------------------------------------------------------------
+// TextInputManager::Observer implementations.
+void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled(
+ 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.
+ RenderWidgetHostViewBase* updated_view,
+ bool did_change_state) {
+ const TextInputState& state =
+ *GetTextInputManager()->GetTextInputState(updated_view);
+ if (state.is_non_ime_change && updated_view->GetRenderWidgetHost()) {
// Sends an acknowledgement to the renderer of a processed IME event.
- host_->Send(new InputMsg_ImeEventAck(host_->GetRoutingID()));
+ updated_view->GetRenderWidgetHost()->Send(
+ new InputMsg_ImeEventAck(host_->GetRoutingID()));
}
if (!content_view_core_)
return;
content_view_core_->UpdateImeAdapter(
- GetNativeImeAdapter(),
- static_cast<int>(params.type), params.flags,
- params.value, params.selection_start, params.selection_end,
- params.composition_start, params.composition_end,
- params.show_ime_if_needed, params.is_non_ime_change,
- params.batch_edit);
+ GetNativeImeAdapter(), static_cast<int>(state.type), state.flags,
+ state.value, state.selection_start, state.selection_end,
+ state.composition_start, state.composition_end, state.show_ime_if_needed,
+ state.is_non_ime_change, state.batch_edit);
}
void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) {
@@ -931,6 +939,9 @@ void RenderWidgetHostViewAndroid::Destroy() {
// The RenderWidgetHost's destruction led here, so don't call it.
host_ = NULL;
+ if (GetTextInputManager() && GetTextInputManager()->HasObserver(this))
+ GetTextInputManager()->RemoveObserver(this);
+
delete this;
}

Powered by Google App Engine
This is Rietveld 408576698