diff options
author | aurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 21:14:36 +0000 |
---|---|---|
committer | aurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-01 21:14:36 +0000 |
commit | eb0cf38179a5e427aaaf9d613fca28a105a38233 (patch) | |
tree | 6768af93f5cdce09f35468aff21eeab9a39feef3 /content | |
parent | 0a208bf4f2c0fb0ae4434567b3fe924c62568a9c (diff) | |
download | chromium_src-eb0cf38179a5e427aaaf9d613fca28a105a38233.zip chromium_src-eb0cf38179a5e427aaaf9d613fca28a105a38233.tar.gz chromium_src-eb0cf38179a5e427aaaf9d613fca28a105a38233.tar.bz2 |
Switch to sending IME selection updates early.
- Switching to send out UpdateSelection updates as soon as the change is
applied in AdapterInputConnection (instead of waiting for Blink)
- Start ignoring the IME updates from Blink if it was caused by an IME event
sent from AdapterInputConnection by checking requiredAck flag.
BUG=235704,145521
Review URL: https://codereview.chromium.org/24195023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
14 files changed, 80 insertions, 170 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index 13e52e0..606343d 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -1531,7 +1531,8 @@ void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, int selection_end, int composition_start, int composition_end, - bool show_ime_if_needed) { + bool show_ime_if_needed, + bool require_ack) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) @@ -1543,15 +1544,7 @@ void ContentViewCoreImpl::UpdateImeAdapter(int native_ime_adapter, jstring_text.obj(), selection_start, selection_end, composition_start, composition_end, - 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); + show_ime_if_needed, require_ack); } void ContentViewCoreImpl::ClearSslPreferences(JNIEnv* env, jobject obj) { diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 7409524..85d893b 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -246,8 +246,7 @@ class ContentViewCoreImpl : public ContentViewCore, const std::string& text, int selection_start, int selection_end, int composition_start, int composition_end, - bool show_ime_if_needed); - void ProcessImeBatchStateAck(bool is_begin); + bool show_ime_if_needed, bool require_ack); 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 da14d7a..68b4a9e 100644 --- a/content/browser/renderer_host/ime_adapter_android.cc +++ b/content/browser/renderer_host/ime_adapter_android.cc @@ -158,16 +158,6 @@ 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 = GetRenderWidgetHostImpl(); - if (!rwhi) - return; - - rwhi->Send(new ViewMsg_ImeBatchStateChanged(rwhi->GetRoutingID(), is_begin)); -} - void ImeAdapterAndroid::CommitText(JNIEnv* env, jobject, jstring text) { RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); if (!rwhi) diff --git a/content/browser/renderer_host/ime_adapter_android.h b/content/browser/renderer_host/ime_adapter_android.h index d55f0d5..a3e273e 100644 --- a/content/browser/renderer_host/ime_adapter_android.h +++ b/content/browser/renderer_host/ime_adapter_android.h @@ -41,7 +41,6 @@ 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 FinishComposingText(JNIEnv* env, jobject); void AttachImeAdapter(JNIEnv*, jobject java_object); 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 421d2f0..15d2cd3 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -166,8 +166,6 @@ bool RenderWidgetHostViewAndroid::OnMessageReceived( const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_ImeBatchStateChanged_ACK, - OnProcessImeBatchStateAck) IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, OnDidChangeBodyBackgroundColor) @@ -440,12 +438,7 @@ void RenderWidgetHostViewAndroid::OnTextInputStateChanged( static_cast<int>(params.type), params.value, params.selection_start, params.selection_end, params.composition_start, params.composition_end, - params.show_ime_if_needed); -} - -void RenderWidgetHostViewAndroid::OnProcessImeBatchStateAck(bool is_begin) { - if (content_view_core_) - content_view_core_->ProcessImeBatchStateAck(is_begin); + params.show_ime_if_needed, params.require_ack); } void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor( 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 9e46acb..3077045 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -212,7 +212,6 @@ class RenderWidgetHostViewAndroid void SendBeginFrame(const cc::BeginFrameArgs& args); void OnTextInputStateChanged(const ViewHostMsg_TextInputState_Params& params); - void OnProcessImeBatchStateAck(bool is_begin); void OnDidChangeBodyBackgroundColor(SkColor color); void OnStartContentIntent(const GURL& content_url); void OnSetNeedsBeginFrame(bool enabled); diff --git a/content/common/view_messages.h b/content/common/view_messages.h index ed0cf62..04d5c09 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1295,10 +1295,6 @@ IPC_MESSAGE_ROUTED2(ViewMsg_SelectPopupMenuItems, // ViewMsg_ScrollFocusedEditableNodeIntoView was called. IPC_MESSAGE_ROUTED0(ViewMsg_UndoScrollFocusedEditableNodeIntoView) -// This message relays the beginning or end of a batch event in the IME. -IPC_MESSAGE_ROUTED1(ViewMsg_ImeBatchStateChanged, - bool /* is_begin */) - // Notifies the renderer whether hiding/showing the top controls is enabled // and whether or not to animate to the proper state. IPC_MESSAGE_ROUTED3(ViewMsg_UpdateTopControlsState, @@ -2310,11 +2306,6 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_StartContentIntent, IPC_MESSAGE_ROUTED1(ViewHostMsg_DidChangeBodyBackgroundColor, uint32 /* bg_color */) -// This message is an ACK that the batch state change has been received by -// the renderer and all IME related messages should be processed accordingly. -IPC_MESSAGE_ROUTED1(ViewHostMsg_ImeBatchStateChanged_ACK, - bool /* is_begin */) - // This message runs the MediaCodec for decoding audio for webaudio. IPC_MESSAGE_CONTROL3(ViewHostMsg_RunWebAudioMediaCodec, base::SharedMemoryHandle /* encoded_data_handle */, diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index b7055b5..52e68af 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java @@ -2395,11 +2395,10 @@ import java.util.Map; getContentViewClient().onGeometryChanged(-1, null); } - @SuppressWarnings("unused") @CalledByNative private void updateImeAdapter(int nativeImeAdapterAndroid, int textInputType, String text, int selectionStart, int selectionEnd, - int compositionStart, int compositionEnd, boolean showImeIfNeeded) { + int compositionStart, int compositionEnd, boolean showImeIfNeeded, boolean requireAck) { TraceEvent.begin(); mSelectionEditable = (textInputType != ImeAdapter.getTextInputTypeNone()); @@ -2409,21 +2408,14 @@ import java.util.Map; selectionStart, selectionEnd, showImeIfNeeded); if (mInputConnection != null) { - mInputConnection.setEditableText(text, selectionStart, selectionEnd, - compositionStart, compositionEnd); + mInputConnection.updateState(text, selectionStart, selectionEnd, compositionStart, + compositionEnd, requireAck); } TraceEvent.end(); } @SuppressWarnings("unused") @CalledByNative - private void processImeBatchStateAck(boolean isBegin) { - if (mInputConnection == null) return; - mInputConnection.setIgnoreTextInputStateUpdates(isBegin); - } - - @SuppressWarnings("unused") - @CalledByNative private void setTitle(String title) { getContentViewClient().onUpdateTitle(title); } @@ -2926,6 +2918,7 @@ import java.util.Map; if (mAccessibilityScriptInjectionObserver == null) { ContentObserver contentObserver = new ContentObserver(new Handler()) { + @Override public void onChange(boolean selfChange, Uri uri) { setAccessibilityState(mAccessibilityManager.isEnabled()); } diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java index a6312c6..df39145 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java @@ -36,7 +36,6 @@ public class AdapterInputConnection extends BaseInputConnection { private boolean mSingleLine; private int mNumNestedBatchEdits = 0; - private boolean mIgnoreTextInputStateUpdates = false; private int mLastUpdateSelectionStart = INVALID_SELECTION; private int mLastUpdateSelectionEnd = INVALID_SELECTION; @@ -104,26 +103,30 @@ public class AdapterInputConnection extends BaseInputConnection { } /** - * Updates the AdapterInputConnection's internal representation of the text - * being edited and its selection and composition properties. The resulting - * Editable is accessible through the getEditable() method. - * If the text has not changed, this also calls updateSelection on the InputMethodManager. - * @param text The String contents of the field being edited - * @param selectionStart The character offset of the selection start, or the caret - * position if there is no selection - * @param selectionEnd The character offset of the selection end, or the caret - * position if there is no selection - * @param compositionStart The character offset of the composition start, or -1 - * if there is no composition - * @param compositionEnd The character offset of the composition end, or -1 - * if there is no selection + * Updates the AdapterInputConnection's internal representation of the text being edited and + * its selection and composition properties. The resulting Editable is accessible through the + * getEditable() method. If the text has not changed, this also calls updateSelection on the + * InputMethodManager. + * + * @param text The String contents of the field being edited. + * @param selectionStart The character offset of the selection start, or the caret position if + * there is no selection. + * @param selectionEnd The character offset of the selection end, or the caret position if there + * is no selection. + * @param compositionStart The character offset of the composition start, or -1 if there is no + * composition. + * @param compositionEnd The character offset of the composition end, or -1 if there is no + * selection. + * @param requireAck True when the update was not caused by IME, false otherwise. */ - public void setEditableText(String text, int selectionStart, int selectionEnd, - int compositionStart, int compositionEnd) { + public void updateState(String text, int selectionStart, int selectionEnd, int compositionStart, + int compositionEnd, boolean requireAck) { if (DEBUG) { - Log.w(TAG, "setEditableText [" + text + "] [" + selectionStart + " " + selectionEnd - + "] [" + compositionStart + " " + compositionEnd + "]"); + Log.w(TAG, "updateState [" + text + "] [" + selectionStart + " " + selectionEnd + "] [" + + compositionStart + " " + compositionEnd + "] [" + requireAck + "]"); } + if (!requireAck) return; + // Non-breaking spaces can cause the IME to get confused. Replace with normal spaces. text = text.replace('\u00A0', ' '); @@ -140,19 +143,6 @@ public class AdapterInputConnection extends BaseInputConnection { editable.replace(0, editable.length(), text); } - int prevSelectionStart = Selection.getSelectionStart(editable); - int prevSelectionEnd = Selection.getSelectionEnd(editable); - int prevCompositionStart = getComposingSpanStart(editable); - int prevCompositionEnd = getComposingSpanEnd(editable); - - if (prevSelectionStart == selectionStart && prevSelectionEnd == selectionEnd - && prevCompositionStart == compositionStart - && prevCompositionEnd == compositionEnd) { - if (mIgnoreTextInputStateUpdates) return; - updateSelection(selectionStart, selectionEnd, compositionStart, compositionEnd); - return; - } - Selection.setSelection(editable, selectionStart, selectionEnd); if (compositionStart == compositionEnd) { @@ -160,14 +150,20 @@ public class AdapterInputConnection extends BaseInputConnection { } else { super.setComposingRegion(compositionStart, compositionEnd); } - - if (mIgnoreTextInputStateUpdates) return; - updateSelection(selectionStart, selectionEnd, compositionStart, compositionEnd); + updateSelectionIfRequired(); } - @VisibleForTesting - protected void updateSelection(int selectionStart, int selectionEnd, int compositionStart, - int compositionEnd) { + /** + * Sends selection update to the InputMethodManager unless we are currently in a batch edit or + * if the exact same selection and composition update was sent already. + */ + private void updateSelectionIfRequired() { + if (mNumNestedBatchEdits != 0) return; + Editable editable = getEditable(); + int selectionStart = Selection.getSelectionStart(editable); + int selectionEnd = Selection.getSelectionEnd(editable); + int compositionStart = getComposingSpanStart(editable); + int compositionEnd = getComposingSpanEnd(editable); // Avoid sending update if we sent an exact update already previously. if (mLastUpdateSelectionStart == selectionStart && mLastUpdateSelectionEnd == selectionEnd && @@ -176,7 +172,7 @@ public class AdapterInputConnection extends BaseInputConnection { return; } if (DEBUG) { - Log.w(TAG, "updateSelection [" + selectionStart + " " + selectionEnd + "] [" + Log.w(TAG, "updateSelectionIfRequired [" + selectionStart + " " + selectionEnd + "] [" + compositionStart + " " + compositionEnd + "]"); } // updateSelection should be called every time the selection or composition changes @@ -196,6 +192,7 @@ public class AdapterInputConnection extends BaseInputConnection { public boolean setComposingText(CharSequence text, int newCursorPosition) { if (DEBUG) Log.w(TAG, "setComposingText [" + text + "] [" + newCursorPosition + "]"); super.setComposingText(text, newCursorPosition); + updateSelectionIfRequired(); return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(), newCursorPosition, false); } @@ -207,6 +204,7 @@ public class AdapterInputConnection extends BaseInputConnection { public boolean commitText(CharSequence text, int newCursorPosition) { if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition + "]"); super.commitText(text, newCursorPosition); + updateSelectionIfRequired(); return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(), newCursorPosition, text.length() > 0); } @@ -274,10 +272,8 @@ public class AdapterInputConnection extends BaseInputConnection { @Override public boolean beginBatchEdit() { if (DEBUG) Log.w(TAG, "beginBatchEdit [" + (mNumNestedBatchEdits == 0) + "]"); - if (mNumNestedBatchEdits == 0) mImeAdapter.batchStateChanged(true); - mNumNestedBatchEdits++; - return false; + return true; } /** @@ -286,11 +282,10 @@ public class AdapterInputConnection extends BaseInputConnection { @Override public boolean endBatchEdit() { if (mNumNestedBatchEdits == 0) return false; - --mNumNestedBatchEdits; if (DEBUG) Log.w(TAG, "endBatchEdit [" + (mNumNestedBatchEdits == 0) + "]"); - if (mNumNestedBatchEdits == 0) mImeAdapter.batchStateChanged(false); - return false; + if (mNumNestedBatchEdits == 0) updateSelectionIfRequired(); + return mNumNestedBatchEdits != 0; } /** @@ -307,6 +302,7 @@ public class AdapterInputConnection extends BaseInputConnection { beforeLength = Math.min(beforeLength, availableBefore); afterLength = Math.min(afterLength, availableAfter); super.deleteSurroundingText(beforeLength, afterLength); + updateSelectionIfRequired(); return mImeAdapter.deleteSurroundingText(beforeLength, afterLength); } @@ -373,6 +369,7 @@ public class AdapterInputConnection extends BaseInputConnection { } super.finishComposingText(); + updateSelectionIfRequired(); mImeAdapter.finishComposingText(); return true; @@ -387,6 +384,7 @@ public class AdapterInputConnection extends BaseInputConnection { int textLength = getEditable().length(); if (start < 0 || end < 0 || start > textLength || end > textLength) return true; super.setSelection(start, end); + updateSelectionIfRequired(); return mImeAdapter.setEditableSelectionOffsets(start, end); } @@ -397,7 +395,6 @@ public class AdapterInputConnection extends BaseInputConnection { void restartInput() { if (DEBUG) Log.w(TAG, "restartInput"); getInputMethodManagerWrapper().restartInput(mInternalView); - mIgnoreTextInputStateUpdates = false; mNumNestedBatchEdits = 0; } @@ -420,6 +417,7 @@ public class AdapterInputConnection extends BaseInputConnection { } else { super.setComposingRegion(a, b); } + updateSelectionIfRequired(); return mImeAdapter.setComposingRegion(a, b); } @@ -427,22 +425,6 @@ public class AdapterInputConnection extends BaseInputConnection { return getInputMethodManagerWrapper().isActive(mInternalView); } - public void setIgnoreTextInputStateUpdates(boolean shouldIgnore) { - mIgnoreTextInputStateUpdates = shouldIgnore; - if (shouldIgnore) return; - - Editable editable = getEditable(); - updateSelection(Selection.getSelectionStart(editable), - Selection.getSelectionEnd(editable), - getComposingSpanStart(editable), - getComposingSpanEnd(editable)); - } - - @VisibleForTesting - protected boolean isIgnoringTextInputStateUpdates() { - return mIgnoreTextInputStateUpdates; - } - private InputMethodManagerWrapper getInputMethodManagerWrapper() { return mImeAdapter.getInputMethodManagerWrapper(); } diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java index 2d5d97d..23ee159 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java @@ -412,11 +412,6 @@ public class ImeAdapter { return true; } - void batchStateChanged(boolean isBegin) { - if (mNativeImeAdapterAndroid == 0) return; - nativeImeBatchStateChanged(mNativeImeAdapterAndroid, isBegin); - } - void commitText() { cancelComposition(); if (mNativeImeAdapterAndroid != 0) { @@ -559,8 +554,6 @@ public class ImeAdapter { private native void nativeDeleteSurroundingText(int nativeImeAdapterAndroid, int before, int after); - private native void nativeImeBatchStateChanged(int nativeImeAdapterAndroid, boolean isBegin); - private native void nativeUnselect(int nativeImeAdapterAndroid); private native void nativeSelectAll(int nativeImeAdapterAndroid); private native void nativeCut(int nativeImeAdapterAndroid); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java index 69be5f86..9dcce92 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java @@ -44,25 +44,40 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { public void testSetComposingText() throws Throwable { mConnection.setComposingText("t", 1); assertCorrectState("t", 1, 1, 0, 1, mConnection.getImeStateForTesting()); - mConnection.setEditableText("t", 1, 1, 0, 1); mWrapper.verifyUpdateSelectionCall(0, 1, 1, 0 ,1); mConnection.setComposingText("te", 1); assertCorrectState("te", 2, 2, 0, 2, mConnection.getImeStateForTesting()); - mConnection.setEditableText("te", 2, 2, 0, 2); mWrapper.verifyUpdateSelectionCall(1, 2, 2, 0 ,2); mConnection.setComposingText("tes", 1); assertCorrectState("tes", 3, 3, 0, 3, mConnection.getImeStateForTesting()); - mConnection.setEditableText("tes", 3, 3, 0, 3); mWrapper.verifyUpdateSelectionCall(2, 3, 3, 0, 3); mConnection.setComposingText("test", 1); assertCorrectState("test", 4, 4, 0, 4, mConnection.getImeStateForTesting()); - mConnection.setEditableText("test", 4, 4, 0, 4); mWrapper.verifyUpdateSelectionCall(3, 4, 4, 0, 4); } + @MediumTest + @Feature({"TextInput", "Main"}) + public void testSelectionUpdatesDuringBatch() throws Throwable { + mConnection.beginBatchEdit(); + mConnection.setComposingText("t", 1); + assertEquals(0, mWrapper.getUpdateSelectionCallCount()); + mConnection.setComposingText("te", 1); + assertEquals(0, mWrapper.getUpdateSelectionCallCount()); + mConnection.beginBatchEdit(); + mConnection.setComposingText("tes", 1); + assertEquals(0, mWrapper.getUpdateSelectionCallCount()); + mConnection.endBatchEdit(); + mConnection.setComposingText("test", 1); + assertEquals(0, mWrapper.getUpdateSelectionCallCount()); + mConnection.endBatchEdit(); + assertEquals(1, mWrapper.getUpdateSelectionCallCount()); + mWrapper.verifyUpdateSelectionCall(0, 4, 4, 0 ,4); + } + private static class TestImeAdapter extends ImeAdapter { public TestImeAdapter(InputMethodManagerWrapper wrapper, ImeAdapterDelegate embedder) { super(wrapper, embedder); @@ -99,6 +114,10 @@ public class AdapterInputConnectionTest extends ContentShellTestBase { mUpdates.add(new ImeState("", selStart, selEnd, candidatesStart, candidatesEnd)); } + public int getUpdateSelectionCallCount() { + return mUpdates.size(); + } + public void verifyUpdateSelectionCall(int index, int selectionStart, int selectionEnd, int compositionStart, int compositionEnd) { ImeState state = mUpdates.get(index); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java index c446207..dd124b9 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java @@ -196,31 +196,6 @@ public class ImeTest extends ContentShellTestBase { @SmallTest @Feature({"TextInput", "Main"}) - public void testUpdatesGetIgnoredDuringBatchEdits() throws Throwable { - mConnection.beginBatchEdit(); - assertWaitForSetIgnoreUpdates(true, mConnection); - - mConnection.setComposingText("h", 1); - waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "h", 1, 1, 0, 1); - assertTrue(mConnection.isIgnoringTextInputStateUpdates()); - assertEquals(0, mInputMethodManagerWrapper.getUpdateSelectionCounter()); - - mConnection.setComposingText("he", 1); - waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "he", 2, 2, 0, 2); - assertTrue(mConnection.isIgnoringTextInputStateUpdates()); - assertEquals(0, mInputMethodManagerWrapper.getUpdateSelectionCounter()); - - mConnection.setComposingText("hel", 1); - waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hel", 3, 3, 0, 3); - - assertEquals(0, mInputMethodManagerWrapper.getUpdateSelectionCounter()); - assertTrue(mConnection.isIgnoringTextInputStateUpdates()); - mConnection.endBatchEdit(); - assertWaitForSetIgnoreUpdates(false, mConnection); - } - - @SmallTest - @Feature({"TextInput", "Main"}) public void testShowImeIfNeeded() throws Throwable { DOMUtils.focusNode(this, mContentView, mCallbackContainer, "input_radio"); assertWaitForKeyboardStatus(false); @@ -365,16 +340,6 @@ public class ImeTest extends ContentShellTestBase { })); } - private void assertWaitForSetIgnoreUpdates(final boolean ignore, - final TestAdapterInputConnection connection) throws Throwable { - assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { - @Override - public boolean isSatisfied() { - return ignore == connection.isIgnoringTextInputStateUpdates(); - } - })); - } - private ImeAdapter getImeAdapter() { return getContentViewCore().getImeAdapterForTest(); } @@ -393,19 +358,19 @@ public class ImeTest extends ContentShellTestBase { } private static class TestAdapterInputConnection extends AdapterInputConnection { - private ArrayList<TestImeState> mImeUpdateQueue = new ArrayList<ImeTest.TestImeState>(); + private final ArrayList<TestImeState> mImeUpdateQueue = new ArrayList<TestImeState>(); public TestAdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) { super(view, imeAdapter, outAttrs); } @Override - public void setEditableText(String text, int selectionStart, int selectionEnd, - int compositionStart, int compositionEnd) { + public void updateState(String text, int selectionStart, int selectionEnd, + int compositionStart, int compositionEnd, boolean requiredAck) { mImeUpdateQueue.add(new TestImeState(text, selectionStart, selectionEnd, compositionStart, compositionEnd)); - super.setEditableText( - text, selectionStart, selectionEnd, compositionStart, compositionEnd); + super.updateState(text, selectionStart, selectionEnd, compositionStart, + compositionEnd, requiredAck); } } diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 95a403b..abb144d 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -399,7 +399,6 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) #if defined(OS_ANDROID) - IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged) IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) #endif @@ -2039,10 +2038,6 @@ void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, } #if defined(OS_ANDROID) -void RenderWidget::OnImeBatchStateChanged(bool is_begin) { - Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin)); -} - void RenderWidget::OnShowImeIfNeeded() { UpdateTextInputState(true, true); } diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index d439347..0d606f8 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -330,7 +330,6 @@ class CONTENT_EXPORT RenderWidget void OnUpdateScreenRects(const gfx::Rect& view_screen_rect, const gfx::Rect& window_screen_rect); #if defined(OS_ANDROID) - void OnImeBatchStateChanged(bool is_begin); void OnShowImeIfNeeded(); // Whenever an IME event that needs an acknowledgement is sent to the browser, |