Commit 7b15adda authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Don't offset selection by handle height for legacy paste menu

|LegacyPastePopupMenu#positionAt| expects the coordinates of the bottom
of the selection caret not the bottom of the touch handle.

Bug: 732742
Change-Id: Idc6d92076695bf865afc093c4980f10e1c48282e
Reviewed-on: https://chromium-review.googlesource.com/849493Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526894}
parent 286fcbbb
...@@ -160,10 +160,10 @@ bool SelectionPopupController::ShowSelectionMenu( ...@@ -160,10 +160,10 @@ bool SelectionPopupController::ShowSelectionMenu(
Java_SelectionPopupController_showSelectionMenu( Java_SelectionPopupController_showSelectionMenu(
env, obj, params.selection_rect.x(), params.selection_rect.y(), env, obj, params.selection_rect.x(), params.selection_rect.y(),
params.selection_rect.right(), params.selection_rect.right(), params.selection_rect.bottom(),
params.selection_rect.bottom() + handle_height, params.is_editable, handle_height, params.is_editable, is_password_type, jselected_text,
is_password_type, jselected_text, params.selection_start_offset, params.selection_start_offset, can_select_all, can_edit_richly,
can_select_all, can_edit_richly, should_suggest, params.source_type); should_suggest, params.source_type);
return true; return true;
} }
......
...@@ -272,11 +272,14 @@ public class SelectionPopupController extends ActionModeCallbackHelper { ...@@ -272,11 +272,14 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
@VisibleForTesting @VisibleForTesting
@CalledByNative @CalledByNative
public void showSelectionMenu(int left, int top, int right, int bottom, boolean isEditable, public void showSelectionMenu(int left, int top, int right, int bottom, int handleHeight,
boolean isPasswordType, String selectionText, int selectionStartOffset, boolean isEditable, boolean isPasswordType, String selectionText,
boolean canSelectAll, boolean canRichlyEdit, boolean shouldSuggest, int selectionStartOffset, boolean canSelectAll, boolean canRichlyEdit,
@MenuSourceType int sourceType) { boolean shouldSuggest, @MenuSourceType int sourceType) {
mSelectionRect.set(left, top, right, bottom); int offsetBottom = bottom;
// Legacy action mode expects the selection rectangle not to include touch handle.
if (supportsFloatingActionMode()) offsetBottom += handleHeight;
mSelectionRect.set(left, top, right, offsetBottom);
mEditable = isEditable; mEditable = isEditable;
mLastSelectedText = selectionText; mLastSelectedText = selectionText;
mLastSelectionOffset = selectionStartOffset; mLastSelectionOffset = selectionStartOffset;
......
...@@ -147,7 +147,7 @@ public class SelectionPopupControllerTest { ...@@ -147,7 +147,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client); mController.setSelectionClient(client);
// Long press triggered showSelectionMenu() call. // Long press triggered showSelectionMenu() call.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5, /* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -162,7 +162,7 @@ public class SelectionPopupControllerTest { ...@@ -162,7 +162,7 @@ public class SelectionPopupControllerTest {
.thenReturn(mActionMode); .thenReturn(mActionMode);
// Call showSelectionMenu again, which is adjustSelectionByCharacterOffset triggered. // Call showSelectionMenu again, which is adjustSelectionByCharacterOffset triggered.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0, /* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -193,7 +193,7 @@ public class SelectionPopupControllerTest { ...@@ -193,7 +193,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client); mController.setSelectionClient(client);
// Long press triggered showSelectionMenu() call. // Long press triggered showSelectionMenu() call.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5, /* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -206,7 +206,7 @@ public class SelectionPopupControllerTest { ...@@ -206,7 +206,7 @@ public class SelectionPopupControllerTest {
// Another long press triggered showSelectionMenu() call. // Another long press triggered showSelectionMenu() call.
client.setResult(newResult); client.setResult(newResult);
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, MOUNTAIN, /* selectionOffset = */ 21, /* isPasswordType = */ false, MOUNTAIN, /* selectionOffset = */ 21,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -219,7 +219,7 @@ public class SelectionPopupControllerTest { ...@@ -219,7 +219,7 @@ public class SelectionPopupControllerTest {
.thenReturn(mActionMode); .thenReturn(mActionMode);
// First adjustSelectionByCharacterOffset() triggered. // First adjustSelectionByCharacterOffset() triggered.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0, /* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -231,7 +231,7 @@ public class SelectionPopupControllerTest { ...@@ -231,7 +231,7 @@ public class SelectionPopupControllerTest {
assertEquals("Maps", returnResult.label); assertEquals("Maps", returnResult.label);
// Second adjustSelectionByCharacterOffset() triggered. // Second adjustSelectionByCharacterOffset() triggered.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, MOUNTAIN_FULL, /* selectionOffset = */ 0, /* isPasswordType = */ false, MOUNTAIN_FULL, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -254,14 +254,14 @@ public class SelectionPopupControllerTest { ...@@ -254,14 +254,14 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client); mController.setSelectionClient(client);
// Long press triggered showSelectionMenu() call. // Long press triggered showSelectionMenu() call.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5, /* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
MenuSourceType.MENU_SOURCE_LONG_PRESS); MenuSourceType.MENU_SOURCE_LONG_PRESS);
// Another long press triggered showSelectionMenu() call. // Another long press triggered showSelectionMenu() call.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, MOUNTAIN, /* selectionOffset = */ 21, /* isPasswordType = */ false, MOUNTAIN, /* selectionOffset = */ 21,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -284,7 +284,7 @@ public class SelectionPopupControllerTest { ...@@ -284,7 +284,7 @@ public class SelectionPopupControllerTest {
.thenReturn(mActionMode); .thenReturn(mActionMode);
// First adjustSelectionByCharacterOffset() triggered. // First adjustSelectionByCharacterOffset() triggered.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0, /* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -296,7 +296,7 @@ public class SelectionPopupControllerTest { ...@@ -296,7 +296,7 @@ public class SelectionPopupControllerTest {
assertEquals("Maps", returnResult.label); assertEquals("Maps", returnResult.label);
// Second adjustSelectionByCharacterOffset() triggered. // Second adjustSelectionByCharacterOffset() triggered.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, MOUNTAIN_FULL, /* selectionOffset = */ 0, /* isPasswordType = */ false, MOUNTAIN_FULL, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -321,7 +321,7 @@ public class SelectionPopupControllerTest { ...@@ -321,7 +321,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client); mController.setSelectionClient(client);
// Long press triggered showSelectionMenu() call. // Long press triggered showSelectionMenu() call.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5, /* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -335,7 +335,7 @@ public class SelectionPopupControllerTest { ...@@ -335,7 +335,7 @@ public class SelectionPopupControllerTest {
mController.getResultCallback().onClassified(result); mController.getResultCallback().onClassified(result);
// Call showSelectionMenu again, which is adjustSelectionByCharacterOffset triggered. // Call showSelectionMenu again, which is adjustSelectionByCharacterOffset triggered.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0, /* isPasswordType = */ false, AMPHITHEATRE_FULL, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -345,7 +345,7 @@ public class SelectionPopupControllerTest { ...@@ -345,7 +345,7 @@ public class SelectionPopupControllerTest {
eq(AMPHITHEATRE_FULL), eq(0), isA(SelectionClient.Result.class)); eq(AMPHITHEATRE_FULL), eq(0), isA(SelectionClient.Result.class));
// Dragging selection handle, select "1600 Amphitheatre". // Dragging selection handle, select "1600 Amphitheatre".
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE_FULL.substring(0, 17), /* isPasswordType = */ false, AMPHITHEATRE_FULL.substring(0, 17),
/* selectionOffset = */ 0, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
...@@ -375,7 +375,7 @@ public class SelectionPopupControllerTest { ...@@ -375,7 +375,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client); mController.setSelectionClient(client);
// Long press triggered showSelectionMenu() call. // Long press triggered showSelectionMenu() call.
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5, /* isPasswordType = */ false, AMPHITHEATRE, /* selectionOffset = */ 5,
/* canSelectAll = */ true, /* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true, /* canRichlyEdit = */ true, /* shouldSuggest = */ true,
...@@ -391,7 +391,7 @@ public class SelectionPopupControllerTest { ...@@ -391,7 +391,7 @@ public class SelectionPopupControllerTest {
eq(AMPHITHEATRE), eq(5), any(SelectionClient.Result.class)); eq(AMPHITHEATRE), eq(5), any(SelectionClient.Result.class));
// Dragging selection handle, select "1600 Amphitheatre". // Dragging selection handle, select "1600 Amphitheatre".
mController.showSelectionMenu(0, 0, 0, 0, /* isEditable = */ true, mController.showSelectionMenu(0, 0, 0, 0, 0, /* isEditable = */ true,
/* isPasswordType = */ false, AMPHITHEATRE_FULL.substring(0, 17), /* isPasswordType = */ false, AMPHITHEATRE_FULL.substring(0, 17),
/* selectionOffset = */ 0, /* selectionOffset = */ 0,
/* canSelectAll = */ true, /* canSelectAll = */ true,
......
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