Skip to content

Commit 274133d

Browse files
mghiwareAndroid (Google) Code Review
authored andcommitted
Merge "Fix setInitialScale() to take display density into account." into ics-mr1
2 parents abf7539 + e9841bb commit 274133d

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

core/java/android/webkit/ZoomManager.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,7 @@ class ZoomManager {
169169

170170
/*
171171
* The initial scale for the WebView. 0 means default. If initial scale is
172-
* greater than 0 the WebView starts with this value as its initial scale. The
173-
* value is converted from an integer percentage so it is guarenteed to have
174-
* no more than 2 significant digits after the decimal. This restriction
175-
* allows us to convert the scale back to the original percentage by simply
176-
* multiplying the value by 100.
172+
* greater than 0, the WebView starts with this value as its initial scale.
177173
*/
178174
private float mInitialScale;
179175

@@ -313,7 +309,7 @@ public final float getMinZoomScale() {
313309
}
314310

315311
public final float getDefaultScale() {
316-
return mInitialScale > 0 ? mInitialScale : mDefaultScale;
312+
return mDefaultScale;
317313
}
318314

319315
/**
@@ -353,9 +349,7 @@ public final void setZoomCenter(float x, float y) {
353349
}
354350

355351
public final void setInitialScaleInPercent(int scaleInPercent) {
356-
mInitialScale = scaleInPercent * 0.01f;
357-
mActualScale = mInitialScale > 0 ? mInitialScale : mDefaultScale;
358-
mInvActualScale = 1 / mActualScale;
352+
mInitialScale = scaleInPercent * mDisplayDensity * 0.01f;
359353
}
360354

361355
public final float computeScaleWithLimits(float scale) {
@@ -1120,7 +1114,6 @@ public void onFirstLayout(WebViewCore.DrawData drawData) {
11201114
float scale;
11211115
if (mInitialScale > 0) {
11221116
scale = mInitialScale;
1123-
mTextWrapScale = scale;
11241117
} else if (viewState.mIsRestored) {
11251118
scale = (viewState.mViewScale > 0)
11261119
? viewState.mViewScale : overviewScale;
@@ -1141,7 +1134,7 @@ public void onFirstLayout(WebViewCore.DrawData drawData) {
11411134
}
11421135
boolean reflowText = false;
11431136
if (!viewState.mIsRestored) {
1144-
if (settings.getUseFixedViewport() && mInitialScale == 0) {
1137+
if (settings.getUseFixedViewport()) {
11451138
// Override the scale only in case of fixed viewport.
11461139
scale = Math.max(scale, overviewScale);
11471140
mTextWrapScale = Math.max(mTextWrapScale, overviewScale);

0 commit comments

Comments
 (0)