Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java

Issue 13820016: [Android] Remove zero length composing spans. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import com.google.common.annotations.VisibleForTesting; 7 import com.google.common.annotations.VisibleForTesting;
8 8
9 import android.text.Editable; 9 import android.text.Editable;
10 import android.text.InputType; 10 import android.text.InputType;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 if (prevSelectionStart == selectionStart && prevSelectionEnd == selectio nEnd 146 if (prevSelectionStart == selectionStart && prevSelectionEnd == selectio nEnd
147 && prevCompositionStart == compositionStart 147 && prevCompositionStart == compositionStart
148 && prevCompositionEnd == compositionEnd) { 148 && prevCompositionEnd == compositionEnd) {
149 // Nothing has changed; don't need to do anything 149 // Nothing has changed; don't need to do anything
150 return; 150 return;
151 } 151 }
152 152
153 Selection.setSelection(editable, selectionStart, selectionEnd); 153 Selection.setSelection(editable, selectionStart, selectionEnd);
154 super.setComposingRegion(compositionStart, compositionEnd); 154
155 if (compositionStart == compositionEnd) {
156 removeComposingSpans(editable);
157 } else {
158 super.setComposingRegion(compositionStart, compositionEnd);
159 }
155 160
156 if (mIgnoreTextInputStateUpdates) return; 161 if (mIgnoreTextInputStateUpdates) return;
157 updateSelection(selectionStart, selectionEnd, compositionStart, composit ionEnd); 162 updateSelection(selectionStart, selectionEnd, compositionStart, composit ionEnd);
158 } 163 }
159 164
160 @VisibleForTesting 165 @VisibleForTesting
161 protected void updateSelection( 166 protected void updateSelection(
162 int selectionStart, int selectionEnd, 167 int selectionStart, int selectionEnd,
163 int compositionStart, int compositionEnd) { 168 int compositionStart, int compositionEnd) {
164 // Avoid sending update if we sent an exact update already previously. 169 // Avoid sending update if we sent an exact update already previously.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 378 }
374 379
375 /** 380 /**
376 * @see BaseInputConnection#setComposingRegion(int, int) 381 * @see BaseInputConnection#setComposingRegion(int, int)
377 */ 382 */
378 @Override 383 @Override
379 public boolean setComposingRegion(int start, int end) { 384 public boolean setComposingRegion(int start, int end) {
380 if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + "]"); 385 if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + "]");
381 int a = Math.min(start, end); 386 int a = Math.min(start, end);
382 int b = Math.max(start, end); 387 int b = Math.max(start, end);
383 super.setComposingRegion(a, b); 388
389 if (a == b) {
390 removeComposingSpans(getEditable());
391 } else {
392 super.setComposingRegion(a, b);
393 }
384 return mImeAdapter.setComposingRegion(a, b); 394 return mImeAdapter.setComposingRegion(a, b);
385 } 395 }
386 396
387 boolean isActive() { 397 boolean isActive() {
388 return getInputMethodManagerWrapper().isActive(mInternalView); 398 return getInputMethodManagerWrapper().isActive(mInternalView);
389 } 399 }
390 400
391 public void setIgnoreTextInputStateUpdates(boolean shouldIgnore) { 401 public void setIgnoreTextInputStateUpdates(boolean shouldIgnore) {
392 mIgnoreTextInputStateUpdates = shouldIgnore; 402 mIgnoreTextInputStateUpdates = shouldIgnore;
393 if (shouldIgnore) return; 403 if (shouldIgnore) return;
394 404
395 Editable editable = getEditable(); 405 Editable editable = getEditable();
396 updateSelection(Selection.getSelectionStart(editable), 406 updateSelection(Selection.getSelectionStart(editable),
397 Selection.getSelectionEnd(editable), 407 Selection.getSelectionEnd(editable),
398 getComposingSpanStart(editable), 408 getComposingSpanStart(editable),
399 getComposingSpanEnd(editable)); 409 getComposingSpanEnd(editable));
400 } 410 }
401 411
402 @VisibleForTesting 412 @VisibleForTesting
403 protected boolean isIgnoringTextInputStateUpdates() { 413 protected boolean isIgnoringTextInputStateUpdates() {
404 return mIgnoreTextInputStateUpdates; 414 return mIgnoreTextInputStateUpdates;
405 } 415 }
406 416
407 private InputMethodManagerWrapper getInputMethodManagerWrapper() { 417 private InputMethodManagerWrapper getInputMethodManagerWrapper() {
408 return mImeAdapter.getInputMethodManagerWrapper(); 418 return mImeAdapter.getInputMethodManagerWrapper();
409 } 419 }
410 } 420 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698