summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/WebTextView.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2009-12-02 10:12:57 -0500
committerLeon Scroggins <scroggo@google.com>2009-12-02 10:27:22 -0500
commitcfc2915d926cee14380b54d0960262e748eed4f5 (patch)
tree62ea0f65f77662f05dd9bf1ce57e16b22062adbc /core/java/android/webkit/WebTextView.java
parent9ed7dc10d263a505da32522139098f085fee811a (diff)
downloadframeworks_base-cfc2915d926cee14380b54d0960262e748eed4f5.zip
frameworks_base-cfc2915d926cee14380b54d0960262e748eed4f5.tar.gz
frameworks_base-cfc2915d926cee14380b54d0960262e748eed4f5.tar.bz2
In setDefaultSelection ensure that webkit is notified of the new selection.
Fix for http://b/issue?id=2254732
Diffstat (limited to 'core/java/android/webkit/WebTextView.java')
-rw-r--r--core/java/android/webkit/WebTextView.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index 412e0d9..f04b04f 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -644,7 +644,22 @@ import java.util.ArrayList;
/* package */ void setDefaultSelection() {
Spannable text = (Spannable) getText();
int selection = mSingle ? text.length() : 0;
- Selection. setSelection(text, selection, selection);
+ if (Selection.getSelectionStart(text) == selection
+ && Selection.getSelectionEnd(text) == selection) {
+ // The selection of the UI copy is set correctly, but the
+ // WebTextView still needs to inform the webkit thread to set the
+ // selection. Normally that is done in onSelectionChanged, but
+ // onSelectionChanged will not be called because the UI copy is not
+ // changing. (This can happen when the WebTextView takes focus.
+ // That onSelectionChanged was blocked because the selection set
+ // when focusing is not necessarily the desirable selection for
+ // WebTextView.)
+ if (mWebView != null) {
+ mWebView.setSelection(selection, selection);
+ }
+ } else {
+ Selection.setSelection(text, selection, selection);
+ }
}
/**