summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoraurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-19 05:12:23 +0000
committeraurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-19 05:12:23 +0000
commitc105f099efa03e0e7db630be209d57b71f33d8b3 (patch)
tree90c1ef548ff1a51378b268a3c7884bba71029a5e /content
parent27a41fe44f2c76b55e75d351cd3b75d0e7aabdd7 (diff)
downloadchromium_src-c105f099efa03e0e7db630be209d57b71f33d8b3.zip
chromium_src-c105f099efa03e0e7db630be209d57b71f33d8b3.tar.gz
chromium_src-c105f099efa03e0e7db630be209d57b71f33d8b3.tar.bz2
Add capping to deleteSurroundingText.
Add check to make sure that we do not try to delete text outside of the bounds. BUG=286348 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/23464043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
index 7d39b7f..653c366 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
@@ -164,9 +164,8 @@ public class AdapterInputConnection extends BaseInputConnection {
}
@VisibleForTesting
- protected void updateSelection(
- int selectionStart, int selectionEnd,
- int compositionStart, int compositionEnd) {
+ protected void updateSelection(int selectionStart, int selectionEnd, int compositionStart,
+ int compositionEnd) {
// Avoid sending update if we sent an exact update already previously.
if (mLastUpdateSelectionStart == selectionStart &&
mLastUpdateSelectionEnd == selectionEnd &&
@@ -296,14 +295,17 @@ public class AdapterInputConnection extends BaseInputConnection {
* @see BaseInputConnection#deleteSurroundingText(int, int)
*/
@Override
- public boolean deleteSurroundingText(int leftLength, int rightLength) {
+ public boolean deleteSurroundingText(int beforeLength, int afterLength) {
if (DEBUG) {
- Log.w(TAG, "deleteSurroundingText [" + leftLength + " " + rightLength + "]");
- }
- if (!super.deleteSurroundingText(leftLength, rightLength)) {
- return false;
+ Log.w(TAG, "deleteSurroundingText [" + beforeLength + " " + afterLength + "]");
}
- return mImeAdapter.deleteSurroundingText(leftLength, rightLength);
+ Editable editable = getEditable();
+ int availableBefore = Selection.getSelectionStart(editable);
+ int availableAfter = editable.length() - Selection.getSelectionEnd(editable);
+ beforeLength = Math.min(beforeLength, availableBefore);
+ afterLength = Math.min(afterLength, availableAfter);
+ super.deleteSurroundingText(beforeLength, afterLength);
+ return mImeAdapter.deleteSurroundingText(beforeLength, afterLength);
}
/**