| 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 a6f50a38e44ab3251eb55128cfe9d5ae6b551e84..27c028bc9c68213c7c46d96f12080777d12e7938 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
|
| @@ -28,6 +28,8 @@ import android.view.WindowManager;
|
| import org.chromium.base.BuildInfo;
|
| import org.chromium.base.Log;
|
| import org.chromium.base.VisibleForTesting;
|
| +import org.chromium.base.annotations.CalledByNative;
|
| +import org.chromium.base.annotations.JNINamespace;
|
| import org.chromium.base.metrics.RecordUserAction;
|
| import org.chromium.content.R;
|
| import org.chromium.content.browser.input.FloatingPastePopupMenu;
|
| @@ -52,6 +54,7 @@ import java.util.List;
|
| * to create {@link ActionMode.Callback} instance and configure the selection action
|
| * mode tasks to their requirements.
|
| */
|
| +@JNINamespace("content")
|
| @TargetApi(Build.VERSION_CODES.M)
|
| public class SelectionPopupController extends ActionModeCallbackHelper {
|
| private static final String TAG = "SelectionPopupCtlr"; // 20 char limit
|
| @@ -129,6 +132,12 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| // arrives or till the selection is adjusted based on the classification result.
|
| private boolean mPendingShowActionMode;
|
|
|
| + // True if flinging is in progress.
|
| + private boolean mIsFlinging;
|
| +
|
| + // Whether a touch scroll sequence is active.
|
| + private boolean mTouchScrollInProgress;
|
| +
|
| /**
|
| * Create {@link SelectionPopupController} instance.
|
| * @param context Context for action mode.
|
| @@ -167,6 +176,8 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| mAssistMenuItemId =
|
| mContext.getResources().getIdentifier("textAssist", "id", "android");
|
| }
|
| +
|
| + nativeInit(webContents);
|
| }
|
|
|
| /**
|
| @@ -206,6 +217,10 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| mAllowedMenuItems = allowedMenuItems;
|
| }
|
|
|
| + void setIsFlinging(boolean isFlinging) {
|
| + mIsFlinging = isFlinging;
|
| + }
|
| +
|
| /**
|
| * Show (activate) android action mode by starting it.
|
| *
|
| @@ -346,12 +361,17 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| }
|
| }
|
|
|
| + void setTouchScrollInProgress(boolean inProgress) {
|
| + mTouchScrollInProgress = inProgress;
|
| + hideActionMode(inProgress);
|
| + }
|
| +
|
| /**
|
| * Hide or reveal the ActionMode. Note that this only has visible
|
| * side-effects if the underlying ActionMode supports hiding.
|
| * @param hide whether to hide or show the ActionMode.
|
| */
|
| - void hideActionMode(boolean hide) {
|
| + private void hideActionMode(boolean hide) {
|
| if (!canHideActionMode()) return;
|
| if (mHidden == hide) return;
|
| mHidden = hide;
|
| @@ -794,9 +814,9 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| }
|
|
|
| // All coordinates are in DIP.
|
| - void onSelectionEvent(int eventType, int xAnchor, int yAnchor,
|
| - int left, int top, int right, int bottom, boolean isScrollInProgress,
|
| - boolean touchScrollInProgress) {
|
| + @CalledByNative
|
| + private void onSelectionEvent(
|
| + int eventType, int xAnchor, int yAnchor, int left, int top, int right, int bottom) {
|
| // Ensure the provided selection coordinates form a non-empty rect, as required by
|
| // the selection action mode.
|
| if (left == right) ++right;
|
| @@ -850,7 +870,7 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
|
|
| case SelectionEventType.INSERTION_HANDLE_MOVED:
|
| mSelectionRect.set(left, top, right, bottom);
|
| - if (!isScrollInProgress && isPastePopupShowing()) {
|
| + if (!isScrollInProgress() && isPastePopupShowing()) {
|
| showPastePopup(xAnchor, yAnchor);
|
| } else {
|
| destroyPastePopup();
|
| @@ -896,6 +916,10 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| }
|
| }
|
|
|
| + private boolean isScrollInProgress() {
|
| + return mTouchScrollInProgress || mIsFlinging;
|
| + }
|
| +
|
| /**
|
| * Clears the current text selection. Note that we will try to move cursor to selection
|
| * end if applicable.
|
| @@ -906,7 +930,8 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| mClassificationResult = null;
|
| }
|
|
|
| - void onSelectionChanged(String text) {
|
| + @CalledByNative
|
| + private void onSelectionChanged(String text) {
|
| mLastSelectedText = text;
|
| if (mSelectionClient != null) {
|
| mSelectionClient.onSelectionChanged(text);
|
| @@ -1004,4 +1029,6 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
|
| showActionModeOrClearOnFailure();
|
| }
|
| };
|
| +
|
| + private native void nativeInit(WebContents webContents);
|
| }
|
|
|