From ef92e7a606167130d4ae52c1e23f32c3f0af291e Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Wed, 2 Sep 2009 17:47:29 -0400 Subject: 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 --- core/java/android/webkit/WebTextView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index a1f2223..95b3a12 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; } -- cgit v1.1