Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java |
| 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 de9f9cce77fdea84ce6f403d65421ea9443a6b78..71fcd01e42e344ff11d23d163cfc85aa44de2432 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 |
| @@ -8,7 +8,6 @@ import android.os.SystemClock; |
| import android.text.Editable; |
| import android.text.InputType; |
| import android.text.Selection; |
| -import android.text.TextUtils; |
| import android.util.Log; |
| import android.view.KeyEvent; |
| import android.view.View; |
| @@ -46,6 +45,9 @@ public class AdapterInputConnection extends BaseInputConnection { |
| private int mLastUpdateCompositionEnd = INVALID_COMPOSITION; |
| @VisibleForTesting |
| + public int mUpdateStateCalls = 0; |
| + |
| + @VisibleForTesting |
| AdapterInputConnection(View view, ImeAdapter imeAdapter, Editable editable, |
| EditorInfo outAttrs) { |
| super(view, true); |
| @@ -139,6 +141,8 @@ public class AdapterInputConnection extends BaseInputConnection { |
| Log.w(TAG, "updateState [" + text + "] [" + selectionStart + " " + selectionEnd + "] [" |
| + compositionStart + " " + compositionEnd + "] [" + isNonImeChange + "]"); |
| } |
| + mUpdateStateCalls++; |
|
aurimas (slooooooooow)
2014/07/21 20:35:54
mUpdateStateCalls does not seem to be used. It if
bcwhite
2014/07/21 20:46:07
Done.
|
| + |
| // If this update is from the IME, no further state modification is necessary because the |
| // state should have been updated already by the IM framework directly. |
| if (!isNonImeChange) return; |
| @@ -213,7 +217,6 @@ public class AdapterInputConnection extends BaseInputConnection { |
| @Override |
| public boolean setComposingText(CharSequence text, int newCursorPosition) { |
| if (DEBUG) Log.w(TAG, "setComposingText [" + text + "] [" + newCursorPosition + "]"); |
| - if (maybePerformEmptyCompositionWorkaround(text)) return true; |
| super.setComposingText(text, newCursorPosition); |
| updateSelectionIfRequired(); |
| return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPosition, false); |
| @@ -225,7 +228,6 @@ public class AdapterInputConnection extends BaseInputConnection { |
| @Override |
| public boolean commitText(CharSequence text, int newCursorPosition) { |
| if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition + "]"); |
| - if (maybePerformEmptyCompositionWorkaround(text)) return true; |
| super.commitText(text, newCursorPosition); |
| updateSelectionIfRequired(); |
| return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPosition, |
| @@ -460,7 +462,12 @@ public class AdapterInputConnection extends BaseInputConnection { |
| super.setComposingRegion(a, b); |
| } |
| updateSelectionIfRequired(); |
| - return mImeAdapter.setComposingRegion(a, b); |
| + |
| + CharSequence regionText = null; |
| + if (b > a) { |
| + regionText = mEditable.subSequence(start, end); |
| + } |
| + return mImeAdapter.setComposingRegion(regionText, a, b); |
| } |
| boolean isActive() { |
| @@ -471,33 +478,6 @@ public class AdapterInputConnection extends BaseInputConnection { |
| return mImeAdapter.getInputMethodManagerWrapper(); |
| } |
| - /** |
| - * This method works around the issue crbug.com/373934 where Blink does not cancel |
| - * the composition when we send a commit with the empty text. |
| - * |
| - * TODO(aurimas) Remove this once crbug.com/373934 is fixed. |
| - * |
| - * @param text Text that software keyboard requested to commit. |
| - * @return Whether the workaround was performed. |
| - */ |
| - private boolean maybePerformEmptyCompositionWorkaround(CharSequence text) { |
|
aurimas (slooooooooow)
2014/07/21 20:21:57
Can we remove this workaround already? Does it wor
bcwhite
2014/07/21 20:27:18
Possibly, but I don't want to do that as part of t
aurimas (slooooooooow)
2014/07/21 20:35:54
Can you undo the removal of this call then?
|
| - int selectionStart = Selection.getSelectionStart(mEditable); |
| - int selectionEnd = Selection.getSelectionEnd(mEditable); |
| - int compositionStart = getComposingSpanStart(mEditable); |
| - int compositionEnd = getComposingSpanEnd(mEditable); |
| - if (TextUtils.isEmpty(text) && (selectionStart == selectionEnd) |
| - && compositionStart != INVALID_COMPOSITION |
| - && compositionEnd != INVALID_COMPOSITION) { |
| - beginBatchEdit(); |
| - finishComposingText(); |
| - int selection = Selection.getSelectionStart(mEditable); |
| - deleteSurroundingText(selection - compositionStart, selection - compositionEnd); |
| - endBatchEdit(); |
| - return true; |
| - } |
| - return false; |
| - } |
| - |
| @VisibleForTesting |
| static class ImeState { |
| public final String text; |