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

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: Fix typo 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // Whether input events are delivered right before vsync. 147 // Whether input events are delivered right before vsync.
148 private final boolean mInputEventsDeliveredAtVSync; 148 private final boolean mInputEventsDeliveredAtVSync;
149 149
150 // Certain touch-event generated gestures (PINCH_BY, SCROLL_BY) may trigger an expedited vsync 150 // Certain touch-event generated gestures (PINCH_BY, SCROLL_BY) may trigger an expedited vsync
151 // signal. Rather than sending the vsync immediately after such a gesture is sent, we 151 // signal. Rather than sending the vsync immediately after such a gesture is sent, we
152 // set this flag and defer the "last event for vsync" signal until the touch event is fully 152 // set this flag and defer the "last event for vsync" signal until the touch event is fully
153 // processed. This allows multiple such gestures to be sent in a given frame . 153 // processed. This allows multiple such gestures to be sent in a given frame .
154 private boolean mSentGestureNeedsVSync; 154 private boolean mSentGestureNeedsVSync;
155 private long mLastVSyncGestureTimeMs; 155 private long mLastVSyncGestureTimeMs;
156 156
157 // If the page scale is fixed, double tap gesture detection can be disabled. 157 // The page's viewport and scale sometimes allow us to disable double tap ge sture detection,
158 private boolean mHasFixedPageScale; 158 // according to the logic in ContentViewCore.onRenderCoordinatesUpdated().
159 private boolean mShouldDisableDoubleTap;
159 160
160 // Incremented and decremented when the methods onTouchEvent() and confirmTo uchEvent() start 161 // Incremented and decremented when the methods onTouchEvent() and confirmTo uchEvent() start
161 // and finish execution, respectively. This provides accounting for synchron ous calls to 162 // and finish execution, respectively. This provides accounting for synchron ous calls to
162 // confirmTouchEvent(), from either itself or onTouchEvent(). 163 // confirmTouchEvent(), from either itself or onTouchEvent().
163 private int mTouchEventHandlingStackDepth; 164 private int mTouchEventHandlingStackDepth;
164 165
165 // Keeps track of the last long press event, if we end up opening a context menu, we would need 166 // Keeps track of the last long press event, if we end up opening a context menu, we would need
166 // to potentially use the event to send GESUTRE_SHOW_PRESS_CANCEL to remove ::active styling 167 // to potentially use the event to send GESUTRE_SHOW_PRESS_CANCEL to remove ::active styling
167 private MotionEvent mLastLongPressEvent; 168 private MotionEvent mLastLongPressEvent;
168 169
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 int type = TouchPoint.createTouchPoints(event, pts); 962 int type = TouchPoint.createTouchPoints(event, pts);
962 963
963 if (type == TouchPoint.CONVERSION_ERROR) return EVENT_NOT_FORWARDED; 964 if (type == TouchPoint.CONVERSION_ERROR) return EVENT_NOT_FORWARDED;
964 965
965 if (!mTouchScrolling && !mPinchInProgress) { 966 if (!mTouchScrolling && !mPinchInProgress) {
966 if (mMotionEventDelegate.sendTouchEvent(event.getEventTime(), type, pts)) { 967 if (mMotionEventDelegate.sendTouchEvent(event.getEventTime(), type, pts)) {
967 // If confirmTouchEvent() is called synchronously with respect t o sendTouchEvent(), 968 // If confirmTouchEvent() is called synchronously with respect t o sendTouchEvent(),
968 // then |event| will have been recycled. Only start the timer if the sent event has 969 // then |event| will have been recycled. Only start the timer if the sent event has
969 // not yet been confirmed. 970 // not yet been confirmed.
970 if (!mJavaScriptIsConsumingGesture 971 if (!mJavaScriptIsConsumingGesture
971 && !mHasFixedPageScale 972 && !mShouldDisableDoubleTap
972 && event == mPendingMotionEvents.peekFirst() 973 && event == mPendingMotionEvents.peekFirst()
973 && event.getAction() != MotionEvent.ACTION_UP 974 && event.getAction() != MotionEvent.ACTION_UP
974 && event.getAction() != MotionEvent.ACTION_CANCEL) { 975 && event.getAction() != MotionEvent.ACTION_CANCEL) {
975 TraceEvent.instant("TouchEventTimeout:StartTimeoutHandler"); 976 TraceEvent.instant("TouchEventTimeout:StartTimeoutHandler");
976 mTouchEventTimeoutHandler.start(event.getEventTime(), pts); 977 mTouchEventTimeoutHandler.start(event.getEventTime(), pts);
977 } 978 }
978 return EVENT_FORWARDED_TO_NATIVE; 979 return EVENT_FORWARDED_TO_NATIVE;
979 } 980 }
980 } 981 }
981 return EVENT_NOT_FORWARDED; 982 return EVENT_NOT_FORWARDED;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 /** 1203 /**
1203 * This is for testing only. 1204 * This is for testing only.
1204 * @return Whether a touch timeout event has been scheduled. 1205 * @return Whether a touch timeout event has been scheduled.
1205 */ 1206 */
1206 boolean hasScheduledTouchTimeoutEventForTesting() { 1207 boolean hasScheduledTouchTimeoutEventForTesting() {
1207 return mTouchEventTimeoutHandler.hasScheduledTimeoutEventForTesting(); 1208 return mTouchEventTimeoutHandler.hasScheduledTimeoutEventForTesting();
1208 } 1209 }
1209 1210
1210 /** 1211 /**
1211 * Update whether double-tap gestures are supported. This allows 1212 * Update whether double-tap gestures are supported. This allows
1212 * double-tap gesture suppression independent of whether or not the page 1213 * double-tap gesture suppression independent of whether or not the page's
1213 * scale is fixed. 1214 * viewport and scale would normally prevent double-tap.
1214 * Note: This should never be called while a double-tap gesture is in progre ss. 1215 * Note: This should never be called while a double-tap gesture is in progre ss.
1215 * @param supportDoubleTap Whether double-tap gestures are supported. 1216 * @param supportDoubleTap Whether double-tap gestures are supported.
1216 */ 1217 */
1217 public void updateDoubleTapSupport(boolean supportDoubleTap) { 1218 public void updateDoubleTapSupport(boolean supportDoubleTap) {
1218 assert (mDoubleTapMode == DOUBLE_TAP_MODE_DISABLED || 1219 assert (mDoubleTapMode == DOUBLE_TAP_MODE_DISABLED ||
1219 mDoubleTapMode == DOUBLE_TAP_MODE_NONE); 1220 mDoubleTapMode == DOUBLE_TAP_MODE_NONE);
1220 int doubleTapMode = supportDoubleTap ? 1221 int doubleTapMode = supportDoubleTap ?
1221 DOUBLE_TAP_MODE_NONE : DOUBLE_TAP_MODE_DISABLED; 1222 DOUBLE_TAP_MODE_NONE : DOUBLE_TAP_MODE_DISABLED;
1222 if (mDoubleTapMode == doubleTapMode) return; 1223 if (mDoubleTapMode == doubleTapMode) return;
1223 mDoubleTapMode = doubleTapMode; 1224 mDoubleTapMode = doubleTapMode;
1224 updateDoubleTapListener(); 1225 updateDoubleTapListener();
1225 } 1226 }
1226 1227
1227 /** 1228 /**
1228 * Update whether the current page has a fixed page scale. 1229 * Update whether double-tap gesture detection should be suppressed due to
1229 * A fixed page scale will suppress double-tap gesture detection, allowing 1230 * the viewport or scale of the current page. Suppressing double-tap gesture
1230 * for rapid and responsive single-tap gestures. 1231 * detection allows for rapid and responsive single-tap gestures.
1231 * @param hasFixedPageScale Whether the page scale is fixed. 1232 * @param shouldDisableDoubleTap Whether double-tap should be suppressed.
1232 */ 1233 */
1233 public void updateHasFixedPageScale(boolean hasFixedPageScale) { 1234 public void updateShouldDisableDoubleTap(boolean shouldDisableDoubleTap) {
1234 if (mHasFixedPageScale == hasFixedPageScale) return; 1235 if (mShouldDisableDoubleTap == shouldDisableDoubleTap) return;
1235 mHasFixedPageScale = hasFixedPageScale; 1236 mShouldDisableDoubleTap = shouldDisableDoubleTap;
1236 updateDoubleTapListener(); 1237 updateDoubleTapListener();
1237 } 1238 }
1238 1239
1239 private boolean isDoubleTapDisabled() { 1240 private boolean isDoubleTapDisabled() {
1240 return mDoubleTapMode == DOUBLE_TAP_MODE_DISABLED || 1241 return mDoubleTapMode == DOUBLE_TAP_MODE_DISABLED ||
1241 mHasFixedPageScale; 1242 mShouldDisableDoubleTap;
Ted C 2013/10/24 19:52:44 this looks like it should fit on the previous line
johnme 2013/10/31 19:13:12 Done.
1242 } 1243 }
1243 1244
1244 private void updateDoubleTapListener() { 1245 private void updateDoubleTapListener() {
1245 if (isDoubleTapDisabled()) { 1246 if (isDoubleTapDisabled()) {
1246 endDoubleTapDragIfNecessary(null); 1247 endDoubleTapDragIfNecessary(null);
1247 mGestureDetector.setOnDoubleTapListener(null); 1248 mGestureDetector.setOnDoubleTapListener(null);
1248 } else { 1249 } else {
1249 mGestureDetector.setOnDoubleTapListener(mDoubleTapListener); 1250 mGestureDetector.setOnDoubleTapListener(mDoubleTapListener);
1250 } 1251 }
1251 1252
1252 } 1253 }
1253 } 1254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698