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

Commit 3fed1bd4 authored by Shimeng (Simon) Wang's avatar Shimeng (Simon) Wang Committed by Android (Google) Code Review
Browse files

Merge "Use website preferred width as the fixed viewport."

parents bfb619a1 14bcc0e7
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ public class WebSettings {
    private boolean         mUseDoubleTree = false;
    private boolean         mUseWideViewport = false;
    private boolean         mUseFixedViewport = false;
    private int             mMaxFixedViewportWidth = WebView.DEFAULT_VIEWPORT_WIDTH;
    private boolean         mSupportMultipleWindows = false;
    private boolean         mShrinksStandaloneImagesToFit = false;
    private long            mMaximumDecodedImageSize = 0; // 0 means default
@@ -324,8 +325,9 @@ public class WebSettings {

        // Detect tablet device for fixed viewport mode.
        final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        mUseFixedViewport = (metrics.density == 1.0f 
            && (metrics.widthPixels >= 800 ||metrics.heightPixels >= 800));
        final int landscapeWidth = Math.max(metrics.widthPixels, metrics.heightPixels);
        mUseFixedViewport = (metrics.density == 1.0f && landscapeWidth >= 800);
        mMaxFixedViewportWidth = (int) (landscapeWidth * 1.25);

        if (sLockForLocaleSettings == null) {
            sLockForLocaleSettings = new Object();
@@ -1515,6 +1517,13 @@ public class WebSettings {
        return mUseFixedViewport;
    }

    /**
     * Returns maximum fixed viewport width.
     */
    /* package */ int getMaxFixedViewportWidth() {
        return mMaxFixedViewportWidth;
    }

    /**
     * Returns whether private browsing is enabled.
     */
+1 −1
Original line number Diff line number Diff line
@@ -667,7 +667,7 @@ public class WebView extends AbsoluteLayout

    // If the site doesn't use the viewport meta tag to specify the viewport,
    // use DEFAULT_VIEWPORT_WIDTH as the default viewport width
    static final int DEFAULT_VIEWPORT_WIDTH = 1040;
    static final int DEFAULT_VIEWPORT_WIDTH = 980;

    // normally we try to fit the content to the minimum preferred width
    // calculated by the Webkit. To avoid the bad behavior when some site's
+8 −1
Original line number Diff line number Diff line
@@ -1706,7 +1706,7 @@ final class WebViewCore {
                }
            } else if (mViewportWidth > 0) {
                if (mSettings.getUseFixedViewport()) {
                    // Use website specified viewport width.
                    // Use website specified or desired fixed viewport width.
                    width = mViewportWidth;
                } else {
                    width = Math.max(w, mViewportWidth);
@@ -1827,6 +1827,13 @@ final class WebViewCore {
            }
            if (mInitialViewState != null) {
                draw.mViewState = mInitialViewState;
                if (mViewportWidth == -1 && mSettings.getUseFixedViewport() &&
                    mSettings.getUseWideViewPort()) {
                    // Use website's initial preferred width as the fixed viewport width.
                    mViewportWidth = Math.min(mSettings.getMaxFixedViewportWidth(),
                        draw.mMinPrefWidth);
                    draw.mViewState.mViewportWidth = mViewportWidth;
                }
                mInitialViewState = null;
            }
            if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw NEW_PICTURE_MSG_ID");