Index: content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java |
index e5ddc2987ac770e604509d1ebe563f20667b9fd5..836f71aebbffe5341b8a038ae5b59b87674b1cd3 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java |
@@ -280,7 +280,7 @@ class ImeAdapter { |
} |
} |
- private boolean checkCompositionQueueAndCallNative(String text, int newCursorPosition, |
+ boolean checkCompositionQueueAndCallNative(String text, int newCursorPosition, |
boolean isCommit) { |
if (mNativeImeAdapterAndroid == 0) { |
return false; |
@@ -461,20 +461,21 @@ class ImeAdapter { |
return true; |
} |
+ public static class AdapterInputConnectionFactory { |
+ public AdapterInputConnection get(View view, ImeAdapter imeAdapter, |
+ EditorInfo outAttrs) { |
+ return new AdapterInputConnection(view, imeAdapter, outAttrs); |
+ } |
+ } |
+ |
// This InputConnection is created by ContentView.onCreateInputConnection. |
// It then adapts android's IME to chrome's RenderWidgetHostView using the |
// native ImeAdapterAndroid via the outer class ImeAdapter. |
- static public class AdapterInputConnection extends BaseInputConnection { |
+ public static class AdapterInputConnection extends BaseInputConnection { |
private View mInternalView; |
private ImeAdapter mImeAdapter; |
private boolean mSingleLine; |
- // Factory function. |
- static public AdapterInputConnection getInstance(View view, ImeAdapter imeAdapter, |
- EditorInfo outAttrs) { |
- return new AdapterInputConnection(view, imeAdapter, outAttrs); |
- } |
- |
/** |
* Updates the AdapterInputConnection's internal representation of the text |
* being edited and its selection and composition properties. The resulting |
@@ -530,13 +531,6 @@ class ImeAdapter { |
getInputMethodManager().updateSelection(mInternalView, |
selectionStart, selectionEnd, compositionStart, compositionEnd); |
} |
- |
- // When WebKit changes the editable field, both the start and the end positions for |
- // the composition will be set to -1. In this case we have to call restart input |
- // for the IME to update its state. |
- if (textUnchanged && compositionStart == -1 && compositionEnd == -1) { |
- restartInput(); |
- } |
} |
@Override |
@@ -685,7 +679,7 @@ class ImeAdapter { |
.getSystemService(Context.INPUT_METHOD_SERVICE); |
} |
- private AdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) { |
+ protected AdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) { |
super(view, true); |
mInternalView = view; |
mImeAdapter = imeAdapter; |
@@ -735,6 +729,16 @@ class ImeAdapter { |
| InputType.TYPE_NUMBER_VARIATION_NORMAL; |
outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; |
} |
+ |
+ Editable editable = getEditable(); |
+ int selectionStart = Selection.getSelectionStart(editable); |
+ int selectionEnd = Selection.getSelectionEnd(editable); |
+ if (selectionStart < 0 || selectionEnd < 0) { |
+ selectionStart = editable.length(); |
+ selectionEnd = selectionStart; |
+ } |
+ outAttrs.initialSelStart = selectionStart; |
+ outAttrs.initialSelEnd = selectionEnd; |
} |
} |