Index: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java b/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
index 0012b5b1b0150d4da1713f251df91ffd5c2177a9..c3f3d75d63fc0e3813ca36c074a4faf5152d0990 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
@@ -116,6 +116,7 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
// editable region or from tapping the insertion handle. |
private PastePopupMenu mPastePopupMenu; |
private boolean mWasPastePopupShowingOnInsertionDragStart; |
+ private boolean mSelectionHandleDragStopped; |
aelias_OOO_until_Jul13
2017/04/21 21:42:19
I think it would be clearer to invert this, "mDrag
|
// The client that processes textual selection, or null if none exists. |
private SelectionClient mSelectionClient; |
@@ -208,6 +209,32 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
mAllowedMenuItems = allowedMenuItems; |
} |
+ public void showSelectionMenu(int xAnchor, int yAnchor, int left, int top, int right, |
+ int bottom, boolean isEditable, boolean isPasswordType, String selectionText, |
+ boolean canSelectAll) { |
+ mSelectionRect.set(left, top, right, bottom); |
+ mEditable = isEditable; |
+ mLastSelectedText = selectionText; |
+ mIsPasswordType = isPasswordType; |
+ mHasSelection = selectionText.length() != 0; |
aelias_OOO_until_Jul13
2017/04/21 21:42:19
This state is redundant now, can be replaced by bo
|
+ mIsInsertion = selectionText.length() == 0; |
aelias_OOO_until_Jul13
2017/04/21 21:42:19
Likewise for mIsInsertion maybe? Is there any val
|
+ mCanSelectAllForPastePopup = canSelectAll; |
+ mUnselectAllOnDismiss = true; |
+ if (isInsertion()) { |
+ createAndShowPastePopup(xAnchor, yAnchor); |
+ } else { |
+ if (mSelectionClient == null |
+ || !mSelectionClient.sendsSelectionPopupUpdates(!mSelectionHandleDragStopped)) { |
+ showActionModeOrClearOnFailure(); |
+ } else { |
+ // Rely on |mSelectionClient| sending a classification request and the request |
+ // always calling onClassified() callback. |
+ mPendingShowActionMode = true; |
+ } |
+ mSelectionHandleDragStopped = false; |
+ } |
+ } |
+ |
/** |
* Show (activate) android action mode by starting it. |
* |
@@ -253,14 +280,13 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
return actionMode; |
} |
- void createAndShowPastePopup(int x, int y, boolean canSelectAll) { |
+ void createAndShowPastePopup(int x, int y) { |
if (mView.getParent() == null || mView.getVisibility() != View.VISIBLE) { |
return; |
} |
if (!supportsFloatingActionMode() && !canPaste()) return; |
destroyPastePopup(); |
- mCanSelectAllForPastePopup = canSelectAll; |
PastePopupMenuDelegate delegate = new PastePopupMenuDelegate() { |
@Override |
public void paste() { |
@@ -645,8 +671,6 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
void selectAll() { |
mWebContents.selectAll(); |
mClassificationResult = null; |
- if (needsActionMenuUpdate()) showActionModeOrClearOnFailure(); |
- |
// Even though the above statement logged a SelectAll user action, we want to |
// track whether the focus was in an editable field, so log that too. |
if (isSelectionEditable()) { |
@@ -841,16 +865,6 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
if (top == bottom) ++bottom; |
switch (eventType) { |
case SelectionEventType.SELECTION_HANDLES_SHOWN: |
- mSelectionRect.set(left, top, right, bottom); |
- mHasSelection = true; |
- mUnselectAllOnDismiss = true; |
- if (mSelectionClient == null || !mSelectionClient.sendsSelectionPopupUpdates()) { |
- showActionModeOrClearOnFailure(); |
- } else { |
- // Rely on |mSelectionClient| sending a classification request and the request |
- // always calling onClassified() callback. |
- mPendingShowActionMode = true; |
- } |
break; |
case SelectionEventType.SELECTION_HANDLES_MOVED: |
@@ -870,15 +884,13 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
break; |
case SelectionEventType.SELECTION_HANDLE_DRAG_STARTED: |
+ mSelectionHandleDragStopped = false; |
hideActionMode(true); |
break; |
case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED: |
- if (mSelectionClient == null || !mSelectionClient.sendsSelectionPopupUpdates()) { |
- hideActionMode(false); |
- } |
- // Otherwise rely on |mSelectionClient| sending a classification request and the |
- // request always calling onClassified() callback. |
+ mSelectionHandleDragStopped = true; |
+ mWebContents.showContextMenuAtPoint(xAnchor, yAnchor); |
break; |
case SelectionEventType.INSERTION_HANDLE_SHOWN: |