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

Commit 94345f45 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Fix zoom overview mode bug in the zoom manager.

Change-Id: Ia4c95e8014976ff6a1c5f3b19030abd78b532f96
http://b/2793303
parent a559e8b6
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.webkit;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.graphics.Point;
import android.os.Bundle;
import android.os.SystemClock;
@@ -27,9 +26,6 @@ import android.util.Log;
import android.view.ScaleGestureDetector;
import android.view.View;

import java.io.File;
import java.io.FileOutputStream;

/**
 * The ZoomManager is responsible for maintaining the WebView's current zoom
 * level state.  It is also responsible for managing the on-screen zoom controls
@@ -72,6 +68,15 @@ class ZoomManager {
    // Locks the minimum ZoomScale to the value currently set in mMinZoomScale.
    private boolean mMinZoomScaleFixed = true;

    /*
     * When loading a new page the WebView does not initially know the final
     * width of the page. Therefore, when a new page is loaded in overview mode
     * the overview scale is initialized to a default value. This flag is then
     * set and used to notify the ZoomManager to take the width of the next
     * picture from webkit and use that width to enter into zoom overview mode.
     */
    private boolean mInitialZoomOverview = false;

    /*
     * When in the zoom overview mode, the page's width is fully fit to the
     * current window. Additionally while the page is in this state it is
@@ -724,8 +729,9 @@ class ZoomManager {
            mMinZoomScale = zoomOverviewScale;
        }
        // fit the content width to the current view. Ignore the rounding error case.
        if (!mWebView.drawHistory() && mInZoomOverview
        if (!mWebView.drawHistory() && (mInZoomOverview || mInitialZoomOverview)
                && Math.abs((viewWidth * mInvActualScale) - mZoomOverviewWidth) > 1) {
            mInitialZoomOverview = false;
            setZoomScale(zoomOverviewScale, !willScaleTriggerZoom(mTextWrapScale));
        }
    }
@@ -758,6 +764,7 @@ class ZoomManager {
            } else {
                WebSettings settings = mWebView.getSettings();
                if (settings.getUseWideViewPort() && settings.getLoadWithOverviewMode()) {
                    mInitialZoomOverview = true;
                    scale = (float) mWebView.getViewWidth() / WebView.DEFAULT_VIEWPORT_WIDTH;
                } else {
                    scale = restoreState.mTextWrapScale;