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..aafac117803054f3a9061e341ec7a070ab4e33d3 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,6 +461,13 @@ class ImeAdapter { |
return true; |
} |
+ static public class AdapterInputConnectionFactory { |
Ted C
2013/02/06 00:59:00
public should come before static...sadly this whol
aurimas (slooooooooow)
2013/02/06 02:25:44
Done.
|
+ 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. |
@@ -469,12 +476,6 @@ class ImeAdapter { |
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 |
Ted C
2013/02/06 00:59:00
Is this comment applicable for the moved block bel
aurimas (slooooooooow)
2013/02/06 02:25:44
This is no longer relevant after https://chromiumc
|
- // 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; |
} |
} |