diff options
author | yusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 03:46:21 +0000 |
---|---|---|
committer | yusufo@chromium.org <yusufo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 03:46:21 +0000 |
commit | 105dffb48c7035e19144347625e796cc7f9d8fe1 (patch) | |
tree | b836ab13a56eb50e79786208961a78ecd6dd477e /content/browser | |
parent | 52d21b5f018328b67b737febb9566bfc516883f3 (diff) | |
download | chromium_src-105dffb48c7035e19144347625e796cc7f9d8fe1.zip chromium_src-105dffb48c7035e19144347625e796cc7f9d8fe1.tar.gz chromium_src-105dffb48c7035e19144347625e796cc7f9d8fe1.tar.bz2 |
Ignore textInputState updates during a batch edit
According to the Android spec, when the Ime is in a batchEdit we should not
be calling updateSelection which we currently do through the setEditableText call.
This calls gets triggered by updateTextInputState calls coming from the
render_widget. This patch adds one browser->renderer and one renderer-> browser
IPC so that the Java IME adapter can distinguish between updates coming during a
batch edit and ignore them properly.
BUG=172845
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12262026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
9 files changed, 48 insertions, 0 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index 4f85a37..124f34a 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -1345,6 +1345,14 @@ void ContentViewCoreImpl::ImeUpdateAdapter(int native_ime_adapter, show_ime_if_needed); } +void ContentViewCoreImpl::ProcessImeBatchStateAck(bool is_begin) { + JNIEnv* env = AttachCurrentThread(); + ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); + if (obj.is_null()) + return; + Java_ContentViewCore_processImeBatchStateAck(env, obj.obj(), is_begin); +} + void ContentViewCoreImpl::ClearSslPreferences(JNIEnv* env, jobject obj) { SSLHostState* state = SSLHostState::GetFor( web_contents_->GetController().GetBrowserContext()); diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 76e67eb..91b35ea 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -239,6 +239,7 @@ class ContentViewCoreImpl : public ContentViewCore, int selection_start, int selection_end, int composition_start, int composition_end, bool show_ime_if_needed); + void ProcessImeBatchStateAck(bool is_begin); void SetTitle(const string16& title); void OnBackgroundColorChanged(SkColor color); diff --git a/content/browser/renderer_host/ime_adapter_android.cc b/content/browser/renderer_host/ime_adapter_android.cc index ee622bd..c5c4ad8 100644 --- a/content/browser/renderer_host/ime_adapter_android.cc +++ b/content/browser/renderer_host/ime_adapter_android.cc @@ -153,6 +153,16 @@ void ImeAdapterAndroid::SetComposingText(JNIEnv* env, jobject, jstring text, rwhi->ImeSetComposition(text16, underlines, new_cursor_pos, new_cursor_pos); } +void ImeAdapterAndroid::ImeBatchStateChanged(JNIEnv* env, + jobject, + jboolean is_begin) { + RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( + rwhva_->GetRenderWidgetHost()); + if (!rwhi) + return; + + rwhi->Send(new ViewMsg_ImeBatchStateChanged(rwhi->GetRoutingID(), is_begin)); +} void ImeAdapterAndroid::CommitText(JNIEnv* env, jobject, jstring text) { RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( diff --git a/content/browser/renderer_host/ime_adapter_android.h b/content/browser/renderer_host/ime_adapter_android.h index 5932189..a2cd2ec 100644 --- a/content/browser/renderer_host/ime_adapter_android.h +++ b/content/browser/renderer_host/ime_adapter_android.h @@ -36,6 +36,7 @@ class ImeAdapterAndroid { int native_key_code, int unicode_char); void SetComposingText(JNIEnv*, jobject, jstring text, int new_cursor_pos); + void ImeBatchStateChanged(JNIEnv*, jobject, jboolean is_begin); void CommitText(JNIEnv*, jobject, jstring text); void AttachImeAdapter(JNIEnv*, jobject java_object); void SetEditableSelectionOffsets(JNIEnv*, jobject, int start, int end); diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index e81f0f3..8090dd8 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -424,6 +424,9 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() + if (!handled && view_ && view_->OnMessageReceived(msg)) + return true; + if (!msg_is_ok) { // The message de-serialization failed. Kill the renderer process. RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); 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 c1bafe7..d697fef 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -67,6 +67,18 @@ RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { } } + +bool RenderWidgetHostViewAndroid::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_ImeBatchStateChanged_ACK, + ProcessImeBatchStateAck) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) { NOTIMPLEMENTED(); } @@ -287,6 +299,11 @@ int RenderWidgetHostViewAndroid::GetNativeImeAdapter() { return reinterpret_cast<int>(&ime_adapter_android_); } +void RenderWidgetHostViewAndroid::ProcessImeBatchStateAck(bool is_begin) { + if (content_view_core_) + content_view_core_->ProcessImeBatchStateAck(is_begin); +} + void RenderWidgetHostViewAndroid::ImeCancelComposition() { ime_adapter_android_.CancelComposition(); } diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 8486fb6..c7a0135 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -51,6 +51,7 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase { virtual ~RenderWidgetHostViewAndroid(); // RenderWidgetHostView implementation. + virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) OVERRIDE; @@ -158,6 +159,8 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase { void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event); void SendGestureEvent(const WebKit::WebGestureEvent& event); + void ProcessImeBatchStateAck(bool is_begin); + int GetNativeImeAdapter(); WebKit::WebGLId GetScaledContentTexture(float scale, gfx::Size* out_size); diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index e44a86b..a2cb5a4 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc @@ -353,6 +353,10 @@ RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { DCHECK(!mouse_locked_); } +bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ + return false; +} + void RenderWidgetHostViewBase::SetBackground(const SkBitmap& background) { background_ = background; } diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index d928a7b..fc509e2 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -45,6 +45,7 @@ class CONTENT_EXPORT RenderWidgetHostViewBase virtual ~RenderWidgetHostViewBase(); // RenderWidgetHostViewPort implementation. + virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; virtual void SelectionChanged(const string16& text, size_t offset, const ui::Range& range) OVERRIDE; |