diff options
author | Mangesh Ghiware <mghiware@google.com> | 2011-09-02 11:16:05 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-09-02 11:16:05 -0700 |
commit | 6ff9f9eff214944181e25f6aa42558d2f382c776 (patch) | |
tree | 20937133952d19e34b429d89cda185ccb525c513 /core | |
parent | 3939356d41ed0fc9c9b8553bce1cf2e85e457cb6 (diff) | |
parent | 5afd2bd02ae44d5a38f9e560047723ddab176405 (diff) | |
download | frameworks_base-6ff9f9eff214944181e25f6aa42558d2f382c776.zip frameworks_base-6ff9f9eff214944181e25f6aa42558d2f382c776.tar.gz frameworks_base-6ff9f9eff214944181e25f6aa42558d2f382c776.tar.bz2 |
am 5afd2bd0: Merge "Set reading level scale to display density instead of a fixed minimum."
* commit '5afd2bd02ae44d5a38f9e560047723ddab176405':
Set reading level scale to display density instead of a fixed minimum.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/webkit/WebView.java | 8 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewCore.java | 2 | ||||
-rw-r--r-- | core/java/android/webkit/ZoomManager.java | 41 |
3 files changed, 31 insertions, 20 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 2e7f923..64fbae6 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2346,6 +2346,14 @@ public class WebView extends AbsoluteLayout } /** + * Return the reading level scale of the WebView + * @return The reading level scale. + */ + /*package*/ float getReadingLevelScale() { + return mZoomManager.getReadingLevelScale(); + } + + /** * Set the initial scale for the WebView. 0 means default. If * {@link WebSettings#getUseWideViewPort()} is true, it zooms out all the * way. Otherwise it starts with 100%. If initial scale is greater than 0, diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index c895b84..c61bd48 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -2460,7 +2460,7 @@ public final class WebViewCore { if (mSettings.isNarrowColumnLayout()) { // In case of automatic text reflow in fixed view port mode. mInitialViewState.mTextWrapScale = - ZoomManager.computeReadingLevelScale(data.mScale); + mWebView.getReadingLevelScale(); } } else { // Scale is given such as when page is restored, use it. diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java index 2bcb020..0bfb668 100644 --- a/core/java/android/webkit/ZoomManager.java +++ b/core/java/android/webkit/ZoomManager.java @@ -58,13 +58,6 @@ class ZoomManager { private ZoomControlExternal mExternalZoomControl; /* - * For large screen devices, the defaultScale usually set to 1.0 and - * equal to the overview scale, to differentiate the zoom level for double tapping, - * a default reading level scale is used. - */ - private static final float DEFAULT_READING_LEVEL_SCALE = 1.5f; - - /* * The scale factors that determine the upper and lower bounds for the * default zoom scale. */ @@ -151,6 +144,19 @@ class ZoomManager { private float mDefaultScale; 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 + */ + private float mReadingLevelScale; + + /* + * The scale factor that is used as the minimum increment when going from + * overview to reading level on a double tap. + */ + private static float MIN_DOUBLE_TAP_SCALE_INCREMENT = 0.5f; + // the current computed zoom scale and its inverse. private float mActualScale; private float mInvActualScale; @@ -230,6 +236,7 @@ class ZoomManager { setDefaultZoomScale(density); mActualScale = density; mInvActualScale = 1 / density; + mReadingLevelScale = density; mTextWrapScale = density; } @@ -304,13 +311,7 @@ class ZoomManager { } public final float getReadingLevelScale() { - return computeScaleWithLimits(computeReadingLevelScale(getZoomOverviewScale())); - } - - /* package */ final static float computeReadingLevelScale(float scale) { - // The reading scale is at least 0.5f apart from the input scale. - final float MIN_SCALE_DIFF = 0.5f; - return Math.max(scale + MIN_SCALE_DIFF, DEFAULT_READING_LEVEL_SCALE); + return mReadingLevelScale; } public final float getInvDefaultScale() { @@ -652,7 +653,7 @@ class ZoomManager { } else if (!mInZoomOverview && willScaleTriggerZoom(getZoomOverviewScale())) { zoomToOverview(); } else { - zoomToReadingLevel(); + zoomToReadingLevelOrMore(); } } @@ -683,8 +684,10 @@ class ZoomManager { !mWebView.getSettings().getUseFixedViewport()); } - private void zoomToReadingLevel() { - final float readingScale = getReadingLevelScale(); + private void zoomToReadingLevelOrMore() { + final float zoomScale = Math.max(getReadingLevelScale(), + mActualScale + MIN_DOUBLE_TAP_SCALE_INCREMENT); + int left = mWebView.nativeGetBlockLeftEdge(mAnchorX, mAnchorY, mActualScale); if (left != WebView.NO_LEFTEDGE) { // add a 5pt padding to the left edge. @@ -693,13 +696,13 @@ class ZoomManager { // Re-calculate the zoom center so that the new scroll x will be // on the left edge. if (viewLeft > 0) { - mZoomCenterX = viewLeft * readingScale / (readingScale - mActualScale); + mZoomCenterX = viewLeft * zoomScale / (zoomScale - mActualScale); } else { mWebView.scrollBy(viewLeft, 0); mZoomCenterX = 0; } } - startZoomAnimation(readingScale, + startZoomAnimation(zoomScale, !mWebView.getSettings().getUseFixedViewport()); } |