Chromium Code Reviews| 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..a347bce95cc95e04d84e55333fe8521c9d633e0b 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 |
| @@ -131,6 +134,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; |
|
boliu
2017/04/20 18:17:28
you can combine these two, then in CVC, just pass
Jinsuk Kim
2017/04/20 22:55:54
Done. I passed true/false instead of isScrollInPro
|
| + |
| + // Whether a touch scroll is in progress. |
| + private boolean mTouchScrollInProgress; |
| + |
| /** |
| * Create {@link SelectionPopupController} instance. |
| * @param context Context for action mode. |
| @@ -169,6 +178,8 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
| mAssistMenuItemId = |
| mContext.getResources().getIdentifier("textAssist", "id", "android"); |
| } |
| + |
| + nativeInit(webContents); |
| } |
| /** |
| @@ -208,6 +219,10 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
| mAllowedMenuItems = allowedMenuItems; |
| } |
| + void setIsFlinging(boolean isFlinging) { |
| + mIsFlinging = isFlinging; |
| + } |
| + |
| /** |
| * Show (activate) android action mode by starting it. |
| * |
| @@ -360,12 +375,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; |
| @@ -832,9 +852,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; |
| @@ -888,7 +908,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(); |
| @@ -934,6 +954,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. |
| @@ -944,7 +968,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); |
| @@ -1042,4 +1067,6 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
| showActionModeOrClearOnFailure(); |
| } |
| }; |
| + |
| + private native void nativeInit(WebContents webContents); |
| } |