Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
| index 1cb1276647cd50d5974a8607dab32a070ed4a7dd..042173b3c61cb346fb1ec5314a9a88efb6799094 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java |
| @@ -164,6 +164,10 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| // confirmTouchEvent(), from either itself or onTouchEvent(). |
| private int mTouchEventHandlingStackDepth; |
| + // Keeps track of the last long press event, if we end up opening a context menu, we would need |
| + // to potentially use the event to send GESUTRE_SHOW_PRESS_CANCEL to remove ::active styling |
| + private MotionEvent mLastLongPressEvent; |
| + |
| static final int GESTURE_SHOW_PRESSED_STATE = 0; |
| static final int GESTURE_DOUBLE_TAP = 1; |
| static final int GESTURE_SINGLE_TAP_UP = 2; |
| @@ -366,9 +370,9 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| void setTestDependencies( |
| LongPressDetector longPressDetector, GestureDetector gestureDetector, |
| OnGestureListener listener) { |
| - mLongPressDetector = longPressDetector; |
| - mGestureDetector = gestureDetector; |
| - mListener = listener; |
| + if (longPressDetector != null) mLongPressDetector = longPressDetector; |
| + if (gestureDetector != null) mGestureDetector = gestureDetector; |
| + if (listener != null) mListener = listener; |
| } |
| private void initGestureDetectors(final Context context) { |
| @@ -608,7 +612,7 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| if (!mZoomManager.isScaleGestureDetectionInProgress() && |
| (mDoubleTapDragMode == DOUBLE_TAP_DRAG_MODE_NONE || |
| isDoubleTapDragDisabled())) { |
| - sendShowPressCancelIfNecessary(e); |
| + mLastLongPressEvent = e; |
| sendMotionEventAsGesture(GESTURE_LONG_PRESS, e, null); |
| } |
| } |
| @@ -858,6 +862,15 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| } |
| } |
| + /** |
| + * Handle content view losing focus -- ensure that any remaining active state is removed. |
| + */ |
| + void onWindowFocusLost() { |
| + if (mLongPressDetector.isInLongPress() && mLastLongPressEvent != null) { |
|
Ted C
2013/09/13 23:50:26
+2 indent for the conditional
Maria
2013/09/14 01:09:34
Done.
|
| + sendShowPressCancelIfNecessary(mLastLongPressEvent); |
| + } |
| + } |
| + |
| private MotionEvent obtainActionCancelMotionEvent() { |
| return MotionEvent.obtain( |
| SystemClock.uptimeMillis(), |
| @@ -1161,6 +1174,7 @@ class ContentViewGestureHandler implements LongPressDelegate { |
| if (sendMotionEventAsGesture(GESTURE_SHOW_PRESS_CANCEL, e, null)) { |
| mShowPressIsCalled = false; |
| + mLastLongPressEvent = null; |
| } |
| } |