summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/WebTextView.java
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-09-30 10:24:19 -0400
committerCary Clark <cary@android.com>2009-09-30 10:52:14 -0400
commit0c5924e9dd1befadae8c73505d3acc9813bf8224 (patch)
treea5d9bdd2ec1b503b7c52c9603445e708a30bb183 /core/java/android/webkit/WebTextView.java
parentb386a86c1c131832c8f9955a5a57a2fa13609d15 (diff)
downloadframeworks_base-0c5924e9dd1befadae8c73505d3acc9813bf8224.zip
frameworks_base-0c5924e9dd1befadae8c73505d3acc9813bf8224.tar.gz
frameworks_base-0c5924e9dd1befadae8c73505d3acc9813bf8224.tar.bz2
preserve webkit-side text selection
When webkit modifies a text field programmatically, it may change the selection. This competes with the UI thread attempting to set the selection in response to the IME next button and changes made by the trackball. One recent fix (https://android-git.corp.google.com/g/#change,26904) sets the selection from the UI side after the IME generated click. Unfortunately, this can be generated under other circumstances, so this change qualifies this with mOkayForFocusNotToMatch, which is only set after the IME next button is pressed. The other change qualfies onTextChanged calls so that if it was triggered by setTextAndKeepSelection, the webkit-side selection is unchanged. fixes http://b/issue?id=2096746
Diffstat (limited to 'core/java/android/webkit/WebTextView.java')
-rw-r--r--core/java/android/webkit/WebTextView.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index f479124..e0d41c2 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -87,11 +87,12 @@ import java.util.ArrayList;
// Gets set to true when the the IME jumps to the next textfield. When this
// happens, the next time the user hits a key it is okay for the focus
// pointer to not match the WebTextView's node pointer
- private boolean mOkayForFocusNotToMatch;
+ boolean mOkayForFocusNotToMatch;
// Whether or not a selection change was generated from webkit. If it was,
// we do not need to pass the selection back to webkit.
private boolean mFromWebKit;
private boolean mGotTouchDown;
+ private boolean mInSetTextAndKeepSelection;
// Array to store the final character added in onTextChanged, so that its
// KeyEvents may be determined.
private char[] mCharacter = new char[1];
@@ -395,7 +396,9 @@ import java.util.ArrayList;
Log.v(LOGTAG, "onTextChanged start=" + start
+ " start + before=" + (start + before));
}
- mWebView.setSelection(start, start + before);
+ if (!mInSetTextAndKeepSelection) {
+ mWebView.setSelection(start, start + before);
+ }
}
if (!cannotUseKeyEvents) {
int length = events.length;
@@ -791,7 +794,9 @@ import java.util.ArrayList;
/* package */ void setTextAndKeepSelection(String text) {
mPreChange = text.toString();
Editable edit = (Editable) getText();
+ mInSetTextAndKeepSelection = true;
edit.replace(0, edit.length(), text);
+ mInSetTextAndKeepSelection = false;
updateCachedTextfield();
}