diff options
-rw-r--r-- | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java | 22 |
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(); } |