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

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

Issue 18850005: Disable double tap zoom on mobile sites, to remove 300ms click delay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.SystemClock; 10 import android.os.SystemClock;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Whether input events are delivered right before vsync. 148 // Whether input events are delivered right before vsync.
149 private final boolean mInputEventsDeliveredAtVSync; 149 private final boolean mInputEventsDeliveredAtVSync;
150 150
151 // Certain touch-event generated gestures (PINCH_BY, SCROLL_BY) may trigger an expedited vsync 151 // Certain touch-event generated gestures (PINCH_BY, SCROLL_BY) may trigger an expedited vsync
152 // signal. Rather than sending the vsync immediately after such a gesture is sent, we 152 // signal. Rather than sending the vsync immediately after such a gesture is sent, we
153 // set this flag and defer the "last event for vsync" signal until the touch event is fully 153 // set this flag and defer the "last event for vsync" signal until the touch event is fully
154 // processed. This allows multiple such gestures to be sent in a given frame . 154 // processed. This allows multiple such gestures to be sent in a given frame .
155 private boolean mSentGestureNeedsVSync; 155 private boolean mSentGestureNeedsVSync;
156 private long mLastVSyncGestureTimeMs; 156 private long mLastVSyncGestureTimeMs;
157 157
158 // If the page scale is fixed, double tap gesture detection can be disabled. 158 // The page's viewport and scale sometimes allow us to disable double tap ge sture detection,
159 private boolean mHasFixedPageScale; 159 // according to the logic in ContentViewCore.onRenderCoordinatesUpdated().
160 private boolean mShouldDisableDoubleTap;
160 161
161 // Incremented and decremented when the methods onTouchEvent() and confirmTo uchEvent() start 162 // Incremented and decremented when the methods onTouchEvent() and confirmTo uchEvent() start
162 // and finish execution, respectively. This provides accounting for synchron ous calls to 163 // and finish execution, respectively. This provides accounting for synchron ous calls to
163 // confirmTouchEvent(), from either itself or onTouchEvent(). 164 // confirmTouchEvent(), from either itself or onTouchEvent().
164 private int mTouchEventHandlingStackDepth; 165 private int mTouchEventHandlingStackDepth;
165 166
166 // Keeps track of the last long press event, if we end up opening a context menu, we would need 167 // Keeps track of the last long press event, if we end up opening a context menu, we would need
167 // to potentially use the event to send GESUTRE_SHOW_PRESS_CANCEL to remove ::active styling 168 // to potentially use the event to send GESUTRE_SHOW_PRESS_CANCEL to remove ::active styling
168 private MotionEvent mLastLongPressEvent; 169 private MotionEvent mLastLongPressEvent;
169 170
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 int type = TouchPoint.createTouchPoints(event, pts); 974 int type = TouchPoint.createTouchPoints(event, pts);
974 975
975 if (type == TouchPoint.CONVERSION_ERROR) return EVENT_NOT_FORWARDED; 976 if (type == TouchPoint.CONVERSION_ERROR) return EVENT_NOT_FORWARDED;
976 977
977 if (!mTouchScrolling && !mPinchInProgress) { 978 if (!mTouchScrolling && !mPinchInProgress) {
978 if (mMotionEventDelegate.sendTouchEvent(event.getEventTime(), type, pts)) { 979 if (mMotionEventDelegate.sendTouchEvent(event.getEventTime(), type, pts)) {
979 // If confirmTouchEvent() is called synchronously with respect t o sendTouchEvent(), 980 // If confirmTouchEvent() is called synchronously with respect t o sendTouchEvent(),
980 // then |event| will have been recycled. Only start the timer if the sent event has 981 // then |event| will have been recycled. Only start the timer if the sent event has
981 // not yet been confirmed. 982 // not yet been confirmed.
982 if (!mJavaScriptIsConsumingGesture 983 if (!mJavaScriptIsConsumingGesture
983 && !mHasFixedPageScale 984 && !mShouldDisableDoubleTap
984 && event == mPendingMotionEvents.peekFirst() 985 && event == mPendingMotionEvents.peekFirst()
985 && event.getAction() != MotionEvent.ACTION_UP 986 && event.getAction() != MotionEvent.ACTION_UP
986 && event.getAction() != MotionEvent.ACTION_CANCEL) { 987 && event.getAction() != MotionEvent.ACTION_CANCEL) {
987 TraceEvent.instant("TouchEventTimeout:StartTimeoutHandler"); 988 TraceEvent.instant("TouchEventTimeout:StartTimeoutHandler");
988 mTouchEventTimeoutHandler.start(event.getEventTime(), pts); 989 mTouchEventTimeoutHandler.start(event.getEventTime(), pts);
989 } 990 }
990 return EVENT_FORWARDED_TO_NATIVE; 991 return EVENT_FORWARDED_TO_NATIVE;
991 } 992 }
992 } 993 }
993 return EVENT_NOT_FORWARDED; 994 return EVENT_NOT_FORWARDED;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 /** 1215 /**
1215 * This is for testing only. 1216 * This is for testing only.
1216 * @return Whether a touch timeout event has been scheduled. 1217 * @return Whether a touch timeout event has been scheduled.
1217 */ 1218 */
1218 boolean hasScheduledTouchTimeoutEventForTesting() { 1219 boolean hasScheduledTouchTimeoutEventForTesting() {
1219 return mTouchEventTimeoutHandler.hasScheduledTimeoutEventForTesting(); 1220 return mTouchEventTimeoutHandler.hasScheduledTimeoutEventForTesting();
1220 } 1221 }
1221 1222
1222 /** 1223 /**
1223 * Update whether double-tap gestures are supported. This allows 1224 * Update whether double-tap gestures are supported. This allows
1224 * double-tap gesture suppression independent of whether or not the page 1225 * double-tap gesture suppression independent of whether or not the page's
1225 * scale is fixed. 1226 * viewport and scale would normally prevent double-tap.
1226 * Note: This should never be called while a double-tap gesture is in progre ss. 1227 * Note: This should never be called while a double-tap gesture is in progre ss.
1227 * @param supportDoubleTap Whether double-tap gestures are supported. 1228 * @param supportDoubleTap Whether double-tap gestures are supported.
1228 */ 1229 */
1229 public void updateDoubleTapSupport(boolean supportDoubleTap) { 1230 public void updateDoubleTapSupport(boolean supportDoubleTap) {
1230 assert !isDoubleTapActive(); 1231 assert !isDoubleTapActive();
1231 int doubleTapMode = supportDoubleTap ? 1232 int doubleTapMode = supportDoubleTap ?
1232 DOUBLE_TAP_MODE_NONE : DOUBLE_TAP_MODE_DISABLED; 1233 DOUBLE_TAP_MODE_NONE : DOUBLE_TAP_MODE_DISABLED;
1233 if (mDoubleTapMode == doubleTapMode) return; 1234 if (mDoubleTapMode == doubleTapMode) return;
1234 mDoubleTapMode = doubleTapMode; 1235 mDoubleTapMode = doubleTapMode;
1235 updateDoubleTapListener(); 1236 updateDoubleTapListener();
1236 } 1237 }
1237 1238
1238 /** 1239 /**
1239 * Update whether the current page has a fixed page scale. 1240 * Update whether double-tap gesture detection should be suppressed due to
1240 * A fixed page scale will suppress double-tap gesture detection, allowing 1241 * the viewport or scale of the current page. Suppressing double-tap gesture
1241 * for rapid and responsive single-tap gestures. 1242 * detection allows for rapid and responsive single-tap gestures.
1242 * @param hasFixedPageScale Whether the page scale is fixed. 1243 * @param shouldDisableDoubleTap Whether double-tap should be suppressed.
1243 */ 1244 */
1244 public void updateHasFixedPageScale(boolean hasFixedPageScale) { 1245 public void updateShouldDisableDoubleTap(boolean shouldDisableDoubleTap) {
1245 if (mHasFixedPageScale == hasFixedPageScale) return; 1246 if (mShouldDisableDoubleTap == shouldDisableDoubleTap) return;
1246 mHasFixedPageScale = hasFixedPageScale; 1247 mShouldDisableDoubleTap = shouldDisableDoubleTap;
1247 updateDoubleTapListener(); 1248 updateDoubleTapListener();
1248 } 1249 }
1249 1250
1250 private boolean isDoubleTapDisabled() { 1251 private boolean isDoubleTapDisabled() {
1251 return mDoubleTapMode == DOUBLE_TAP_MODE_DISABLED || 1252 return mDoubleTapMode == DOUBLE_TAP_MODE_DISABLED || mShouldDisableDoubl eTap;
1252 mHasFixedPageScale;
1253 } 1253 }
1254 1254
1255 private boolean isDoubleTapActive() { 1255 private boolean isDoubleTapActive() {
1256 return mDoubleTapMode != DOUBLE_TAP_MODE_DISABLED && 1256 return mDoubleTapMode != DOUBLE_TAP_MODE_DISABLED &&
1257 mDoubleTapMode != DOUBLE_TAP_MODE_NONE; 1257 mDoubleTapMode != DOUBLE_TAP_MODE_NONE;
1258 } 1258 }
1259 1259
1260 private void updateDoubleTapListener() { 1260 private void updateDoubleTapListener() {
1261 if (isDoubleTapDisabled()) { 1261 if (isDoubleTapDisabled()) {
1262 // Defer nulling the DoubleTapListener until the double tap gesture is complete. 1262 // Defer nulling the DoubleTapListener until the double tap gesture is complete.
1263 if (isDoubleTapActive()) return; 1263 if (isDoubleTapActive()) return;
1264 mGestureDetector.setOnDoubleTapListener(null); 1264 mGestureDetector.setOnDoubleTapListener(null);
1265 } else { 1265 } else {
1266 mGestureDetector.setOnDoubleTapListener(mDoubleTapListener); 1266 mGestureDetector.setOnDoubleTapListener(mDoubleTapListener);
1267 } 1267 }
1268 1268
1269 } 1269 }
1270 } 1270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698