summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-04-14 12:10:58 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-04-14 12:10:58 -0700
commit7ba155bf5a06faa577df34d0bc38b1e8223fdf31 (patch)
treefdeb679dc6fbc88dfd3e4fdb976f20c456ebc38d /core
parentd2688cb1defcc8bfbb2af648358e604cbacf820b (diff)
parent876a5dfe3b4a7e0b7bba6b6227a2db2038f29976 (diff)
downloadframeworks_base-7ba155bf5a06faa577df34d0bc38b1e8223fdf31.zip
frameworks_base-7ba155bf5a06faa577df34d0bc38b1e8223fdf31.tar.gz
frameworks_base-7ba155bf5a06faa577df34d0bc38b1e8223fdf31.tar.bz2
am 876a5dfe: am b2212464: Merge "Ensure the selection does not change in setTextAndKeepSelection." into froyo
Merge commit '876a5dfe3b4a7e0b7bba6b6227a2db2038f29976' into kraken * commit '876a5dfe3b4a7e0b7bba6b6227a2db2038f29976': Ensure the selection does not change in setTextAndKeepSelection.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/WebTextView.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index 870f512..dc952e6 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -343,6 +343,7 @@ import java.util.ArrayList;
@Override
protected void onSelectionChanged(int selStart, int selEnd) {
+ if (mInSetTextAndKeepSelection) return;
// This code is copied from TextView.onDraw(). That code does not get
// executed, however, because the WebTextView does not draw, allowing
// webkit's drawing to show through.
@@ -799,8 +800,14 @@ import java.util.ArrayList;
/* package */ void setTextAndKeepSelection(String text) {
mPreChange = text.toString();
Editable edit = (Editable) getText();
+ int selStart = Selection.getSelectionStart(edit);
+ int selEnd = Selection.getSelectionEnd(edit);
mInSetTextAndKeepSelection = true;
edit.replace(0, edit.length(), text);
+ int newLength = edit.length();
+ if (selStart > newLength) selStart = newLength;
+ if (selEnd > newLength) selEnd = newLength;
+ Selection.setSelection(edit, selStart, selEnd);
mInSetTextAndKeepSelection = false;
updateCachedTextfield();
}