Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java

Issue 11637024: Cleaning up ImeAdapter.java (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 949b1f3199cebed21d1e64371799bed6f80036e6..9614b54f60d13848ce890824a5a42e98ae6bf96c 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
@@ -496,7 +496,6 @@ class ImeAdapter {
static public class AdapterInputConnection extends BaseInputConnection {
private View mInternalView;
private ImeAdapter mImeAdapter;
- private Editable mEditable;
private boolean mSingleLine;
// Factory function.
@@ -523,16 +522,14 @@ class ImeAdapter {
public void setEditableText(String text, int selectionStart, int selectionEnd,
int compositionStart, int compositionEnd) {
- if (mEditable == null) {
- mEditable = Editable.Factory.getInstance().newEditable("");
- }
+ Editable editable = getEditable();
- int prevSelectionStart = Selection.getSelectionStart(mEditable);
- int prevSelectionEnd = Selection.getSelectionEnd(mEditable);
- int prevEditableLength = mEditable.length();
- int prevCompositionStart = getComposingSpanStart(mEditable);
- int prevCompositionEnd = getComposingSpanEnd(mEditable);
- String prevText = mEditable.toString();
+ int prevSelectionStart = Selection.getSelectionStart(editable);
+ int prevSelectionEnd = Selection.getSelectionEnd(editable);
+ int prevEditableLength = editable.length();
+ int prevCompositionStart = getComposingSpanStart(editable);
+ int prevCompositionEnd = getComposingSpanEnd(editable);
+ String prevText = editable.toString();
selectionStart = Math.min(selectionStart, text.length());
selectionEnd = Math.min(selectionEnd, text.length());
@@ -557,9 +554,9 @@ class ImeAdapter {
}
if (!textUnchanged) {
- mEditable.replace(0, mEditable.length(), text);
+ editable.replace(0, editable.length(), text);
}
- Selection.setSelection(mEditable, selectionStart, selectionEnd);
+ Selection.setSelection(editable, selectionStart, selectionEnd);
super.setComposingRegion(compositionStart, compositionEnd);
if (textUnchanged || prevText.equals("")) {
@@ -572,15 +569,6 @@ class ImeAdapter {
}
@Override
- public Editable getEditable() {
- if (mEditable == null) {
- mEditable = Editable.Factory.getInstance().newEditable("");
- Selection.setSelection(mEditable, 0);
- }
- return mEditable;
- }
-
- @Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
super.setComposingText(text, newCursorPosition);
return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(),
@@ -632,14 +620,11 @@ class ImeAdapter {
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
ExtractedText et = new ExtractedText();
- if (mEditable == null) {
- et.text = "";
- } else {
- et.text = mEditable.toString();
- et.partialEndOffset = mEditable.length();
- et.selectionStart = Selection.getSelectionStart(mEditable);
- et.selectionEnd = Selection.getSelectionEnd(mEditable);
- }
+ Editable editable = getEditable();
+ et.text = editable.toString();
+ et.partialEndOffset = editable.length();
+ et.selectionStart = Selection.getSelectionStart(editable);
+ et.selectionEnd = Selection.getSelectionEnd(editable);
et.flags = mSingleLine ? ExtractedText.FLAG_SINGLE_LINE : 0;
return et;
}
@@ -686,8 +671,8 @@ class ImeAdapter {
@Override
public boolean finishComposingText() {
- if (mEditable == null
- || (getComposingSpanStart(mEditable) == getComposingSpanEnd(mEditable))) {
+ Editable editable = getEditable();
+ if (getComposingSpanStart(editable) == getComposingSpanEnd(editable)) {
return true;
}
super.finishComposingText();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698