Skip to content

Commit b6610d8

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "Fix DPI scaling on TVDPI" into jb-mr1-dev
2 parents 3d5be42 + 6013d8c commit b6610d8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

core/java/android/webkit/WebViewCore.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,9 @@ private void setupViewport(boolean updateViewState) {
25282528
adjust = (float) mContext.getResources().getDisplayMetrics().densityDpi
25292529
/ mViewportDensityDpi;
25302530
}
2531+
// We make bad assumptions about multiplying and dividing by 100, force
2532+
// them to be true with this hack
2533+
adjust = ((int) (adjust * 100)) / 100.0f;
25312534
// Remove any update density messages in flight.
25322535
// If the density is indeed different from WebView's default scale,
25332536
// a new message will be queued.

core/java/android/webkit/ZoomManager.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ private void setDefaultZoomScale(float defaultScale) {
287287
if (!exceedsMinScaleIncrement(mMinZoomScale, mMaxZoomScale)) {
288288
mMaxZoomScale = mMinZoomScale;
289289
}
290+
sanitizeMinMaxScales();
290291
}
291292

292293
public final float getScale() {
@@ -909,6 +910,14 @@ public void onScaleEnd(ScaleGestureDetector detector) {
909910
}
910911
}
911912

913+
private void sanitizeMinMaxScales() {
914+
if (mMinZoomScale > mMaxZoomScale) {
915+
Log.w(LOGTAG, "mMinZoom > mMaxZoom!!! " + mMinZoomScale + " > " + mMaxZoomScale,
916+
new Exception());
917+
mMaxZoomScale = mMinZoomScale;
918+
}
919+
}
920+
912921
public void onSizeChanged(int w, int h, int ow, int oh) {
913922
// reset zoom and anchor to the top left corner of the screen
914923
// unless we are already zooming
@@ -933,6 +942,7 @@ public void onSizeChanged(int w, int h, int ow, int oh) {
933942
if (mInitialScale > 0 && mInitialScale < mMinZoomScale) {
934943
mMinZoomScale = mInitialScale;
935944
}
945+
sanitizeMinMaxScales();
936946
}
937947

938948
dismissZoomPicker();
@@ -1004,6 +1014,7 @@ public void updateZoomRange(WebViewCore.ViewState viewState,
10041014
} else {
10051015
mMaxZoomScale = viewState.mMaxScale;
10061016
}
1017+
sanitizeMinMaxScales();
10071018
}
10081019

10091020
/**
@@ -1033,6 +1044,7 @@ public boolean onNewPicture(WebViewCore.DrawData drawData) {
10331044
if (!mMinZoomScaleFixed || settings.getUseWideViewPort()) {
10341045
mMinZoomScale = newZoomOverviewScale;
10351046
mMaxZoomScale = Math.max(mMaxZoomScale, mMinZoomScale);
1047+
sanitizeMinMaxScales();
10361048
}
10371049
// fit the content width to the current view for the first new picture
10381050
// after first layout.
@@ -1113,6 +1125,7 @@ public void onFirstLayout(WebViewCore.DrawData drawData) {
11131125
mMinZoomScale = (mInitialScale > 0) ?
11141126
Math.min(mInitialScale, overviewScale) : overviewScale;
11151127
mMaxZoomScale = Math.max(mMaxZoomScale, mMinZoomScale);
1128+
sanitizeMinMaxScales();
11161129
}
11171130

11181131
if (!mWebView.drawHistory()) {

0 commit comments

Comments
 (0)