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

Commit e832b63c authored by Mangesh Ghiware's avatar Mangesh Ghiware
Browse files

Revert change to setInitialScale() to take display density into account.

Updated WebView documentation to clarify this behavior.

Additionally, if target-densityDpi is specified in the meta viewport
tag, update the display density in ZoomManager.

Bug: 5477652
Bug: 5327492
Change-Id: I176e87489f76a2ee6595d76a006e302b07595de1
parent 6a54a997
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -799,7 +799,7 @@ public class WebSettings {
    public void setDefaultZoom(ZoomDensity zoom) {
        if (mDefaultZoom != zoom) {
            mDefaultZoom = zoom;
            mWebView.updateDefaultZoomDensity(zoom.value);
            mWebView.adjustDefaultZoomDensity(zoom.value);
        }
    }

+8 −2
Original line number Diff line number Diff line
@@ -1341,9 +1341,13 @@ public class WebView extends AbsoluteLayout
        }
    }

    /* package */void updateDefaultZoomDensity(int zoomDensity) {
    /* package */ void adjustDefaultZoomDensity(int zoomDensity) {
        final float density = mContext.getResources().getDisplayMetrics().density
                * 100 / zoomDensity;
        updateDefaultZoomDensity(density);
    }

    /* package */ void updateDefaultZoomDensity(float density) {
        mNavSlop = (int) (16 * density);
        mZoomManager.updateDefaultZoomDensity(density);
    }
@@ -2469,7 +2473,9 @@ public class WebView extends AbsoluteLayout
     * Set the initial scale for the WebView. 0 means default. If
     * {@link WebSettings#getUseWideViewPort()} is true, it zooms out all the
     * way. Otherwise it starts with 100%. If initial scale is greater than 0,
     * WebView starts will this value as initial scale.
     * WebView starts with this value as initial scale.
     * Please note that unlike the scale properties in the viewport meta tag,
     * this method doesn't take the screen density into account.
     *
     * @param scaleInPercent The initial scale in percent.
     */
+4 −1
Original line number Diff line number Diff line
@@ -2336,6 +2336,9 @@ public final class WebViewCore {
            adjust = (float) mContext.getResources().getDisplayMetrics().densityDpi
                    / mViewportDensityDpi;
        }
        if (adjust != mWebView.getDefaultZoomScale()) {
            mWebView.updateDefaultZoomDensity(adjust);
        }
        int defaultScale = (int) (adjust * 100);

        if (mViewportInitialScale > 0) {
@@ -2546,7 +2549,7 @@ public final class WebViewCore {
    // called by JNI
    private void restoreScale(float scale, float textWrapScale) {
        if (mBrowserFrame.firstLayoutDone() == false) {
            mIsRestored = scale > 0;
            mIsRestored = true;
            mRestoredScale = scale;
            if (mSettings.getUseWideViewPort()) {
                mRestoredTextWrapScale = textWrapScale;
+1 −1
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ class ZoomManager {
    }

    public final void setInitialScaleInPercent(int scaleInPercent) {
        mInitialScale = scaleInPercent * mDisplayDensity * 0.01f;
        mInitialScale = scaleInPercent * 0.01f;
    }

    public final float computeScaleWithLimits(float scale) {