Commit 1e664dd6 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Only clear insertion handle if there is no range selection

There is a race condition where a user makes an insertion handle
and then long-presses some text to make a selection. This can result
in the |INSERTION_HANDLE_CLEARED| coming after the call to
|SelectionPopupControllerImpl#showSelectionMenu()| which resets the
menu position set by |showSelectionMenu()|. This CL fixes that by first
making sure there is no range selection before trying to clear the
insertion handle.

Bug: 773515
Change-Id: I16b1e845b3960420f424dd04d418464a26bc5f1b
Reviewed-on: https://chromium-review.googlesource.com/884508Reviewed-by: default avatarShimi Zhang <ctzsm@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531737}
parent e5073d50
...@@ -1189,7 +1189,7 @@ public class SelectionPopupControllerImpl ...@@ -1189,7 +1189,7 @@ public class SelectionPopupControllerImpl
case SelectionEventType.INSERTION_HANDLE_CLEARED: case SelectionEventType.INSERTION_HANDLE_CLEARED:
destroyPastePopup(); destroyPastePopup();
mIsInsertionForTesting = false; mIsInsertionForTesting = false;
mSelectionRect.setEmpty(); if (!hasSelection()) mSelectionRect.setEmpty();
break; break;
case SelectionEventType.INSERTION_HANDLE_DRAG_STARTED: case SelectionEventType.INSERTION_HANDLE_DRAG_STARTED:
...@@ -1241,7 +1241,7 @@ public class SelectionPopupControllerImpl ...@@ -1241,7 +1241,7 @@ public class SelectionPopupControllerImpl
@CalledByNative @CalledByNative
private void onSelectionChanged(String text) { private void onSelectionChanged(String text) {
if (text.length() == 0 && mHasSelection && mSelectionMetricsLogger != null) { if (text.length() == 0 && hasSelection() && mSelectionMetricsLogger != null) {
mSelectionMetricsLogger.logSelectionAction(mLastSelectedText, mLastSelectionOffset, mSelectionMetricsLogger.logSelectionAction(mLastSelectedText, mLastSelectionOffset,
SmartSelectionMetricsLogger.ActionType.ABANDON, SmartSelectionMetricsLogger.ActionType.ABANDON,
/* SelectionClient.Result = */ null); /* SelectionClient.Result = */ null);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment