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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.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: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.app.Activity; 7 import android.app.Activity;
8 import android.content.ContentResolver; 8 import android.content.ContentResolver;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.pm.ActivityInfo; 10 import android.content.pm.ActivityInfo;
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 public ContentSettings getContentSettings() { 1357 public ContentSettings getContentSettings() {
1358 return mContentSettings; 1358 return mContentSettings;
1359 } 1359 }
1360 1360
1361 @Override 1361 @Override
1362 public boolean didUIStealScroll(float x, float y) { 1362 public boolean didUIStealScroll(float x, float y) {
1363 return getContentViewClient().shouldOverrideScroll( 1363 return getContentViewClient().shouldOverrideScroll(
1364 x, y, computeHorizontalScrollOffset(), computeVerticalScrollOffs et()); 1364 x, y, computeHorizontalScrollOffset(), computeVerticalScrollOffs et());
1365 } 1365 }
1366 1366
1367 @Override
1368 public boolean hasFixedPageScale() {
1369 return mRenderCoordinates.hasFixedPageScale();
1370 }
1371
1372 private void hidePopupDialog() { 1367 private void hidePopupDialog() {
1373 SelectPopupDialog.hide(this); 1368 SelectPopupDialog.hide(this);
1374 hideHandles(); 1369 hideHandles();
1375 hideSelectActionBar(); 1370 hideSelectActionBar();
1376 } 1371 }
1377 1372
1378 void hideSelectActionBar() { 1373 void hideSelectActionBar() {
1379 if (mActionMode != null) { 1374 if (mActionMode != null) {
1380 mActionMode.finish(); 1375 mActionMode.finish();
1381 mActionMode = null; 1376 mActionMode = null;
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 scrollOffsetX, scrollOffsetY, 2191 scrollOffsetX, scrollOffsetY,
2197 contentWidth, contentHeight, 2192 contentWidth, contentHeight,
2198 viewportWidth, viewportHeight, 2193 viewportWidth, viewportHeight,
2199 pageScaleFactor, minPageScaleFactor, maxPageScaleFactor, 2194 pageScaleFactor, minPageScaleFactor, maxPageScaleFactor,
2200 contentOffsetYPix); 2195 contentOffsetYPix);
2201 2196
2202 if (needTemporarilyHideHandles) temporarilyHideTextHandles(); 2197 if (needTemporarilyHideHandles) temporarilyHideTextHandles();
2203 if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls(); 2198 if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls();
2204 if (contentOffsetChanged) updateHandleScreenPositions(); 2199 if (contentOffsetChanged) updateHandleScreenPositions();
2205 2200
2201 updateDoubleTapZoomEnabled();
2202
2206 // Update offsets for fullscreen. 2203 // Update offsets for fullscreen.
2207 final float deviceScale = mRenderCoordinates.getDeviceScaleFactor(); 2204 final float deviceScale = mRenderCoordinates.getDeviceScaleFactor();
2208 final float controlsOffsetPix = controlsOffsetYCss * deviceScale; 2205 final float controlsOffsetPix = controlsOffsetYCss * deviceScale;
2209 final float overdrawBottomHeightPix = overdrawBottomHeightCss * deviceSc ale; 2206 final float overdrawBottomHeightPix = overdrawBottomHeightCss * deviceSc ale;
2210 getContentViewClient().onOffsetsForFullscreenChanged( 2207 getContentViewClient().onOffsetsForFullscreenChanged(
2211 controlsOffsetPix, contentOffsetYPix, overdrawBottomHeightPix); 2208 controlsOffsetPix, contentOffsetYPix, overdrawBottomHeightPix);
2212 2209
2213 mPendingRendererFrame = true; 2210 mPendingRendererFrame = true;
2214 if (mBrowserAccessibilityManager != null) { 2211 if (mBrowserAccessibilityManager != null) {
2215 mBrowserAccessibilityManager.notifyFrameInfoInitialized(); 2212 mBrowserAccessibilityManager.notifyFrameInfoInitialized();
2216 } 2213 }
2217 } 2214 }
2218 2215
2216 private void updateDoubleTapZoomEnabled() {
2217 float pageScale = mRenderCoordinates.getPageScaleFactor();
2218 float contentWidthCss = mRenderCoordinates.getContentWidthCss();
2219 float windowWidthDp = pageScale * mRenderCoordinates.getLastFrameViewpor tWidthCss();
2220
2221 float minScale = mRenderCoordinates.getMinPageScaleFactor();
2222 float maxScale = mRenderCoordinates.getMaxPageScaleFactor();
2223
2224 // We disable double-tap zoom for pages that have a width=device-width
2225 // or narrower viewport (indicating that this is a mobile-optimized or
2226 // responsive website), as long as the user has not pinch-zoomed in by
2227 // more than 10% (in which case they might reasonably expect to be able
2228 // to zoom back out using double-tap zoom).
2229 // It is also disabled for pages that disallow the user from zooming in
2230 // or out (even if they don't have a device-width or narrower viewport).
2231 boolean enable = (contentWidthCss > windowWidthDp || pageScale >= 1.1f * minScale)
2232 && minScale != maxScale;
2233 mContentViewGestureHandler.setDoubleTapZoomEnabled(enable);
2234 }
2235
2219 @SuppressWarnings("unused") 2236 @SuppressWarnings("unused")
2220 @CalledByNative 2237 @CalledByNative
2221 private void updateImeAdapter(int nativeImeAdapterAndroid, int textInputType , 2238 private void updateImeAdapter(int nativeImeAdapterAndroid, int textInputType ,
2222 String text, int selectionStart, int selectionEnd, 2239 String text, int selectionStart, int selectionEnd,
2223 int compositionStart, int compositionEnd, boolean showImeIfNeeded) { 2240 int compositionStart, int compositionEnd, boolean showImeIfNeeded) {
2224 TraceEvent.begin(); 2241 TraceEvent.begin();
2225 mSelectionEditable = (textInputType != ImeAdapter.getTextInputTypeNone() ); 2242 mSelectionEditable = (textInputType != ImeAdapter.getTextInputTypeNone() );
2226 2243
2227 if (mActionMode != null) mActionMode.invalidate(); 2244 if (mActionMode != null) mActionMode.invalidate();
2228 2245
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 3129
3113 private native void nativeAttachExternalVideoSurface( 3130 private native void nativeAttachExternalVideoSurface(
3114 int nativeContentViewCoreImpl, int playerId, Surface surface); 3131 int nativeContentViewCoreImpl, int playerId, Surface surface);
3115 3132
3116 private native void nativeDetachExternalVideoSurface( 3133 private native void nativeDetachExternalVideoSurface(
3117 int nativeContentViewCoreImpl, int playerId); 3134 int nativeContentViewCoreImpl, int playerId);
3118 3135
3119 private native void nativeSetAccessibilityEnabled( 3136 private native void nativeSetAccessibilityEnabled(
3120 int nativeContentViewCoreImpl, boolean enabled); 3137 int nativeContentViewCoreImpl, boolean enabled);
3121 } 3138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698