| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| index 823b08c6bcdef6dbce0c491e382c952f3c700a9f..66a80a690f4e16795ca8b6388cf2fe3cb6a2e3ba 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| @@ -7,6 +7,7 @@ package org.chromium.content.browser;
|
| import android.annotation.SuppressLint;
|
| import android.app.Activity;
|
| import android.app.SearchManager;
|
| +import android.content.ClipboardManager;
|
| import android.content.ContentResolver;
|
| import android.content.Context;
|
| import android.content.Intent;
|
| @@ -61,16 +62,18 @@ import org.chromium.content.browser.accessibility.AccessibilityInjector;
|
| import org.chromium.content.browser.accessibility.BrowserAccessibilityManager;
|
| import org.chromium.content.browser.input.AdapterInputConnection;
|
| import org.chromium.content.browser.input.GamepadList;
|
| -import org.chromium.content.browser.input.HandleView;
|
| import org.chromium.content.browser.input.ImeAdapter;
|
| import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFactory;
|
| import org.chromium.content.browser.input.InputMethodManagerWrapper;
|
| -import org.chromium.content.browser.input.InsertionHandleController;
|
| +import org.chromium.content.browser.input.PastePopupMenu;
|
| +import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate;
|
| +import org.chromium.content.browser.input.PopupTouchHandleDrawable;
|
| +import org.chromium.content.browser.input.PopupTouchHandleDrawable.PopupTouchHandleDrawableDelegate;
|
| import org.chromium.content.browser.input.SelectPopup;
|
| import org.chromium.content.browser.input.SelectPopupDialog;
|
| import org.chromium.content.browser.input.SelectPopupDropdown;
|
| import org.chromium.content.browser.input.SelectPopupItem;
|
| -import org.chromium.content.browser.input.SelectionHandleController;
|
| +import org.chromium.content.browser.input.SelectionEventType;
|
| import org.chromium.content.common.ContentSwitches;
|
| import org.chromium.content_public.browser.GestureStateListener;
|
| import org.chromium.content_public.browser.WebContents;
|
| @@ -107,9 +110,6 @@ public class ContentViewCore
|
| private static final int IS_LONG_PRESS = 1;
|
| private static final int IS_LONG_TAP = 2;
|
|
|
| - // Length of the delay (in ms) before fading in handles after the last page movement.
|
| - private static final int TEXT_HANDLE_FADE_IN_DELAY = 300;
|
| -
|
| // If the embedder adds a JavaScript interface object that contains an indirect reference to
|
| // the ContentViewCore, then storing a strong ref to the interface object on the native
|
| // side would prevent garbage collection of the ContentViewCore (as that strong ref would
|
| @@ -259,13 +259,10 @@ public class ContentViewCore
|
| private AdapterInputConnection mInputConnection;
|
| private InputMethodManagerWrapper mInputMethodManagerWrapper;
|
|
|
| - private SelectionHandleController mSelectionHandleController;
|
| - private InsertionHandleController mInsertionHandleController;
|
| -
|
| - private Runnable mDeferredHandleFadeInRunnable;
|
| + private PastePopupMenu mPastePopupMenu;
|
| + private PopupTouchHandleDrawableDelegate mTouchHandleDelegate;
|
|
|
| private PositionObserver mPositionObserver;
|
| - private PositionObserver.Listener mPositionListener;
|
|
|
| // Size of the viewport in physical pixels as set from onSizeChanged.
|
| private int mViewportWidthPix;
|
| @@ -279,13 +276,10 @@ public class ContentViewCore
|
| // Cached copy of all positions and scales as reported by the renderer.
|
| private final RenderCoordinates mRenderCoordinates;
|
|
|
| - private final RenderCoordinates.NormalizedPoint mStartHandlePoint;
|
| - private final RenderCoordinates.NormalizedPoint mEndHandlePoint;
|
| - private final RenderCoordinates.NormalizedPoint mInsertionHandlePoint;
|
| -
|
| // Tracks whether a selection is currently active. When applied to selected text, indicates
|
| // whether the last selected text is still highlighted.
|
| private boolean mHasSelection;
|
| + private boolean mHasInsertion;
|
| private String mLastSelectedText;
|
| private boolean mSelectionEditable;
|
| private ActionMode mActionMode;
|
| @@ -375,9 +369,6 @@ public class ContentViewCore
|
| deviceScaleFactor = Float.valueOf(forceScaleFactor);
|
| }
|
| mRenderCoordinates.setDeviceScaleFactor(deviceScaleFactor);
|
| - mStartHandlePoint = mRenderCoordinates.createNormalizedPoint();
|
| - mEndHandlePoint = mRenderCoordinates.createNormalizedPoint();
|
| - mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint();
|
| mAccessibilityManager = (AccessibilityManager)
|
| getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
| mGestureStateListeners = new ObserverList<GestureStateListener>();
|
| @@ -535,7 +526,7 @@ public class ContentViewCore
|
| public void onImeEvent(boolean isFinish) {
|
| getContentViewClient().onImeEvent();
|
| if (!isFinish) {
|
| - hideHandles();
|
| + hideTextHandles();
|
| }
|
| }
|
|
|
| @@ -598,15 +589,6 @@ public class ContentViewCore
|
| long nativeWebContents, WindowAndroid windowAndroid) {
|
| setContainerView(containerView);
|
|
|
| - mPositionListener = new PositionObserver.Listener() {
|
| - @Override
|
| - public void onPositionChanged(int x, int y) {
|
| - if (isSelectionHandleShowing() || isInsertionHandleShowing()) {
|
| - temporarilyHideTextHandles();
|
| - }
|
| - }
|
| - };
|
| -
|
| long windowNativePointer = windowAndroid != null ? windowAndroid.getNativePointer() : 0;
|
|
|
| long viewAndroidNativePointer = 0;
|
| @@ -678,9 +660,7 @@ public class ContentViewCore
|
| public void setContainerView(ViewGroup containerView) {
|
| TraceEvent.begin();
|
| if (mContainerView != null) {
|
| - mPositionObserver.removeListener(mPositionListener);
|
| - mSelectionHandleController = null;
|
| - mInsertionHandleController = null;
|
| + mPastePopupMenu = null;
|
| mInputConnection = null;
|
| }
|
|
|
| @@ -1121,18 +1101,7 @@ public class ContentViewCore
|
| cancelRequestToScrollFocusedEditableNodeIntoView();
|
|
|
| final int eventAction = event.getActionMasked();
|
| -
|
| - // Only these actions have any effect on gesture detection. Other
|
| - // actions have no corresponding WebTouchEvent type and may confuse the
|
| - // touch pipline, so we ignore them entirely.
|
| - if (eventAction != MotionEvent.ACTION_DOWN
|
| - && eventAction != MotionEvent.ACTION_UP
|
| - && eventAction != MotionEvent.ACTION_CANCEL
|
| - && eventAction != MotionEvent.ACTION_MOVE
|
| - && eventAction != MotionEvent.ACTION_POINTER_DOWN
|
| - && eventAction != MotionEvent.ACTION_POINTER_UP) {
|
| - return false;
|
| - }
|
| + if (!isValidTouchEventActionForNative(eventAction)) return false;
|
|
|
| if (mNativeContentViewCore == 0) return false;
|
|
|
| @@ -1164,6 +1133,18 @@ public class ContentViewCore
|
| }
|
| }
|
|
|
| + private static boolean isValidTouchEventActionForNative(int eventAction) {
|
| + // Only these actions have any effect on gesture detection. Other
|
| + // actions have no corresponding WebTouchEvent type and may confuse the
|
| + // touch pipline, so we ignore them entirely.
|
| + return eventAction == MotionEvent.ACTION_DOWN
|
| + || eventAction == MotionEvent.ACTION_UP
|
| + || eventAction == MotionEvent.ACTION_CANCEL
|
| + || eventAction == MotionEvent.ACTION_MOVE
|
| + || eventAction == MotionEvent.ACTION_POINTER_DOWN
|
| + || eventAction == MotionEvent.ACTION_POINTER_UP;
|
| + }
|
| +
|
| public void setIgnoreRemainingTouchEvents() {
|
| resetGestureDetection();
|
| }
|
| @@ -1177,7 +1158,6 @@ public class ContentViewCore
|
| private void onFlingStartEventConsumed(int vx, int vy) {
|
| mTouchScrollInProgress = false;
|
| mPotentiallyActiveFlingCount++;
|
| - temporarilyHideTextHandles();
|
| for (mGestureStateListenersIterator.rewind();
|
| mGestureStateListenersIterator.hasNext();) {
|
| mGestureStateListenersIterator.next().onFlingStartGesture(
|
| @@ -1204,8 +1184,8 @@ public class ContentViewCore
|
| @SuppressWarnings("unused")
|
| @CalledByNative
|
| private void onScrollBeginEventAck() {
|
| + hidePastePopup();
|
| mTouchScrollInProgress = true;
|
| - temporarilyHideTextHandles();
|
| mZoomControlsDelegate.invokeZoomPicker();
|
| updateGestureStateListener(GestureEventType.SCROLL_START);
|
| }
|
| @@ -1231,7 +1211,6 @@ public class ContentViewCore
|
| @SuppressWarnings("unused")
|
| @CalledByNative
|
| private void onPinchBeginEventAck() {
|
| - temporarilyHideTextHandles();
|
| updateGestureStateListener(GestureEventType.PINCH_BEGIN);
|
| }
|
|
|
| @@ -1250,12 +1229,6 @@ public class ContentViewCore
|
| }
|
| }
|
|
|
| - @SuppressWarnings("unused")
|
| - @CalledByNative
|
| - private void onDoubleTapEventAck() {
|
| - temporarilyHideTextHandles();
|
| - }
|
| -
|
| /**
|
| * Called just prior to a tap or press gesture being forwarded to the renderer.
|
| */
|
| @@ -1421,9 +1394,11 @@ public class ContentViewCore
|
| }
|
|
|
| private void hidePopups() {
|
| - hideSelectPopup();
|
| - hideHandles();
|
| + mUnselectAllOnActionModeDismiss = true;
|
| hideSelectActionBar();
|
| + hidePastePopup();
|
| + hideSelectPopup();
|
| + hideTextHandles();
|
| }
|
|
|
| public void hideSelectActionBar() {
|
| @@ -1878,13 +1853,7 @@ public class ContentViewCore
|
| mLastTapX = (int) xPix;
|
| mLastTapY = (int) yPix;
|
|
|
| - if (type == GestureEventType.LONG_PRESS
|
| - || type == GestureEventType.LONG_TAP) {
|
| - getInsertionHandleController().allowAutomaticShowing();
|
| - getSelectionHandleController().allowAutomaticShowing();
|
| - } else {
|
| - if (mSelectionEditable) getInsertionHandleController().allowAutomaticShowing();
|
| - }
|
| + if (type == GestureEventType.LONG_PRESS) getPastePopup().allowAutomaticShowing();
|
| }
|
|
|
| /**
|
| @@ -1947,101 +1916,6 @@ public class ContentViewCore
|
| return mDownloadDelegate;
|
| }
|
|
|
| - private SelectionHandleController getSelectionHandleController() {
|
| - if (mSelectionHandleController == null) {
|
| - mSelectionHandleController = new SelectionHandleController(
|
| - getContainerView(), mPositionObserver) {
|
| - @Override
|
| - public void selectBetweenCoordinates(int x1, int y1, int x2, int y2) {
|
| - if (mNativeContentViewCore != 0 && !(x1 == x2 && y1 == y2)) {
|
| - nativeSelectBetweenCoordinates(mNativeContentViewCore,
|
| - x1, y1 - mRenderCoordinates.getContentOffsetYPix(),
|
| - x2, y2 - mRenderCoordinates.getContentOffsetYPix());
|
| - }
|
| - }
|
| -
|
| - @Override
|
| - public void showHandles(int startDir, int endDir) {
|
| - final boolean wasShowing = isShowing();
|
| - super.showHandles(startDir, endDir);
|
| - if (!wasShowing || mActionMode == null) showSelectActionBar();
|
| - }
|
| -
|
| - };
|
| -
|
| - mSelectionHandleController.hideAndDisallowAutomaticShowing();
|
| - }
|
| -
|
| - return mSelectionHandleController;
|
| - }
|
| -
|
| - private InsertionHandleController getInsertionHandleController() {
|
| - if (mInsertionHandleController == null) {
|
| - mInsertionHandleController = new InsertionHandleController(
|
| - getContainerView(), mPositionObserver) {
|
| - private static final int AVERAGE_LINE_HEIGHT = 14;
|
| -
|
| - @Override
|
| - public void setCursorPosition(int x, int y) {
|
| - if (mNativeContentViewCore != 0) {
|
| - nativeMoveCaret(mNativeContentViewCore,
|
| - x, y - mRenderCoordinates.getContentOffsetYPix());
|
| - }
|
| - }
|
| -
|
| - @Override
|
| - public void paste() {
|
| - mImeAdapter.paste();
|
| - hideHandles();
|
| - }
|
| -
|
| - @Override
|
| - public int getLineHeight() {
|
| - return (int) Math.ceil(
|
| - mRenderCoordinates.fromLocalCssToPix(AVERAGE_LINE_HEIGHT));
|
| - }
|
| - };
|
| -
|
| - mInsertionHandleController.hideAndDisallowAutomaticShowing();
|
| - }
|
| -
|
| - return mInsertionHandleController;
|
| - }
|
| -
|
| - @VisibleForTesting
|
| - public InsertionHandleController getInsertionHandleControllerForTest() {
|
| - return mInsertionHandleController;
|
| - }
|
| -
|
| - @VisibleForTesting
|
| - public SelectionHandleController getSelectionHandleControllerForTest() {
|
| - return mSelectionHandleController;
|
| - }
|
| -
|
| - private void updateHandleScreenPositions() {
|
| - if (isSelectionHandleShowing()) {
|
| - mSelectionHandleController.setStartHandlePosition(
|
| - mStartHandlePoint.getXPix(), mStartHandlePoint.getYPix());
|
| - mSelectionHandleController.setEndHandlePosition(
|
| - mEndHandlePoint.getXPix(), mEndHandlePoint.getYPix());
|
| - }
|
| -
|
| - if (isInsertionHandleShowing()) {
|
| - mInsertionHandleController.setHandlePosition(
|
| - mInsertionHandlePoint.getXPix(), mInsertionHandlePoint.getYPix());
|
| - }
|
| - }
|
| -
|
| - private void hideHandles() {
|
| - if (mSelectionHandleController != null) {
|
| - mSelectionHandleController.hideAndDisallowAutomaticShowing();
|
| - }
|
| - if (mInsertionHandleController != null) {
|
| - mInsertionHandleController.hideAndDisallowAutomaticShowing();
|
| - }
|
| - mPositionObserver.removeListener(mPositionListener);
|
| - }
|
| -
|
| private void showSelectActionBar() {
|
| if (mActionMode != null) {
|
| mActionMode.invalidate();
|
| @@ -2171,6 +2045,64 @@ public class ContentViewCore
|
| }
|
| }
|
|
|
| + private void hidePastePopup() {
|
| + if (mPastePopupMenu == null) return;
|
| + mPastePopupMenu.hide();
|
| + }
|
| +
|
| + @CalledByNative
|
| + private void onSelectionEvent(int eventType, float anchorXDip, float anchorYDip) {
|
| + boolean shouldShowPastePopup = false;
|
| + switch (eventType) {
|
| + case SelectionEventType.SELECTION_SHOWN:
|
| + mHasSelection = true;
|
| + // TODO(cjhopman): Remove this when there is a better signal that long press caused
|
| + // a selection. See http://crbug.com/150151.
|
| + mContainerView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
| + showSelectActionBar();
|
| + break;
|
| +
|
| + case SelectionEventType.SELECTION_CLEARED:
|
| + mHasSelection = false;
|
| + mUnselectAllOnActionModeDismiss = false;
|
| + hideSelectActionBar();
|
| + break;
|
| +
|
| + case SelectionEventType.INSERTION_SHOWN:
|
| + mHasInsertion = true;
|
| + shouldShowPastePopup = true;
|
| + break;
|
| +
|
| + case SelectionEventType.INSERTION_MOVED:
|
| + // TODO(jdduke): Handle case where movement triggered by focus.
|
| + hidePastePopup();
|
| + break;
|
| +
|
| + case SelectionEventType.INSERTION_TAPPED:
|
| + if (getPastePopup().isShowing()) {
|
| + mPastePopupMenu.hide();
|
| + } else {
|
| + mPastePopupMenu.allowAutomaticShowing();
|
| + shouldShowPastePopup = true;
|
| + }
|
| + break;
|
| +
|
| + case SelectionEventType.INSERTION_CLEARED:
|
| + mHasInsertion = false;
|
| + hidePastePopup();
|
| + break;
|
| +
|
| + default:
|
| + assert false : "Invalid selection event type.";
|
| + }
|
| + if (shouldShowPastePopup) {
|
| + final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix();
|
| + getPastePopup().showAt(
|
| + (int) mRenderCoordinates.fromDipToPix(anchorXDip),
|
| + (int) (mRenderCoordinates.fromDipToPix(anchorYDip) + contentOffsetYPix));
|
| + }
|
| + }
|
| +
|
| public boolean getUseDesktopUserAgent() {
|
| if (mNativeContentViewCore != 0) {
|
| return nativeGetUseDesktopUserAgent(mNativeContentViewCore);
|
| @@ -2193,59 +2125,10 @@ public class ContentViewCore
|
| if (mNativeContentViewCore != 0) nativeClearSslPreferences(mNativeContentViewCore);
|
| }
|
|
|
| - private boolean isSelectionHandleShowing() {
|
| - return mSelectionHandleController != null && mSelectionHandleController.isShowing();
|
| - }
|
| -
|
| - private boolean isInsertionHandleShowing() {
|
| - return mInsertionHandleController != null && mInsertionHandleController.isShowing();
|
| - }
|
| -
|
| - // Makes the insertion/selection handles invisible. They will fade back in shortly after the
|
| - // last call to scheduleTextHandleFadeIn (or temporarilyHideTextHandles).
|
| - private void temporarilyHideTextHandles() {
|
| - if (isSelectionHandleShowing() && !mSelectionHandleController.isDragging()) {
|
| - mSelectionHandleController.setHandleVisibility(HandleView.INVISIBLE);
|
| - }
|
| - if (isInsertionHandleShowing() && !mInsertionHandleController.isDragging()) {
|
| - mInsertionHandleController.setHandleVisibility(HandleView.INVISIBLE);
|
| - }
|
| - scheduleTextHandleFadeIn();
|
| - }
|
| -
|
| - private boolean allowTextHandleFadeIn() {
|
| - if (mTouchScrollInProgress) return false;
|
| -
|
| - if (mPopupZoomer.isShowing()) return false;
|
| -
|
| - return true;
|
| - }
|
| -
|
| - // Cancels any pending fade in and schedules a new one.
|
| - private void scheduleTextHandleFadeIn() {
|
| - if (!isInsertionHandleShowing() && !isSelectionHandleShowing()) return;
|
| -
|
| - if (mDeferredHandleFadeInRunnable == null) {
|
| - mDeferredHandleFadeInRunnable = new Runnable() {
|
| - @Override
|
| - public void run() {
|
| - if (!allowTextHandleFadeIn()) {
|
| - // Delay fade in until it is allowed.
|
| - scheduleTextHandleFadeIn();
|
| - } else {
|
| - if (isSelectionHandleShowing()) {
|
| - mSelectionHandleController.beginHandleFadeIn();
|
| - }
|
| - if (isInsertionHandleShowing()) {
|
| - mInsertionHandleController.beginHandleFadeIn();
|
| - }
|
| - }
|
| - }
|
| - };
|
| - }
|
| -
|
| - mContainerView.removeCallbacks(mDeferredHandleFadeInRunnable);
|
| - mContainerView.postDelayed(mDeferredHandleFadeInRunnable, TEXT_HANDLE_FADE_IN_DELAY);
|
| + private void hideTextHandles() {
|
| + mHasSelection = false;
|
| + mHasInsertion = false;
|
| + if (mNativeContentViewCore != 0) nativeHideTextHandles(mNativeContentViewCore);
|
| }
|
|
|
| /**
|
| @@ -2309,7 +2192,6 @@ public class ContentViewCore
|
|
|
| final boolean needHidePopupZoomer = contentSizeChanged || scrollChanged;
|
| final boolean needUpdateZoomControls = scaleLimitsChanged || scrollChanged;
|
| - final boolean needTemporarilyHideHandles = scrollChanged;
|
|
|
| if (needHidePopupZoomer) mPopupZoomer.hide(true);
|
|
|
| @@ -2337,9 +2219,7 @@ public class ContentViewCore
|
| }
|
| }
|
|
|
| - if (needTemporarilyHideHandles) temporarilyHideTextHandles();
|
| if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls();
|
| - if (contentOffsetChanged) updateHandleScreenPositions();
|
|
|
| // Update offsets for fullscreen.
|
| final float controlsOffsetPix = controlsOffsetYCss * deviceScale;
|
| @@ -2359,6 +2239,7 @@ public class ContentViewCore
|
| boolean isNonImeChange) {
|
| TraceEvent.begin();
|
| mSelectionEditable = (textInputType != ImeAdapter.getTextInputTypeNone());
|
| + if (!mSelectionEditable) hidePastePopup();
|
|
|
| mImeAdapter.updateKeyboardVisibility(
|
| nativeImeAdapterAndroid, textInputType, showImeIfNeeded);
|
| @@ -2428,7 +2309,6 @@ public class ContentViewCore
|
| private void showDisambiguationPopup(Rect targetRect, Bitmap zoomedBitmap) {
|
| mPopupZoomer.setBitmap(zoomedBitmap);
|
| mPopupZoomer.show(targetRect);
|
| - temporarilyHideTextHandles();
|
| }
|
|
|
| @SuppressWarnings("unused")
|
| @@ -2439,72 +2319,25 @@ public class ContentViewCore
|
|
|
| @SuppressWarnings("unused")
|
| @CalledByNative
|
| - private void onSelectionChanged(String text) {
|
| - mLastSelectedText = text;
|
| - getContentViewClient().onSelectionChanged(text);
|
| - }
|
| -
|
| - @SuppressWarnings("unused")
|
| - @CalledByNative
|
| - private void showSelectionHandlesAutomatically() {
|
| - getSelectionHandleController().allowAutomaticShowing();
|
| + private PopupTouchHandleDrawable createPopupTouchHandleDrawable() {
|
| + if (mTouchHandleDelegate == null) {
|
| + mTouchHandleDelegate = new PopupTouchHandleDrawableDelegate() {
|
| + public boolean onTouchHandleEvent(MotionEvent event) {
|
| + if (mNativeContentViewCore == 0) return false;
|
| + if (!isValidTouchEventActionForNative(event.getActionMasked())) return false;
|
| + return nativeOnTouchHandleEvent(mNativeContentViewCore, event);
|
| + }
|
| + };
|
| + }
|
| + return new PopupTouchHandleDrawable(
|
| + mTouchHandleDelegate, getContainerView(), mPositionObserver);
|
| }
|
|
|
| @SuppressWarnings("unused")
|
| @CalledByNative
|
| - private void onSelectionBoundsChanged(
|
| - float anchorXDip, float anchorYDip, float focusXDip, float focusYDip,
|
| - int anchorDir, int focusDir,
|
| - boolean isAnchorVisible, boolean isFocusVisible) {
|
| - // TODO(jdduke): Use |is{Anchor,Focus}Visible|, as well as the action
|
| - // bar height, to set handle visibility, see crbug.com/164819.
|
| - if (focusXDip != anchorXDip || focusYDip != anchorYDip ||
|
| - (mSelectionHandleController != null && mSelectionHandleController.isDragging())) {
|
| - if (mInsertionHandleController != null) {
|
| - mInsertionHandleController.hide();
|
| - }
|
| - mStartHandlePoint.setLocalDip(anchorXDip, anchorYDip);
|
| - mEndHandlePoint.setLocalDip(focusXDip, focusYDip);
|
| -
|
| - boolean wereSelectionHandlesShowing = getSelectionHandleController().isShowing();
|
| -
|
| - getSelectionHandleController().onSelectionChanged(anchorDir, focusDir);
|
| - updateHandleScreenPositions();
|
| - mHasSelection = true;
|
| -
|
| - if (!wereSelectionHandlesShowing && getSelectionHandleController().isShowing()) {
|
| - // TODO(cjhopman): Remove this when there is a better signal that long press caused
|
| - // a selection. See http://crbug.com/150151.
|
| - mContainerView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
| - }
|
| -
|
| - } else {
|
| - mUnselectAllOnActionModeDismiss = false;
|
| - hideSelectActionBar();
|
| - if (anchorXDip != 0 && anchorYDip != 0 && mSelectionEditable) {
|
| - // Selection is a caret, and a text field is focused.
|
| - if (mSelectionHandleController != null) {
|
| - mSelectionHandleController.hide();
|
| - }
|
| - mInsertionHandlePoint.setLocalDip(anchorXDip, anchorYDip);
|
| -
|
| - getInsertionHandleController().onCursorPositionChanged();
|
| - updateHandleScreenPositions();
|
| - if (mInputMethodManagerWrapper.isWatchingCursor(mContainerView)) {
|
| - final int xPix = (int) mInsertionHandlePoint.getXPix();
|
| - final int yPix = (int) mInsertionHandlePoint.getYPix();
|
| - mInputMethodManagerWrapper.updateCursor(
|
| - mContainerView, xPix, yPix, xPix, yPix);
|
| - }
|
| - } else {
|
| - // Deselection
|
| - hideHandles();
|
| - }
|
| - mHasSelection = false;
|
| - }
|
| - if (isSelectionHandleShowing() || isInsertionHandleShowing()) {
|
| - mPositionObserver.addListener(mPositionListener);
|
| - }
|
| + private void onSelectionChanged(String text) {
|
| + mLastSelectedText = text;
|
| + getContentViewClient().onSelectionChanged(text);
|
| }
|
|
|
| @SuppressWarnings("unused")
|
| @@ -2517,10 +2350,36 @@ public class ContentViewCore
|
| @SuppressWarnings("unused")
|
| @CalledByNative
|
| private void showPastePopup(int xDip, int yDip) {
|
| - mInsertionHandlePoint.setLocalDip(xDip, yDip);
|
| - getInsertionHandleController().showHandle();
|
| - updateHandleScreenPositions();
|
| - getInsertionHandleController().showHandleWithPastePopup();
|
| + /*
|
| + if (mPastePopupMenu == null) {
|
| + mPastePopupMenu = new PastePopupMenu(getContainerView(),
|
| + new PastePopupMenuDelegate() {
|
| + public void paste() {
|
| + mImeAdapter.paste();
|
| + }
|
| + });
|
| + }
|
| + final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix();
|
| + mPastePopupMenu.showAt((int) mRenderCoordinates.fromDipToPix(xDip),
|
| + (int) (mRenderCoordinates.fromDipToPix(yDip) + contentOffsetYPix));
|
| + */
|
| + }
|
| +
|
| + private PastePopupMenu getPastePopup() {
|
| + if (mPastePopupMenu == null) {
|
| + mPastePopupMenu = new PastePopupMenu(getContainerView(),
|
| + new PastePopupMenuDelegate() {
|
| + public void paste() {
|
| + mImeAdapter.paste();
|
| + }
|
| + public boolean canPaste() {
|
| + if (!mSelectionEditable) return false;
|
| + return ((ClipboardManager) mContext.getSystemService(
|
| + Context.CLIPBOARD_SERVICE)).hasPrimaryClip();
|
| + }
|
| + });
|
| + }
|
| + return mPastePopupMenu;
|
| }
|
|
|
| @SuppressWarnings("unused")
|
| @@ -3188,6 +3047,9 @@ public class ContentViewCore
|
| float rawX, float rawY,
|
| int androidToolType0, int androidToolType1, int androidButtonState);
|
|
|
| + private native boolean nativeOnTouchHandleEvent(
|
| + long nativeContentViewCoreImpl, MotionEvent event);
|
| +
|
| private native int nativeSendMouseMoveEvent(
|
| long nativeContentViewCoreImpl, long timeMs, float x, float y);
|
|
|
| @@ -3231,6 +3093,8 @@ public class ContentViewCore
|
|
|
| private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y);
|
|
|
| + private native void nativeHideTextHandles(long nativeContentViewCoreImpl);
|
| +
|
| private native void nativeResetGestureDetection(long nativeContentViewCoreImpl);
|
| private native void nativeSetDoubleTapSupportEnabled(
|
| long nativeContentViewCoreImpl, boolean enabled);
|
|
|