Skip to content

Commit 4fdfdee

Browse files
mghiwareAndroid (Google) Code Review
authored andcommitted
Merge "Revert change to setInitialScale() to take display density into account." into ics-mr1
2 parents e5febfd + e832b63 commit 4fdfdee

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

core/java/android/webkit/WebSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ public int getDoubleTapZoom() {
799799
public void setDefaultZoom(ZoomDensity zoom) {
800800
if (mDefaultZoom != zoom) {
801801
mDefaultZoom = zoom;
802-
mWebView.updateDefaultZoomDensity(zoom.value);
802+
mWebView.adjustDefaultZoomDensity(zoom.value);
803803
}
804804
}
805805

core/java/android/webkit/WebView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,9 +1341,13 @@ public void setOverScrollMode(int mode) {
13411341
}
13421342
}
13431343

1344-
/* package */void updateDefaultZoomDensity(int zoomDensity) {
1344+
/* package */ void adjustDefaultZoomDensity(int zoomDensity) {
13451345
final float density = mContext.getResources().getDisplayMetrics().density
13461346
* 100 / zoomDensity;
1347+
updateDefaultZoomDensity(density);
1348+
}
1349+
1350+
/* package */ void updateDefaultZoomDensity(float density) {
13471351
mNavSlop = (int) (16 * density);
13481352
mZoomManager.updateDefaultZoomDensity(density);
13491353
}
@@ -2469,7 +2473,9 @@ public float getScale() {
24692473
* Set the initial scale for the WebView. 0 means default. If
24702474
* {@link WebSettings#getUseWideViewPort()} is true, it zooms out all the
24712475
* way. Otherwise it starts with 100%. If initial scale is greater than 0,
2472-
* WebView starts will this value as initial scale.
2476+
* WebView starts with this value as initial scale.
2477+
* Please note that unlike the scale properties in the viewport meta tag,
2478+
* this method doesn't take the screen density into account.
24732479
*
24742480
* @param scaleInPercent The initial scale in percent.
24752481
*/

core/java/android/webkit/WebViewCore.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,9 @@ private void setupViewport(boolean updateViewState) {
23362336
adjust = (float) mContext.getResources().getDisplayMetrics().densityDpi
23372337
/ mViewportDensityDpi;
23382338
}
2339+
if (adjust != mWebView.getDefaultZoomScale()) {
2340+
mWebView.updateDefaultZoomDensity(adjust);
2341+
}
23392342
int defaultScale = (int) (adjust * 100);
23402343

23412344
if (mViewportInitialScale > 0) {
@@ -2546,7 +2549,7 @@ private void setupViewport(boolean updateViewState) {
25462549
// called by JNI
25472550
private void restoreScale(float scale, float textWrapScale) {
25482551
if (mBrowserFrame.firstLayoutDone() == false) {
2549-
mIsRestored = scale > 0;
2552+
mIsRestored = true;
25502553
mRestoredScale = scale;
25512554
if (mSettings.getUseWideViewPort()) {
25522555
mRestoredTextWrapScale = textWrapScale;

core/java/android/webkit/ZoomManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public final void setZoomCenter(float x, float y) {
349349
}
350350

351351
public final void setInitialScaleInPercent(int scaleInPercent) {
352-
mInitialScale = scaleInPercent * mDisplayDensity * 0.01f;
352+
mInitialScale = scaleInPercent * 0.01f;
353353
}
354354

355355
public final float computeScaleWithLimits(float scale) {

0 commit comments

Comments
 (0)