Bug 765831 - Part 2: Clamp bogus selection indexes passed to setSelection(). r=blassey

This commit is contained in:
Chris Peterson 2012-06-19 12:13:48 -07:00
parent 0e8e38a31e
commit fad3377b1a

View File

@ -234,10 +234,12 @@ public class GeckoInputConnection
@Override @Override
public boolean setSelection(int start, int end) { public boolean setSelection(int start, int end) {
GeckoAppShell.sendEventToGecko( // Some IMEs call setSelection() with negative or stale indexes, so clamp them.
GeckoEvent.createIMEEvent(GeckoEvent.IME_SET_SELECTION, start, end - start)); Span newSelection = Span.clamp(start, end, getEditable());
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(GeckoEvent.IME_SET_SELECTION,
return super.setSelection(start, end); newSelection.start,
newSelection.length));
return super.setSelection(newSelection.start, newSelection.end);
} }
@Override @Override