summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2014-11-13 11:25:33 -0800
committerSelim Gurun <sgurun@google.com>2014-11-13 11:25:33 -0800
commit5154ef920639c9c98a8ae94355a7247c2fd82dc4 (patch)
tree2a17e55667e8de542c53a2dd72f5fb66d5f2d537
parent757e6d30528497c763bce864b552885d3c119fc7 (diff)
downloadchromium_org-5154ef920639c9c98a8ae94355a7247c2fd82dc4.tar.gz
Clear the selection when hiding the handles
Bug: 18200283 Cherry-pick https://codereview.chromium.org/713493003. Clear the selected text when hiding the handles and the desired behavior is to "unselect all on dismiss". BUG=430859 internal b/18200283 Review URL: https://codereview.chromium.org/713493003 Change-Id: Ie8d751774c6341054f0c1b8d4cca91ba6877e373 Cr-Commit-Position: refs/heads/master@{#303946}
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 001238487c..234bc47654 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -1289,6 +1289,10 @@ public class ContentViewCore
private void hidePopupsAndClearSelection() {
mUnselectAllOnActionModeDismiss = true;
hidePopups();
+ // Clear the selection. The selection is cleared on destroying IME
+ // and also here since we may receive destroy first, for example
+ // when focus is lost in webview.
+ clearUserSelection();
}
private void hidePopupsAndPreserveSelection() {
@@ -1296,6 +1300,17 @@ public class ContentViewCore
hidePopups();
}
+ private void clearUserSelection() {
+ if (isSelectionEditable()) {
+ if (mInputConnection != null) {
+ int selectionEnd = Selection.getSelectionEnd(mEditable);
+ mInputConnection.setSelection(selectionEnd, selectionEnd);
+ }
+ } else if (mImeAdapter != null) {
+ mImeAdapter.unselect();
+ }
+ }
+
private void hidePopups() {
hideSelectActionBar();
hidePastePopup();
@@ -1909,12 +1924,7 @@ public class ContentViewCore
mActionMode = null;
if (mUnselectAllOnActionModeDismiss) {
hideTextHandles();
- if (isSelectionEditable()) {
- int selectionEnd = Selection.getSelectionEnd(mEditable);
- mInputConnection.setSelection(selectionEnd, selectionEnd);
- } else {
- mImeAdapter.unselect();
- }
+ clearUserSelection();
}
getContentViewClient().onContextualActionBarHidden();
}