diff options
| author | 2009-09-02 17:47:29 -0400 | |
|---|---|---|
| committer | 2009-09-02 19:31:33 -0400 | |
| commit | ef92e7a606167130d4ae52c1e23f32c3f0af291e (patch) | |
| tree | 0c5a6e8a32f5ace680783017ed5e8874ca05ff7e | |
| parent | 169ae05f9f5cce400dd936e2a31676b80d84b862 (diff) | |
Prevent a crash when webkit changes the selection.
Partial fix for http://b/issue?id=2081673
This prevents a crash. However, if the user continues typing
into the textfield, the selection is incorrect. The real solution
(forthcoming), will make sure that the WebTextView's text gets
updated when webkit updates.
Change-Id: Ic832ec48fd4236c8116c5cbda1467677ad731feb
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index a1f2223412e7..95b3a12ad308 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -697,8 +697,12 @@ import java.util.ArrayList; * Set the selection, and disable our onSelectionChanged action. */ /* package */ void setSelectionFromWebKit(int start, int end) { + if (start < 0 || end < 0) return; + Spannable text = (Spannable) getText(); + int length = text.length(); + if (start > length || end > length) return; mFromWebKit = true; - Selection.setSelection((Spannable) getText(), start, end); + Selection.setSelection(text, start, end); mFromWebKit = false; } |