From e9841bb45d32685cf1371659fbf5ce4a3b88e782 Mon Sep 17 00:00:00 2001 From: Mangesh Ghiware Date: Tue, 1 Nov 2011 09:55:45 -0700 Subject: [PATCH] Fix setInitialScale() to take display density into account. Reverted changes made to fix bug 4982074 (Book text display is limited to about half the available screen.) The Books app sets initial scale to 100%, and since display density for Crespo is 1.5, initial scale was actually being set to a smaller value in Device Independent Pixel units. The correct fix is to take display density into account. This fixes bug 5477652: webview scale factor wrong on prime in reddit app. Change-Id: Ie09172629add7fb28ca6b47d0fd8f6450c5df569 --- core/java/android/webkit/ZoomManager.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java index 2a0b6e5d50595..e829571d531fd 100644 --- a/core/java/android/webkit/ZoomManager.java +++ b/core/java/android/webkit/ZoomManager.java @@ -169,11 +169,7 @@ class ZoomManager { /* * The initial scale for the WebView. 0 means default. If initial scale is - * greater than 0 the WebView starts with this value as its initial scale. The - * value is converted from an integer percentage so it is guarenteed to have - * no more than 2 significant digits after the decimal. This restriction - * allows us to convert the scale back to the original percentage by simply - * multiplying the value by 100. + * greater than 0, the WebView starts with this value as its initial scale. */ private float mInitialScale; @@ -313,7 +309,7 @@ class ZoomManager { } public final float getDefaultScale() { - return mInitialScale > 0 ? mInitialScale : mDefaultScale; + return mDefaultScale; } /** @@ -353,9 +349,7 @@ class ZoomManager { } public final void setInitialScaleInPercent(int scaleInPercent) { - mInitialScale = scaleInPercent * 0.01f; - mActualScale = mInitialScale > 0 ? mInitialScale : mDefaultScale; - mInvActualScale = 1 / mActualScale; + mInitialScale = scaleInPercent * mDisplayDensity * 0.01f; } public final float computeScaleWithLimits(float scale) { @@ -1120,7 +1114,6 @@ class ZoomManager { float scale; if (mInitialScale > 0) { scale = mInitialScale; - mTextWrapScale = scale; } else if (viewState.mIsRestored) { scale = (viewState.mViewScale > 0) ? viewState.mViewScale : overviewScale; @@ -1141,7 +1134,7 @@ class ZoomManager { } boolean reflowText = false; if (!viewState.mIsRestored) { - if (settings.getUseFixedViewport() && mInitialScale == 0) { + if (settings.getUseFixedViewport()) { // Override the scale only in case of fixed viewport. scale = Math.max(scale, overviewScale); mTextWrapScale = Math.max(mTextWrapScale, overviewScale);