summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMangesh Ghiware <mghiware@google.com>2011-08-31 17:49:07 -0700
committerMangesh Ghiware <mghiware@google.com>2011-09-01 10:49:04 -0700
commitb5f9fc32ec3972694b626ab93991b0b9de97749a (patch)
tree7b81dc4ec5dfa1286001f83e0fd79b5e0dc9a431
parent468485747970d9842d94e1d292fe4cced701cad2 (diff)
downloadframeworks_base-b5f9fc32ec3972694b626ab93991b0b9de97749a.zip
frameworks_base-b5f9fc32ec3972694b626ab93991b0b9de97749a.tar.gz
frameworks_base-b5f9fc32ec3972694b626ab93991b0b9de97749a.tar.bz2
Set reading level scale to display density instead of a fixed minimum.
On a double tap, zoom to either reading level scale or 0.5f more than current (overview) scale, whichever is greater. This addresses the scenario for large screen devices where overview and reading level scale are the same. Bug: 5165527 Change-Id: I50216d60f98b2904f06742336b9c8c7c512328a6
-rw-r--r--core/java/android/webkit/WebView.java8
-rw-r--r--core/java/android/webkit/WebViewCore.java2
-rw-r--r--core/java/android/webkit/ZoomManager.java41
3 files changed, 31 insertions, 20 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 4748522..6274895 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2343,6 +2343,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 3ca3eaa..b24dcb0 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2445,7 +2445,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());
}