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(
Java_SelectionPopupController_showSelectionMenu(
env, obj, params.selection_rect.x(), params.selection_rect.y(),
params.selection_rect.right(),
params.selection_rect.bottom() + handle_height, params.is_editable,
is_password_type, jselected_text, params.selection_start_offset,
can_select_all, can_edit_richly, should_suggest, params.source_type);
params.selection_rect.right(), params.selection_rect.bottom(),
handle_height, params.is_editable, is_password_type, jselected_text,
params.selection_start_offset, can_select_all, can_edit_richly,
should_suggest, params.source_type);
return true;
}
......
......@@ -272,11 +272,14 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
@VisibleForTesting
@CalledByNative
public void showSelectionMenu(int left, int top, int right, int bottom, boolean isEditable,
boolean isPasswordType, String selectionText, int selectionStartOffset,
boolean canSelectAll, boolean canRichlyEdit, boolean shouldSuggest,
@MenuSourceType int sourceType) {
mSelectionRect.set(left, top, right, bottom);
public void showSelectionMenu(int left, int top, int right, int bottom, int handleHeight,
boolean isEditable, boolean isPasswordType, String selectionText,
int selectionStartOffset, boolean canSelectAll, boolean canRichlyEdit,
boolean shouldSuggest, @MenuSourceType int sourceType) {
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;
mLastSelectedText = selectionText;
mLastSelectionOffset = selectionStartOffset;
......
......@@ -147,7 +147,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -162,7 +162,7 @@ public class SelectionPopupControllerTest {
.thenReturn(mActionMode);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -193,7 +193,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -206,7 +206,7 @@ public class SelectionPopupControllerTest {
// Another long press triggered showSelectionMenu() call.
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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -219,7 +219,7 @@ public class SelectionPopupControllerTest {
.thenReturn(mActionMode);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -231,7 +231,7 @@ public class SelectionPopupControllerTest {
assertEquals("Maps", returnResult.label);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -254,14 +254,14 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
MenuSourceType.MENU_SOURCE_LONG_PRESS);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -284,7 +284,7 @@ public class SelectionPopupControllerTest {
.thenReturn(mActionMode);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -296,7 +296,7 @@ public class SelectionPopupControllerTest {
assertEquals("Maps", returnResult.label);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -321,7 +321,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -335,7 +335,7 @@ public class SelectionPopupControllerTest {
mController.getResultCallback().onClassified(result);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -345,7 +345,7 @@ public class SelectionPopupControllerTest {
eq(AMPHITHEATRE_FULL), eq(0), isA(SelectionClient.Result.class));
// 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),
/* selectionOffset = */ 0,
/* canSelectAll = */ true,
......@@ -375,7 +375,7 @@ public class SelectionPopupControllerTest {
mController.setSelectionClient(client);
// 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,
/* canSelectAll = */ true,
/* canRichlyEdit = */ true, /* shouldSuggest = */ true,
......@@ -391,7 +391,7 @@ public class SelectionPopupControllerTest {
eq(AMPHITHEATRE), eq(5), any(SelectionClient.Result.class));
// 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),
/* selectionOffset = */ 0,
/* 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