Loading core/java/android/webkit/WebSettings.java +22 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ public class WebSettings { private ZoomDensity mDefaultZoom = ZoomDensity.MEDIUM; private RenderPriority mRenderPriority = RenderPriority.NORMAL; private int mOverrideCacheMode = LOAD_DEFAULT; private int mDoubleTapZoom = 100; private boolean mSaveFormData = true; private boolean mAutoFillEnabled = false; private boolean mSavePassword = true; Loading Loading @@ -768,6 +769,27 @@ public class WebSettings { return closestSize != null ? closestSize : TextSize.NORMAL; } /** * Set the double-tap zoom of the page in percent. Default is 100. * @param doubleTapZoom A percent value for increasing or decreasing the double-tap zoom. * @hide */ public void setDoubleTapZoom(int doubleTapZoom) { if (mDoubleTapZoom != doubleTapZoom) { mDoubleTapZoom = doubleTapZoom; mWebView.updateDoubleTapZoom(); } } /** * Get the double-tap zoom of the page in percent. * @return A percent value describing the double-tap zoom. * @hide */ public int getDoubleTapZoom() { return mDoubleTapZoom; } /** * Set the default zoom density of the page. This should be called from UI * thread. Loading core/java/android/webkit/WebView.java +7 −0 Original line number Diff line number Diff line Loading @@ -2986,6 +2986,13 @@ public class WebView extends AbsoluteLayout return false; } /** * Update the double-tap zoom. */ /* package */ void updateDoubleTapZoom() { mZoomManager.updateDoubleTapZoom(); } private int computeRealHorizontalScrollRange() { if (mDrawHistory) { return mHistoryWidth; Loading core/java/android/webkit/ZoomManager.java +17 −7 Original line number Diff line number Diff line Loading @@ -145,11 +145,11 @@ class ZoomManager { private float mInvDefaultScale; /* * The scale factor that is used to determine the zoom level for reading text. * The value is initially set to equal the display density. * TODO: Support changing this in WebSettings * The logical density of the display. This is a scaling factor for the * Density Independent Pixel unit, where one DIP is one pixel on an * approximately 160 dpi screen (see android.util.DisplayMetrics.density) */ private float mReadingLevelScale; private float mDisplayDensity; /* * The scale factor that is used as the minimum increment when going from Loading Loading @@ -233,11 +233,11 @@ class ZoomManager { public void init(float density) { assert density > 0; mDisplayDensity = density; setDefaultZoomScale(density); mActualScale = density; mInvActualScale = 1 / density; mReadingLevelScale = density; mTextWrapScale = density; mTextWrapScale = getReadingLevelScale(); } /** Loading Loading @@ -310,8 +310,11 @@ class ZoomManager { return mInitialScale > 0 ? mInitialScale : mDefaultScale; } /** * Returns the zoom scale used for reading text on a double-tap. */ public final float getReadingLevelScale() { return mReadingLevelScale; return mDisplayDensity * mWebView.getSettings().getDoubleTapZoom() / 100.0f; } public final float getInvDefaultScale() { Loading Loading @@ -510,6 +513,13 @@ class ZoomManager { return mZoomScale != 0 || mInHWAcceleratedZoom; } public void updateDoubleTapZoom() { if (mInZoomOverview) { mTextWrapScale = getReadingLevelScale(); refreshZoomScale(true); } } public void refreshZoomScale(boolean reflowText) { setZoomScale(mActualScale, reflowText, true); } Loading Loading
core/java/android/webkit/WebSettings.java +22 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ public class WebSettings { private ZoomDensity mDefaultZoom = ZoomDensity.MEDIUM; private RenderPriority mRenderPriority = RenderPriority.NORMAL; private int mOverrideCacheMode = LOAD_DEFAULT; private int mDoubleTapZoom = 100; private boolean mSaveFormData = true; private boolean mAutoFillEnabled = false; private boolean mSavePassword = true; Loading Loading @@ -768,6 +769,27 @@ public class WebSettings { return closestSize != null ? closestSize : TextSize.NORMAL; } /** * Set the double-tap zoom of the page in percent. Default is 100. * @param doubleTapZoom A percent value for increasing or decreasing the double-tap zoom. * @hide */ public void setDoubleTapZoom(int doubleTapZoom) { if (mDoubleTapZoom != doubleTapZoom) { mDoubleTapZoom = doubleTapZoom; mWebView.updateDoubleTapZoom(); } } /** * Get the double-tap zoom of the page in percent. * @return A percent value describing the double-tap zoom. * @hide */ public int getDoubleTapZoom() { return mDoubleTapZoom; } /** * Set the default zoom density of the page. This should be called from UI * thread. Loading
core/java/android/webkit/WebView.java +7 −0 Original line number Diff line number Diff line Loading @@ -2986,6 +2986,13 @@ public class WebView extends AbsoluteLayout return false; } /** * Update the double-tap zoom. */ /* package */ void updateDoubleTapZoom() { mZoomManager.updateDoubleTapZoom(); } private int computeRealHorizontalScrollRange() { if (mDrawHistory) { return mHistoryWidth; Loading
core/java/android/webkit/ZoomManager.java +17 −7 Original line number Diff line number Diff line Loading @@ -145,11 +145,11 @@ class ZoomManager { private float mInvDefaultScale; /* * The scale factor that is used to determine the zoom level for reading text. * The value is initially set to equal the display density. * TODO: Support changing this in WebSettings * The logical density of the display. This is a scaling factor for the * Density Independent Pixel unit, where one DIP is one pixel on an * approximately 160 dpi screen (see android.util.DisplayMetrics.density) */ private float mReadingLevelScale; private float mDisplayDensity; /* * The scale factor that is used as the minimum increment when going from Loading Loading @@ -233,11 +233,11 @@ class ZoomManager { public void init(float density) { assert density > 0; mDisplayDensity = density; setDefaultZoomScale(density); mActualScale = density; mInvActualScale = 1 / density; mReadingLevelScale = density; mTextWrapScale = density; mTextWrapScale = getReadingLevelScale(); } /** Loading Loading @@ -310,8 +310,11 @@ class ZoomManager { return mInitialScale > 0 ? mInitialScale : mDefaultScale; } /** * Returns the zoom scale used for reading text on a double-tap. */ public final float getReadingLevelScale() { return mReadingLevelScale; return mDisplayDensity * mWebView.getSettings().getDoubleTapZoom() / 100.0f; } public final float getInvDefaultScale() { Loading Loading @@ -510,6 +513,13 @@ class ZoomManager { return mZoomScale != 0 || mInHWAcceleratedZoom; } public void updateDoubleTapZoom() { if (mInZoomOverview) { mTextWrapScale = getReadingLevelScale(); refreshZoomScale(true); } } public void refreshZoomScale(boolean reflowText) { setZoomScale(mActualScale, reflowText, true); } Loading