Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6013d8c2 authored by John Reck's avatar John Reck
Browse files

Fix DPI scaling on TVDPI

 Bug: 6891214
 tvdpi has a density of 1.3312501 which we fail on as we assume
 you can take density and multiply by 100, cast to an int, and
 divide by 100f to get back to the original density. Force this
 assumption to be true by truncating density

Change-Id: I0caeb7768ee002f935b41c77a5579ffeed491f82
parent 5dbeb6a8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2536,6 +2536,9 @@ public final class WebViewCore {
            adjust = (float) mContext.getResources().getDisplayMetrics().densityDpi
                    / mViewportDensityDpi;
        }
        // We make bad assumptions about multiplying and dividing by 100, force
        // them to be true with this hack
        adjust = ((int) (adjust * 100)) / 100.0f;
        // Remove any update density messages in flight.
        // If the density is indeed different from WebView's default scale,
        // a new message will be queued.
+13 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@ class ZoomManager {
        if (!exceedsMinScaleIncrement(mMinZoomScale, mMaxZoomScale)) {
            mMaxZoomScale = mMinZoomScale;
        }
        sanitizeMinMaxScales();
    }

    public final float getScale() {
@@ -909,6 +910,14 @@ class ZoomManager {
        }
    }

    private void sanitizeMinMaxScales() {
        if (mMinZoomScale > mMaxZoomScale) {
            Log.w(LOGTAG, "mMinZoom > mMaxZoom!!! " + mMinZoomScale + " > " + mMaxZoomScale,
                    new Exception());
            mMaxZoomScale = mMinZoomScale;
        }
    }

    public void onSizeChanged(int w, int h, int ow, int oh) {
        // reset zoom and anchor to the top left corner of the screen
        // unless we are already zooming
@@ -933,6 +942,7 @@ class ZoomManager {
            if (mInitialScale > 0 && mInitialScale < mMinZoomScale) {
                mMinZoomScale = mInitialScale;
            }
            sanitizeMinMaxScales();
        }

        dismissZoomPicker();
@@ -1004,6 +1014,7 @@ class ZoomManager {
        } else {
            mMaxZoomScale = viewState.mMaxScale;
        }
        sanitizeMinMaxScales();
    }

    /**
@@ -1033,6 +1044,7 @@ class ZoomManager {
        if (!mMinZoomScaleFixed || settings.getUseWideViewPort()) {
            mMinZoomScale = newZoomOverviewScale;
            mMaxZoomScale = Math.max(mMaxZoomScale, mMinZoomScale);
            sanitizeMinMaxScales();
        }
        // fit the content width to the current view for the first new picture
        // after first layout.
@@ -1113,6 +1125,7 @@ class ZoomManager {
            mMinZoomScale = (mInitialScale > 0) ?
                    Math.min(mInitialScale, overviewScale) : overviewScale;
            mMaxZoomScale = Math.max(mMaxZoomScale, mMinZoomScale);
            sanitizeMinMaxScales();
        }

        if (!mWebView.drawHistory()) {