Chromium Code Reviews| 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 b0e1e037e500feffe28500b4e0171819d5bbfdee..9dd2f6421d7584f9ca77ad11533235cbef3dea3d 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,13 +7,9 @@ package org.chromium.content.browser; |
| import android.annotation.SuppressLint; |
| import android.annotation.TargetApi; |
| import android.app.Activity; |
| -import android.app.SearchManager; |
| import android.app.assist.AssistStructure.ViewNode; |
| -import android.content.ClipboardManager; |
| -import android.content.ContentResolver; |
| import android.content.Context; |
| import android.content.Intent; |
| -import android.content.pm.PackageManager; |
| import android.content.res.Configuration; |
| import android.graphics.Bitmap; |
| import android.graphics.Rect; |
| @@ -22,11 +18,8 @@ import android.os.Bundle; |
| import android.os.Handler; |
| import android.os.ResultReceiver; |
| import android.os.SystemClock; |
| -import android.provider.Browser; |
| -import android.text.TextUtils; |
| import android.util.Pair; |
| import android.util.TypedValue; |
| -import android.view.ActionMode; |
| import android.view.HapticFeedbackConstants; |
| import android.view.InputDevice; |
| import android.view.KeyEvent; |
| @@ -34,7 +27,6 @@ import android.view.MotionEvent; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.view.ViewStructure; |
| -import android.view.WindowManager; |
| import android.view.accessibility.AccessibilityEvent; |
| import android.view.accessibility.AccessibilityManager; |
| import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; |
| @@ -54,23 +46,17 @@ import org.chromium.base.TraceEvent; |
| 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.ScreenOrientationListener.ScreenOrientationObserver; |
| import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; |
| import org.chromium.content.browser.accessibility.captioning.CaptioningBridgeFactory; |
| import org.chromium.content.browser.accessibility.captioning.SystemCaptioningBridge; |
| import org.chromium.content.browser.accessibility.captioning.TextTrackSettings; |
| import org.chromium.content.browser.input.AnimationIntervalProvider; |
| -import org.chromium.content.browser.input.FloatingPastePopupMenu; |
| import org.chromium.content.browser.input.GamepadList; |
| import org.chromium.content.browser.input.ImeAdapter; |
| import org.chromium.content.browser.input.InputMethodManagerWrapper; |
| import org.chromium.content.browser.input.JoystickScrollProvider; |
| import org.chromium.content.browser.input.JoystickZoomProvider; |
| -import org.chromium.content.browser.input.LegacyPastePopupMenu; |
| -import org.chromium.content.browser.input.PastePopupMenu; |
| -import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; |
| import org.chromium.content.browser.input.SelectPopup; |
| import org.chromium.content.browser.input.SelectPopupDialog; |
| import org.chromium.content.browser.input.SelectPopupDropdown; |
| @@ -86,7 +72,6 @@ import org.chromium.ui.base.ViewAndroidDelegate; |
| import org.chromium.ui.base.WindowAndroid; |
| import org.chromium.ui.base.ime.TextInputType; |
| import org.chromium.ui.gfx.DeviceDisplayInfo; |
| -import org.chromium.ui.touch_selection.SelectionEventType; |
| import java.lang.annotation.Annotation; |
| import java.lang.ref.WeakReference; |
| @@ -490,11 +475,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| // Only valid when focused on a text / password field. |
| private ImeAdapter mImeAdapter; |
| - // Lazily created paste popup menu, triggered either via long press in an |
| - // editable region or from tapping the insertion handle. |
| - private PastePopupMenu mPastePopupMenu; |
| - private boolean mWasPastePopupShowingOnInsertionDragStart; |
| - |
| // Size of the viewport in physical pixels as set from onSizeChanged. |
| private int mViewportWidthPix; |
| private int mViewportHeightPix; |
| @@ -514,20 +494,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| private boolean mIsMobileOptimizedHint; |
| - // 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 boolean mDraggingSelection; |
| private String mLastSelectedText; |
| private boolean mFocusedNodeEditable; |
| - private boolean mFocusedNodeIsPassword; |
| - private WebActionMode mActionMode; |
| - private boolean mFloatingActionModeCreationFailed; |
| - private boolean mUnselectAllOnActionModeDismiss; |
| private boolean mPreserveSelectionOnNextLossOfFocus; |
| - private WebActionModeCallback.ActionHandler mActionHandler; |
| - private final Rect mSelectionRect = new Rect(); |
| + private boolean mUnselectAllOnActionModeDismiss; |
| // Delegate that will handle GET downloads, and be notified of completion of POST downloads. |
| private ContentViewDownloadDelegate mDownloadDelegate; |
| @@ -827,7 +797,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| // TODO(yusufo): Rename this call to be general for tab reparenting. |
| // Clean up cached popups that may have been created with an old activity. |
| mSelectPopup = null; |
| - mPastePopupMenu = null; |
| } |
| @VisibleForTesting |
| @@ -858,7 +827,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| TraceEvent.begin("ContentViewCore.setContainerView"); |
| if (mContainerView != null) { |
| assert mOverscrollRefreshHandler == null; |
| - mPastePopupMenu = null; |
| hidePopupsAndClearSelection(); |
| } |
| @@ -998,7 +966,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| ScreenOrientationListener.getInstance().removeObserver(this); |
| mContainerViewObservers.clear(); |
| hidePopupsAndPreserveSelection(); |
| - mPastePopupMenu = null; |
| // See warning in javadoc before adding more clean up code here. |
| } |
| @@ -1134,14 +1101,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| */ |
| @VisibleForTesting |
| public String getSelectedText() { |
| - return mHasSelection ? mLastSelectedText : ""; |
| - } |
| - |
| - /** |
| - * @return Whether the current selection is editable (false if no text selected). |
| - */ |
| - public boolean isSelectionEditable() { |
| - return mHasSelection ? mFocusedNodeEditable : false; |
| + return mLastSelectedText; |
| } |
| /** |
| @@ -1268,7 +1228,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| private void setTouchScrollInProgress(boolean inProgress) { |
| if (mTouchScrollInProgress == inProgress) return; |
| mTouchScrollInProgress = inProgress; |
| - updateActionModeVisibility(); |
| } |
| @SuppressWarnings("unused") |
| @@ -1293,7 +1252,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| @CalledByNative |
| private void onScrollBeginEventAck() { |
| setTouchScrollInProgress(true); |
| - hidePastePopup(); |
| mZoomControlsDelegate.invokeZoomPicker(); |
| updateGestureStateListener(GestureEventType.SCROLL_START); |
| } |
| @@ -1334,7 +1292,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| mGestureStateListenersIterator.hasNext();) { |
| mGestureStateListenersIterator.next().onSingleTap(consumed, x, y); |
| } |
| - hidePastePopup(); |
| } |
| @SuppressWarnings("unused") |
| @@ -1441,7 +1398,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| assert mWebContents != null; |
| mWebContents.onShow(); |
| setAccessibilityState(mAccessibilityManager.isEnabled()); |
| - restoreSelectionPopupsIfNecessary(); |
| } |
| /** |
| @@ -1472,28 +1428,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| } |
| private void hidePopups() { |
| - hideSelectActionMode(); |
| - hidePastePopup(); |
| hideSelectPopupWithCancelMesage(); |
| mPopupZoomer.hide(false); |
| if (mUnselectAllOnActionModeDismiss) dismissTextHandles(); |
| } |
| - private void restoreSelectionPopupsIfNecessary() { |
| - if (mHasSelection && mActionMode == null) showSelectActionMode(true); |
| - } |
| - |
| - public void hideSelectActionMode() { |
| - if (mActionMode != null) { |
| - mActionMode.finish(); |
| - mActionMode = null; |
| - } |
| - } |
| - |
| - public boolean isSelectActionBarShowing() { |
| - return mActionMode != null; |
| - } |
| - |
| private void resetGestureDetection() { |
| if (mNativeContentViewCore == 0) return; |
| nativeResetGestureDetection(mNativeContentViewCore); |
| @@ -1522,9 +1461,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| */ |
| public void updateTextSelectionUI(boolean focused) { |
| setTextHandlesTemporarilyHidden(!focused); |
| - if (focused) { |
| - restoreSelectionPopupsIfNecessary(); |
| - } else { |
| + if (!focused) { |
| hidePopupsAndPreserveSelection(); |
| } |
| } |
| @@ -1651,7 +1588,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| */ |
| public void onWindowFocusChanged(boolean hasWindowFocus) { |
| if (!hasWindowFocus) resetGestureDetection(); |
| - if (mActionMode != null) mActionMode.onWindowFocusChanged(hasWindowFocus); |
| for (mGestureStateListenersIterator.rewind(); mGestureStateListenersIterator.hasNext();) { |
| mGestureStateListenersIterator.next().onWindowFocusChanged(hasWindowFocus); |
| } |
| @@ -1661,9 +1597,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| mImeAdapter.onViewFocusChanged(gainFocus); |
| mJoystickScrollProvider.setEnabled(gainFocus && !mFocusedNodeEditable); |
| - if (gainFocus) { |
| - restoreSelectionPopupsIfNecessary(); |
| - } else { |
| + if (!gainFocus) { |
| cancelRequestToScrollFocusedEditableNodeIntoView(); |
| if (mPreserveSelectionOnNextLossOfFocus) { |
| mPreserveSelectionOnNextLossOfFocus = false; |
| @@ -1990,264 +1924,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| return mDownloadDelegate; |
| } |
| - @VisibleForTesting |
| - public WebActionModeCallback.ActionHandler getSelectActionHandler() { |
| - return mActionHandler; |
| - } |
| - |
| - private void showSelectActionMode(boolean allowFallbackIfFloatingActionModeCreationFails) { |
| - if (mActionMode != null) { |
| - mActionMode.invalidate(); |
| - return; |
| - } |
| - |
| - // Start a new action mode with a WebActionModeCallback. |
| - if (mActionHandler == null) { |
| - mActionHandler = new WebActionModeCallback.ActionHandler() { |
| - /** |
| - * Android Intent size limitations prevent sending over a megabyte of data. Limit |
| - * query lengths to 100kB because other things may be added to the Intent. |
| - */ |
| - private static final int MAX_SHARE_QUERY_LENGTH = 100000; |
| - |
| - /** Google search doesn't support requests slightly larger than this. */ |
| - private static final int MAX_SEARCH_QUERY_LENGTH = 1000; |
| - |
| - // All WebContents actions record a user action internally. |
| - @Override |
| - public void selectAll() { |
| - mWebContents.selectAll(); |
| - // 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 (isFocusedNodeEditable()) { |
| - RecordUserAction.record("MobileActionMode.SelectAllWasEditable"); |
| - } else { |
| - RecordUserAction.record("MobileActionMode.SelectAllWasNonEditable"); |
| - } |
| - } |
| - |
| - @Override |
| - public void cut() { |
| - mWebContents.cut(); |
| - } |
| - |
| - @Override |
| - public void copy() { |
| - mWebContents.copy(); |
| - } |
| - |
| - @Override |
| - public void paste() { |
| - mWebContents.paste(); |
| - } |
| - |
| - @Override |
| - public void share() { |
| - RecordUserAction.record("MobileActionMode.Share"); |
| - final String query = sanitizeQuery(getSelectedText(), MAX_SHARE_QUERY_LENGTH); |
| - if (TextUtils.isEmpty(query)) return; |
| - |
| - Intent send = new Intent(Intent.ACTION_SEND); |
| - send.setType("text/plain"); |
| - send.putExtra(Intent.EXTRA_TEXT, query); |
| - try { |
| - Intent i = Intent.createChooser(send, getContext().getString( |
| - R.string.actionbar_share)); |
| - i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| - getContext().startActivity(i); |
| - } catch (android.content.ActivityNotFoundException ex) { |
| - // If no app handles it, do nothing. |
| - } |
| - } |
| - |
| - @Override |
| - public void processText(Intent intent) { |
| - RecordUserAction.record("MobileActionMode.ProcessTextIntent"); |
| - assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; |
| - |
| - final String query = sanitizeQuery(getSelectedText(), MAX_SEARCH_QUERY_LENGTH); |
| - if (TextUtils.isEmpty(query)) return; |
| - |
| - intent.putExtra(Intent.EXTRA_PROCESS_TEXT, query); |
| - try { |
| - if (getContentViewClient().doesPerformProcessText()) { |
| - getContentViewClient().startProcessTextIntent(intent); |
| - } else { |
| - getWindowAndroid().showIntent( |
| - intent, new WindowAndroid.IntentCallback() { |
| - @Override |
| - public void onIntentCompleted(WindowAndroid window, |
| - int resultCode, ContentResolver contentResolver, |
| - Intent data) { |
| - onReceivedProcessTextResult(resultCode, data); |
| - } |
| - }, null); |
| - } |
| - } catch (android.content.ActivityNotFoundException ex) { |
| - // If no app handles it, do nothing. |
| - } |
| - } |
| - |
| - @Override |
| - public void search() { |
| - RecordUserAction.record("MobileActionMode.WebSearch"); |
| - final String query = sanitizeQuery(getSelectedText(), MAX_SEARCH_QUERY_LENGTH); |
| - if (TextUtils.isEmpty(query)) return; |
| - |
| - // See if ContentViewClient wants to override. |
| - if (getContentViewClient().doesPerformWebSearch()) { |
| - getContentViewClient().performWebSearch(query); |
| - return; |
| - } |
| - |
| - Intent i = new Intent(Intent.ACTION_WEB_SEARCH); |
| - i.putExtra(SearchManager.EXTRA_NEW_SEARCH, true); |
| - i.putExtra(SearchManager.QUERY, query); |
| - i.putExtra(Browser.EXTRA_APPLICATION_ID, getContext().getPackageName()); |
| - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| - try { |
| - getContext().startActivity(i); |
| - } catch (android.content.ActivityNotFoundException ex) { |
| - // If no app handles it, do nothing. |
| - } |
| - } |
| - |
| - @Override |
| - public boolean isSelectionPassword() { |
| - return mFocusedNodeIsPassword; |
| - } |
| - |
| - @Override |
| - public boolean isSelectionEditable() { |
| - return mFocusedNodeEditable; |
| - } |
| - |
| - @Override |
| - public boolean isInsertion() { |
| - return mHasInsertion; |
| - } |
| - |
| - @Override |
| - public void onDestroyActionMode() { |
| - mActionMode = null; |
| - if (mUnselectAllOnActionModeDismiss) { |
| - dismissTextHandles(); |
| - clearSelection(); |
| - } |
| - if (!supportsFloatingActionMode()) { |
| - getContentViewClient().onContextualActionBarHidden(); |
| - } |
| - } |
| - |
| - @Override |
| - public void onGetContentRect(Rect outRect) { |
| - // The selection coordinates are relative to the content viewport, but we need |
| - // coordinates relative to the containing View. |
| - outRect.set(mSelectionRect); |
| - outRect.offset(0, (int) mRenderCoordinates.getContentOffsetYPix()); |
| - } |
| - |
| - @Override |
| - public boolean isIncognito() { |
| - return mWebContents.isIncognito(); |
| - } |
| - |
| - @Override |
| - public boolean isSelectActionModeAllowed(int actionModeItem) { |
| - boolean isAllowedByClient = |
| - getContentViewClient().isSelectActionModeAllowed(actionModeItem); |
| - if (actionModeItem == WebActionModeCallback.MENU_ITEM_SHARE) { |
| - return isAllowedByClient && isShareAvailable(); |
| - } |
| - |
| - if (actionModeItem == WebActionModeCallback.MENU_ITEM_WEB_SEARCH) { |
| - return isAllowedByClient && isWebSearchAvailable(); |
| - } |
| - |
| - return isAllowedByClient; |
| - } |
| - |
| - private boolean isShareAvailable() { |
| - Intent intent = new Intent(Intent.ACTION_SEND); |
| - intent.setType("text/plain"); |
| - return getContext().getPackageManager().queryIntentActivities(intent, |
| - PackageManager.MATCH_DEFAULT_ONLY).size() > 0; |
| - } |
| - |
| - private boolean isWebSearchAvailable() { |
| - if (getContentViewClient().doesPerformWebSearch()) return true; |
| - Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); |
| - intent.putExtra(SearchManager.EXTRA_NEW_SEARCH, true); |
| - return getContext().getPackageManager().queryIntentActivities(intent, |
| - PackageManager.MATCH_DEFAULT_ONLY).size() > 0; |
| - } |
| - |
| - private String sanitizeQuery(String query, int maxLength) { |
| - if (TextUtils.isEmpty(query) || query.length() < maxLength) return query; |
| - Log.w(TAG, "Truncating oversized query (" + query.length() + ")."); |
| - return query.substring(0, maxLength) + "…"; |
| - } |
| - }; |
| - } |
| - mActionMode = null; |
| - // On ICS, startActionMode throws an NPE when getParent() is null. |
| - if (mContainerView.getParent() != null) { |
| - assert mWebContents != null; |
| - ActionMode actionMode = startActionMode(allowFallbackIfFloatingActionModeCreationFails); |
| - if (actionMode != null) mActionMode = new WebActionMode(actionMode, mContainerView); |
| - } |
| - mUnselectAllOnActionModeDismiss = true; |
| - if (mActionMode == null) { |
| - // There is no ActionMode, so remove the selection. |
| - clearSelection(); |
| - } else { |
| - // TODO(jdduke): Refactor ContentViewClient.onContextualActionBarShown to be aware of |
| - // non-action-bar (i.e., floating) ActionMode instances, crbug.com/524666. |
| - if (!supportsFloatingActionMode()) { |
| - getContentViewClient().onContextualActionBarShown(); |
| - } |
| - } |
| - } |
| - |
| - private boolean supportsFloatingActionMode() { |
| - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false; |
| - return !mFloatingActionModeCreationFailed; |
| - } |
| - |
| - private ActionMode startActionMode(boolean allowFallbackIfFloatingActionModeCreationFails) { |
| - WebActionModeCallback callback = |
| - new WebActionModeCallback(mContainerView.getContext(), mActionHandler); |
| - if (supportsFloatingActionMode()) { |
| - ActionMode actionMode = startFloatingActionMode(callback); |
| - if (actionMode != null) return actionMode; |
| - mFloatingActionModeCreationFailed = true; |
| - if (!allowFallbackIfFloatingActionModeCreationFails) return null; |
| - } |
| - return startDefaultActionMode(callback); |
| - } |
| - |
| - private ActionMode startDefaultActionMode(WebActionModeCallback callback) { |
| - return mContainerView.startActionMode(callback); |
| - } |
| - |
| - @TargetApi(Build.VERSION_CODES.M) |
| - private ActionMode startFloatingActionMode(WebActionModeCallback callback) { |
| - ActionMode.Callback2 callback2 = new FloatingWebActionModeCallback(callback); |
| - return mContainerView.startActionMode(callback2, ActionMode.TYPE_FLOATING); |
| - } |
| - |
| - private void invalidateActionModeContentRect() { |
| - if (mActionMode != null) mActionMode.invalidateContentRect(); |
| - } |
| - |
| - private void updateActionModeVisibility() { |
| - if (mActionMode == null) return; |
| - // The active fling count isn't reliable with WebView, so only use the |
| - // active touch scroll signal for hiding. The fling animation movement |
| - // will naturally hide the ActionMode by invalidating its content rect. |
| - mActionMode.hide(mDraggingSelection || mTouchScrollInProgress); |
| - } |
| - |
| /** |
| * Clears the current text selection. Note that we will try to move cursor to selection |
| * end if applicable. |
| @@ -2268,107 +1944,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| mPreserveSelectionOnNextLossOfFocus = true; |
| } |
| - /** |
| - * @return Whether the page has an active, touch-controlled selection region. |
| - */ |
| - @VisibleForTesting |
| - public boolean hasSelection() { |
| - return mHasSelection; |
| - } |
| - |
| - /** |
| - * @return Whether the page has an active, touch-controlled insertion handle. |
| - */ |
| - @VisibleForTesting |
| - public boolean hasInsertion() { |
| - return mHasInsertion; |
| - } |
| - |
| @CalledByNative |
| private void onSelectionEvent( |
| - int eventType, int xAnchor, int yAnchor, int left, int top, int right, int bottom) { |
| + int eventType, int xAnchor, int yAnchor) { |
| // Ensure the provided selection coordinates form a non-empty rect, as required by |
| // the selection action mode. |
| - if (left == right) ++right; |
| - if (top == bottom) ++bottom; |
| - switch (eventType) { |
| - case SelectionEventType.SELECTION_HANDLES_SHOWN: |
| - mSelectionRect.set(left, top, right, bottom); |
| - mHasSelection = true; |
| - mUnselectAllOnActionModeDismiss = true; |
| - showSelectActionMode(true); |
| - break; |
| - |
| - case SelectionEventType.SELECTION_HANDLES_MOVED: |
| - mSelectionRect.set(left, top, right, bottom); |
| - invalidateActionModeContentRect(); |
| - break; |
| - |
| - case SelectionEventType.SELECTION_HANDLES_CLEARED: |
| - mHasSelection = false; |
| - mDraggingSelection = false; |
| - mUnselectAllOnActionModeDismiss = false; |
| - hideSelectActionMode(); |
| - mSelectionRect.setEmpty(); |
| - break; |
| - |
| - case SelectionEventType.SELECTION_HANDLE_DRAG_STARTED: |
| - mDraggingSelection = true; |
| - updateActionModeVisibility(); |
| - break; |
| - |
| - case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED: |
| - mDraggingSelection = false; |
| - updateActionModeVisibility(); |
| - break; |
| - |
| - case SelectionEventType.INSERTION_HANDLE_SHOWN: |
| - mSelectionRect.set(left, top, right, bottom); |
| - mHasInsertion = true; |
| - break; |
| - |
| - case SelectionEventType.INSERTION_HANDLE_MOVED: |
| - mSelectionRect.set(left, top, right, bottom); |
| - if (!isScrollInProgress() && isPastePopupShowing()) { |
| - showPastePopup(xAnchor, yAnchor); |
| - } else { |
| - hidePastePopup(); |
| - } |
| - break; |
| - |
| - case SelectionEventType.INSERTION_HANDLE_TAPPED: |
| - if (mWasPastePopupShowingOnInsertionDragStart) { |
| - hidePastePopup(); |
| - } else { |
| - showPastePopup(xAnchor, yAnchor); |
| - } |
| - mWasPastePopupShowingOnInsertionDragStart = false; |
| - break; |
| - |
| - case SelectionEventType.INSERTION_HANDLE_CLEARED: |
| - hidePastePopup(); |
| - mHasInsertion = false; |
| - mSelectionRect.setEmpty(); |
| - break; |
| - |
| - case SelectionEventType.INSERTION_HANDLE_DRAG_STARTED: |
| - mWasPastePopupShowingOnInsertionDragStart = isPastePopupShowing(); |
| - hidePastePopup(); |
| - break; |
| - |
| - case SelectionEventType.INSERTION_HANDLE_DRAG_STOPPED: |
| - if (mWasPastePopupShowingOnInsertionDragStart) { |
| - showPastePopup(xAnchor, yAnchor); |
| - } |
| - mWasPastePopupShowingOnInsertionDragStart = false; |
| - break; |
| - case SelectionEventType.SELECTION_ESTABLISHED: |
| - case SelectionEventType.SELECTION_DISSOLVED: |
| - break; |
| - |
| - default: |
| - assert false : "Invalid selection event type."; |
| - } |
| if (mContextualSearchClient != null) { |
| mContextualSearchClient.onSelectionEvent(eventType, xAnchor, yAnchor); |
| } |
| @@ -2478,7 +2058,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| TraceEvent.begin("ContentViewCore.updateImeAdapter"); |
| boolean focusedNodeEditable = (textInputType != TextInputType.NONE); |
| boolean focusedNodeIsPassword = (textInputType == TextInputType.PASSWORD); |
| - if (!focusedNodeEditable) hidePastePopup(); |
| mImeAdapter.attach(nativeImeAdapterAndroid); |
| mImeAdapter.updateKeyboardVisibility( |
| @@ -2486,14 +2065,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| mImeAdapter.updateState(text, selectionStart, selectionEnd, compositionStart, |
| compositionEnd, isNonImeChange); |
| - if (mActionMode != null) { |
| - final boolean actionModeConfigurationChanged = |
| - focusedNodeEditable != mFocusedNodeEditable |
| - || focusedNodeIsPassword != mFocusedNodeIsPassword; |
| - if (actionModeConfigurationChanged) mActionMode.invalidate(); |
| - } |
| - |
| - mFocusedNodeIsPassword = focusedNodeIsPassword; |
| if (focusedNodeEditable != mFocusedNodeEditable) { |
| mFocusedNodeEditable = focusedNodeEditable; |
| mJoystickScrollProvider.setEnabled(!mFocusedNodeEditable); |
| @@ -2640,80 +2211,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| @SuppressWarnings("unused") |
| @CalledByNative |
| - private boolean showPastePopupWithFeedback(int x, int y) { |
| - if (showPastePopup(x, y)) { |
| - if (mWebContents != null) mWebContents.onContextMenuOpened(); |
| - return true; |
| - } else { |
| - return false; |
| - } |
| - } |
| - |
| - @SuppressWarnings("unused") |
| - @CalledByNative |
| private void performLongPressHapticFeedback() { |
| mContainerView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); |
| } |
| - @VisibleForTesting |
| - public boolean isPastePopupShowing() { |
| - if (mPastePopupMenu != null) return mPastePopupMenu.isShowing(); |
| - return false; |
| - } |
| - |
| - private boolean showPastePopup(int x, int y) { |
| - if (mContainerView.getParent() == null || mContainerView.getVisibility() != View.VISIBLE) { |
| - return false; |
| - } |
| - |
| - if (!mHasInsertion || !canPaste()) return false; |
| - final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix(); |
| - PastePopupMenu pastePopupMenu = getPastePopup(); |
| - if (pastePopupMenu == null) return false; |
| - try { |
| - pastePopupMenu.show(x, (int) (y + contentOffsetYPix)); |
| - } catch (WindowManager.BadTokenException e) { |
| - return false; |
| - } |
| - return true; |
| - } |
| - |
| - private void hidePastePopup() { |
| - if (mPastePopupMenu != null) mPastePopupMenu.hide(); |
| - } |
| - |
| - private PastePopupMenu getPastePopup() { |
| - if (mPastePopupMenu == null) { |
| - PastePopupMenuDelegate delegate = new PastePopupMenuDelegate() { |
| - @Override |
| - public void paste() { |
| - mWebContents.paste(); |
| - dismissTextHandles(); |
| - } |
| - |
| - @Override |
| - public void onDismiss() { |
| - if (mWebContents != null) mWebContents.onContextMenuClosed(); |
| - } |
| - }; |
| - Context windowContext = getWindowAndroid().getContext().get(); |
| - if (windowContext == null) return null; |
| - if (supportsFloatingActionMode()) { |
| - mPastePopupMenu = new FloatingPastePopupMenu( |
| - windowContext, getContainerView(), delegate); |
| - } else { |
| - mPastePopupMenu = new LegacyPastePopupMenu( |
| - windowContext, getContainerView(), delegate); |
| - } |
| - } |
| - return mPastePopupMenu; |
| - } |
| - |
| - private boolean canPaste() { |
| - return ((ClipboardManager) mContext.getSystemService( |
| - Context.CLIPBOARD_SERVICE)).hasPrimaryClip(); |
| - } |
| - |
| @SuppressWarnings("unused") |
| @CalledByNative |
| private void onRenderProcessChange() { |
| @@ -3164,7 +2665,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| * @param data the reply that contains the processed text. |
| */ |
| public void onReceivedProcessTextResult(int resultCode, Intent data) { |
| - if (mWebContents == null || !isSelectionEditable() || resultCode != Activity.RESULT_OK |
| + if (mWebContents == null || resultCode != Activity.RESULT_OK // Fix this |
|
no sievers
2016/06/23 23:16:41
So why don't we check before we process the text w
amaralp
2016/06/24 00:45:50
Yeah we probably should. I removed as much as poss
|
| || data == null) { |
| return; |
| } |
| @@ -3354,14 +2855,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen |
| @Override |
| public void onScreenOrientationChanged(int orientation) { |
| - // ActionMode#invalidate() won't be able to re-layout the floating |
| - // action mode menu items according to the new orientation. So Chrome |
| - // has to re-create the action mode. |
| - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && mActionMode != null) { |
| - hidePopupsAndPreserveSelection(); |
| - showSelectActionMode(true); |
| - } |
| - |
| sendOrientationChangeEvent(orientation); |
| } |