Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1242)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java

Issue 23444068: Fix stuck state when long press on a button is performed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6912bcc2c821e14d7cb0215563c5887cb81e7df7 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) {
+ 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;
}
}

Powered by Google App Engine
This is Rietveld 408576698