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

Commit 15c5ddb7 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Refactor the double tap zoom code into ZoomManager.

This CL is one in a series of CL's that is intended to refactor
the zoom logic from WebView to ZoomManager.

Change-Id: Icf88f7bd45068dddb31913903403acc7a8f21063
http://b/2671604
parent 4b983d9f
Loading
Loading
Loading
Loading
+18 −101
Original line number Diff line number Diff line
@@ -524,11 +524,6 @@ public class WebView extends AbsoluteLayout
    // JavaScript or ones for which no accessibility script exists
    private AccessibilityInjector mAccessibilityInjector;

    // the anchor point in the document space where VIEW_SIZE_CHANGED should
    // apply to
    private int mAnchorX;
    private int mAnchorY;

    // the color used to highlight the touch rectangles
    private static final int mHightlightColor = 0x33000000;
    // the round corner for the highlight path
@@ -2178,11 +2173,6 @@ public class WebView extends AbsoluteLayout
        r.bottom = Math.min(viewToContentYf(ri.bottom), (float)mContentHeight);
    }

    void setViewSizeAnchor(int x, int y) {
        mAnchorX = x;
        mAnchorY = y;
    }

    static class ViewSizeData {
        int mWidth;
        int mHeight;
@@ -2228,12 +2218,12 @@ public class WebView extends AbsoluteLayout
            data.mScale = mZoomManager.mActualScale;
            data.mIgnoreHeight = mZoomManager.isFixedLengthAnimationInProgress()
                    && !mHeightCanMeasure;
            data.mAnchorX = mAnchorX;
            data.mAnchorY = mAnchorY;
            data.mAnchorX = mZoomManager.getDocumentAnchorX();
            data.mAnchorY = mZoomManager.getDocumentAnchorY();
            mWebViewCore.sendMessage(EventHub.VIEW_SIZE_CHANGED, data);
            mLastWidthSent = newWidth;
            mLastHeightSent = newHeight;
            mAnchorX = mAnchorY = 0;
            mZoomManager.clearDocumentAnchor();
            return true;
        }
        return false;
@@ -3449,7 +3439,6 @@ public class WebView extends AbsoluteLayout
        boolean zoom = mZoomManager.mActualScale < mZoomManager.getDefaultScale();
        if (zoom) {
            mZoomManager.setZoomCenter(mLastTouchX, mLastTouchY);
            mZoomManager.mInZoomOverview = false;
            mZoomManager.setZoomScale(mZoomManager.getDefaultScale(), false);
        }
        if (isTextView) {
@@ -4831,7 +4820,7 @@ public class WebView extends AbsoluteLayout
                            ted.mReprocess = mDeferTouchProcess;
                            mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
                        } else if (mPreventDefault != PREVENT_DEFAULT_YES){
                            doDoubleTap();
                            mZoomManager.handleDoubleTap(mLastTouchX, mLastTouchY);
                            mTouchMode = TOUCH_DONE_MODE;
                        }
                        break;
@@ -5598,23 +5587,16 @@ public class WebView extends AbsoluteLayout
     * Return true if the view (Plugin) is fully visible and maximized inside
     * the WebView.
     */
    private boolean isPluginFitOnScreen(ViewManager.ChildView view) {
        int viewWidth = getViewWidth();
        int viewHeight = getViewHeightWithTitle();
        float scale = Math.min((float) viewWidth / view.width,
                (float) viewHeight / view.height);
    boolean isPluginFitOnScreen(ViewManager.ChildView view) {
        final int viewWidth = getViewWidth();
        final int viewHeight = getViewHeightWithTitle();
        float scale = Math.min((float) viewWidth / view.width, (float) viewHeight / view.height);
        scale = mZoomManager.computeScaleWithLimits(scale);
        if (!mZoomManager.willScaleTriggerZoom(scale)) {
            if (contentToViewX(view.x) >= mScrollX
                    && contentToViewX(view.x + view.width) <= mScrollX
                            + viewWidth
        return !mZoomManager.willScaleTriggerZoom(scale)
                && contentToViewX(view.x) >= mScrollX
                && contentToViewX(view.x + view.width) <= mScrollX + viewWidth
                && contentToViewY(view.y) >= mScrollY
                    && contentToViewY(view.y + view.height) <= mScrollY
                            + viewHeight) {
                return true;
            }
        }
        return false;
                && contentToViewY(view.y + view.height) <= mScrollY + viewHeight;
    }

    /*
@@ -5623,7 +5605,7 @@ public class WebView extends AbsoluteLayout
     * animated scroll to center it. If the zoom needs to be changed, find the
     * zoom center and do a smooth zoom transition.
     */
    private void centerFitRect(int docX, int docY, int docWidth, int docHeight) {
    void centerFitRect(int docX, int docY, int docWidth, int docHeight) {
        int viewWidth = getViewWidth();
        int viewHeight = getViewHeightWithTitle();
        float scale = Math.min((float) viewWidth / docWidth, (float) viewHeight
@@ -5667,70 +5649,6 @@ public class WebView extends AbsoluteLayout
        }
    }

    // Rule for double tap:
    // 1. if the current scale is not same as the text wrap scale and layout
    //    algorithm is NARROW_COLUMNS, fit to column;
    // 2. if the current state is not overview mode, change to overview mode;
    // 3. if the current state is overview mode, change to default scale.
    private void doDoubleTap() {
        if (mWebViewCore.getSettings().getUseWideViewPort() == false) {
            return;
        }
        mZoomManager.setZoomCenter(mLastTouchX, mLastTouchY);
        mAnchorX = viewToContentX((int) mLastTouchX + mScrollX);
        mAnchorY = viewToContentY((int) mLastTouchX + mScrollY);
        WebSettings settings = getSettings();
        settings.setDoubleTapToastCount(0);
        // remove the zoom control after double tap
        mZoomManager.dismissZoomPicker();
        ViewManager.ChildView plugin = mViewManager.hitTest(mAnchorX, mAnchorY);
        if (plugin != null) {
            if (isPluginFitOnScreen(plugin)) {
                mZoomManager.zoomToOverview();
            } else {
                mZoomManager.mInZoomOverview = false;
                centerFitRect(plugin.x, plugin.y, plugin.width, plugin.height);
            }
            return;
        }
        boolean zoomToDefault = false;
        if ((settings.getLayoutAlgorithm() == WebSettings.LayoutAlgorithm.NARROW_COLUMNS)
                && mZoomManager.willScaleTriggerZoom(mZoomManager.mTextWrapScale)) {
            mZoomManager.refreshZoomScale(true);
            float overviewScale = (float) getViewWidth() / mZoomManager.mZoomOverviewWidth;
            if (!mZoomManager.willScaleTriggerZoom(overviewScale)) {
                mZoomManager.mInZoomOverview = true;
            }
        } else if (!mZoomManager.mInZoomOverview) {
            float newScale = (float) getViewWidth() / mZoomManager.mZoomOverviewWidth;
            if (mZoomManager.willScaleTriggerZoom(newScale)) {
                mZoomManager.zoomToOverview();
            } else if (mZoomManager.willScaleTriggerZoom(mZoomManager.getDefaultScale())) {
                zoomToDefault = true;
            }
        } else {
            zoomToDefault = true;
        }
        if (zoomToDefault) {
            int left = nativeGetBlockLeftEdge(mAnchorX, mAnchorY, mZoomManager.mActualScale);
            if (left != NO_LEFTEDGE) {
                // add a 5pt padding to the left edge.
                int viewLeft = contentToViewX(left < 5 ? 0 : (left - 5))
                        - mScrollX;
                // Re-calculate the zoom center so that the new scroll x will be
                // on the left edge.
                if (viewLeft > 0) {
                    mZoomManager.mZoomCenterX = viewLeft * mZoomManager.getDefaultScale()
                            / (mZoomManager.getDefaultScale() - mZoomManager.mActualScale);
                } else {
                    scrollBy(viewLeft, 0);
                    mZoomManager.mZoomCenterX = 0;
                }
            }
            mZoomManager.zoomToDefaultLevel(true);
        }
    }

    // Called by JNI to handle a touch on a node representing an email address,
    // address, or phone number
    private void overrideLoading(String url) {
@@ -6046,7 +5964,7 @@ public class WebView extends AbsoluteLayout
                            = (WebViewCore.RestoreState) msg.obj;
                    // mScrollX contains the new minPrefWidth
                    mZoomManager.updateZoomRange(restoreState, getViewWidth(),
                            restoreState.mScrollX, false);
                            restoreState.mScrollX);
                    break;
                }
                case NEW_PICTURE_MSG_ID: {
@@ -6286,7 +6204,7 @@ public class WebView extends AbsoluteLayout
                                // doDoubleTap() needs mLastTouchX/Y as anchor
                                mLastTouchX = contentToViewX(ted.mX) - mScrollX;
                                mLastTouchY = contentToViewY(ted.mY) - mScrollY;
                                doDoubleTap();
                                mZoomManager.handleDoubleTap(mLastTouchX, mLastTouchY);
                                mDeferTouchMode = TOUCH_DONE_MODE;
                                break;
                            case WebViewCore.ACTION_LONGPRESS:
@@ -6417,7 +6335,6 @@ public class WebView extends AbsoluteLayout

                case CENTER_FIT_RECT:
                    Rect r = (Rect)msg.obj;
                    mZoomManager.mInZoomOverview = false;
                    centerFitRect(r.left, r.top, r.width(), r.height());
                    break;

@@ -7070,6 +6987,6 @@ public class WebView extends AbsoluteLayout
    private native void     nativeUpdateCachedTextfield(String updatedText,
            int generation);
    // return NO_LEFTEDGE means failure.
    private static final int NO_LEFTEDGE = -1;
    private native int      nativeGetBlockLeftEdge(int x, int y, float scale);
    static final int NO_LEFTEDGE = -1;
    native int nativeGetBlockLeftEdge(int x, int y, float scale);
}
+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class ZoomControlEmbedded implements ZoomControlBase {

            WebSettings settings = mWebView.getSettings();
            int count = settings.getDoubleTapToastCount();
            if (mZoomManager.mInZoomOverview && count > 0) {
            if (mZoomManager.isInZoomOverview() && count > 0) {
                settings.setDoubleTapToastCount(--count);
                Toast.makeText(mWebView.getContext(),
                        com.android.internal.R.string.double_tap_toast,
@@ -67,7 +67,7 @@ class ZoomControlEmbedded implements ZoomControlBase {
        }

        boolean canZoomIn = mZoomManager.canZoomIn();
        boolean canZoomOut = mZoomManager.canZoomOut() && !mZoomManager.mInZoomOverview;
        boolean canZoomOut = mZoomManager.canZoomOut() && !mZoomManager.isInZoomOverview();
        if (!canZoomIn && !canZoomOut) {
            // Hide the zoom in and out buttons if the page cannot zoom
            mZoomButtonsController.getZoomControls().setVisibility(View.GONE);
+163 −68
Original line number Diff line number Diff line
@@ -71,11 +71,17 @@ class ZoomManager {
    // locks the minimum ZoomScale to the value currently set in mMinZoomScale
    private boolean mMinZoomScaleFixed = true;

    // while in the zoom overview mode, the page's width is fully fit to the
    // current window. The page is alive, in another words, you can click to
    // follow the links. Double tap will toggle between zoom overview mode and
    // the last zoom scale.
    /*
     * 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
     * active, in other words, you can click to follow the links. We cache a
     * boolean to enable us to quickly check whether or not we are in overview
     * mode, but this value should only be modified by changes to the zoom
     * scale.
     */
    boolean mInZoomOverview = false;
    private int mZoomOverviewWidth;
    private float mInvZoomOverviewWidth;

    // These keep track of the center point of the zoom and they are used to
    // determine the point around which we should zoom. They are stored in view
@@ -83,9 +89,17 @@ class ZoomManager {
    float mZoomCenterX;
    float mZoomCenterY;

    // ideally mZoomOverviewWidth should be mContentWidth. But sites like espn,
    // engadget always have wider mContentWidth no matter what viewport size is.
    int mZoomOverviewWidth = WebView.DEFAULT_VIEWPORT_WIDTH;
    /*
     * These values represent the point around which the screen should be
     * centered after zooming. In other words it is used to determine the center
     * point of the visible document after the page has finished zooming. This
     * is important because the zoom may have potentially reflowed the text and
     * we need to ensure the proper portion of the document remains on the
     * screen.
     */
    private int mAnchorX;
    private int mAnchorY;

    float mTextWrapScale;

    // the default zoom scale. This value will is initially set based on the
@@ -133,6 +147,13 @@ class ZoomManager {
    public ZoomManager(WebView webView, CallbackProxy callbackProxy) {
        mWebView = webView;
        mCallbackProxy = callbackProxy;

        /*
         * Ideally mZoomOverviewWidth should be mContentWidth. But sites like
         * ESPN and Engadget always have wider mContentWidth no matter what the
         * viewport size is.
         */
        setZoomOverviewWidth(WebView.DEFAULT_VIEWPORT_WIDTH);
    }

    public void init(float density) {
@@ -167,6 +188,18 @@ class ZoomManager {
        return mDefaultScale;
    }

    public int getDocumentAnchorX() {
        return mAnchorX;
    }

    public int getDocumentAnchorY() {
        return mAnchorY;
    }

    public void clearDocumentAnchor() {
        mAnchorX = mAnchorY = 0;
    }

    public void setZoomCenter(float x, float y) {
        mZoomCenterX = x;
        mZoomCenterY = y;
@@ -206,7 +239,6 @@ class ZoomManager {
    }

    public boolean zoomIn() {
        mInZoomOverview = false;
        return zoom(1.25f);
    }

@@ -221,27 +253,11 @@ class ZoomManager {
        // Center zooming to the center of the screen.
        mZoomCenterX = mWebView.getViewWidth() * .5f;
        mZoomCenterY = mWebView.getViewHeight() * .5f;
        int anchorX = mWebView.viewToContentX((int) mZoomCenterX + mWebView.getScrollX());
        int anchorY = mWebView.viewToContentY((int) mZoomCenterY + mWebView.getScrollY());
        mWebView.setViewSizeAnchor(anchorX, anchorY);
        mAnchorX = mWebView.viewToContentX((int) mZoomCenterX + mWebView.getScrollX());
        mAnchorY = mWebView.viewToContentY((int) mZoomCenterY + mWebView.getScrollY());
        return startZoomAnimation(mActualScale * zoomMultiplier, true);
    }

    public void zoomToOverview() {
        mInZoomOverview = true;
        // Force the titlebar fully reveal in overview mode
        int scrollY = mWebView.getScrollY();
        if (scrollY < mWebView.getTitleHeight()) {
            mWebView.updateScrollCoordinates(mWebView.getScrollX(), 0);
        }
        startZoomAnimation((float) mWebView.getViewWidth() / mZoomOverviewWidth, true);
    }

    public void zoomToDefaultLevel(boolean reflowText) {
        mInZoomOverview = false;
        startZoomAnimation(mDefaultScale, reflowText);
    }

    /**
     * Initiates an animated zoom of the WebView.
     *
@@ -341,14 +357,14 @@ class ZoomManager {
    }

    private void setZoomScale(float scale, boolean reflowText, boolean force) {
        if (scale < mMinZoomScale) {
            scale = mMinZoomScale;
            // set mInZoomOverview for non mobile sites
            if (scale < mDefaultScale) {
        final boolean isScaleLessThanMinZoom = scale < mMinZoomScale;
        scale = computeScaleWithLimits(scale);

        // determine whether or not we are in the zoom overview mode
        if (isScaleLessThanMinZoom && mMinZoomScale < mDefaultScale) {
            mInZoomOverview = true;
            }
        } else if (scale > mMaxZoomScale) {
            scale = mMaxZoomScale;
        } else {
            mInZoomOverview = !exceedsMinScaleIncrement(scale, getZoomOverviewScale());
        }

        if (reflowText) {
@@ -400,6 +416,102 @@ class ZoomManager {
        }
    }

    /**
     * The double tap gesture can result in different behaviors depending on the
     * content that is tapped.
     *
     * (1) PLUGINS: If the taps occur on a plugin then we maximize the plugin on
     * the screen. If the plugin is already maximized then zoom the user into
     * overview mode.
     *
     * (2) HTML/OTHER: If the taps occur outside a plugin then the following
     * heuristic is used.
     *   A. If the current scale is not the same as the text wrap scale and the
     *      layout algorithm specifies the use of NARROW_COLUMNS, then fit to
     *      column by reflowing the text.
     *   B. If the page is not in overview mode then change to overview mode.
     *   C. If the page is in overmode then change to the default scale.
     */
    public void handleDoubleTap(float lastTouchX, float lastTouchY) {
        WebSettings settings = mWebView.getSettings();
        if (settings == null || settings.getUseWideViewPort() == false) {
            return;
        }

        setZoomCenter(lastTouchX, lastTouchY);
        mAnchorX = mWebView.viewToContentX((int) lastTouchX + mWebView.getScrollX());
        mAnchorY = mWebView.viewToContentY((int) lastTouchY + mWebView.getScrollY());
        settings.setDoubleTapToastCount(0);

        // remove the zoom control after double tap
        dismissZoomPicker();

        /*
         * If the double tap was on a plugin then either zoom to maximize the
         * plugin on the screen or scale to overview mode.
         */
        ViewManager.ChildView plugin = mWebView.mViewManager.hitTest(mAnchorX, mAnchorY);
        if (plugin != null) {
            if (mWebView.isPluginFitOnScreen(plugin)) {
                zoomToOverview();
            } else {
                mWebView.centerFitRect(plugin.x, plugin.y, plugin.width, plugin.height);
            }
            return;
        }

        if (settings.getLayoutAlgorithm() == WebSettings.LayoutAlgorithm.NARROW_COLUMNS
                && willScaleTriggerZoom(mTextWrapScale)) {
            refreshZoomScale(true);
        } else if (!mInZoomOverview) {
            zoomToOverview();
        } else {
            zoomToDefaultLevel();
        }
    }

    private void setZoomOverviewWidth(int width) {
        mZoomOverviewWidth = width;
        mInvZoomOverviewWidth = 1.0f / width;
    }

    private float getZoomOverviewScale() {
        return mWebView.getViewWidth() * mInvZoomOverviewWidth;
    }

    public boolean isInZoomOverview() {
        return mInZoomOverview;
    }

    private void zoomToOverview() {
        if (!willScaleTriggerZoom(getZoomOverviewScale())) return;

        // Force the titlebar fully reveal in overview mode
        int scrollY = mWebView.getScrollY();
        if (scrollY < mWebView.getTitleHeight()) {
            mWebView.updateScrollCoordinates(mWebView.getScrollX(), 0);
        }
        startZoomAnimation(getZoomOverviewScale(), true);
    }

    private void zoomToDefaultLevel() {
        int left = mWebView.nativeGetBlockLeftEdge(mAnchorX, mAnchorY, mActualScale);
        if (left != WebView.NO_LEFTEDGE) {
            // add a 5pt padding to the left edge.
            int viewLeft = mWebView.contentToViewX(left < 5 ? 0 : (left - 5))
                    - mWebView.getScrollX();
            // Re-calculate the zoom center so that the new scroll x will be
            // on the left edge.
            if (viewLeft > 0) {
                mZoomCenterX = viewLeft * mDefaultScale / (mDefaultScale - mActualScale);
            } else {
                mWebView.scrollBy(viewLeft, 0);
                mZoomCenterX = 0;
            }
        }
        startZoomAnimation(mDefaultScale, true);
    }

    public void updateMultiTouchSupport(Context context) {
        // check the preconditions
        assert mWebView.getSettings() != null;
@@ -442,8 +554,6 @@ class ZoomManager {

        public boolean onScaleBegin(ScaleGestureDetector detector) {
            dismissZoomPicker();
            // reset the zoom overview mode so that the page won't auto grow
            mInZoomOverview = false;
            mWebView.mViewManager.startZoom();
            mWebView.onPinchToZoomAnimationStart();
            return true;
@@ -470,9 +580,8 @@ class ZoomManager {
        public void onScaleEnd(ScaleGestureDetector detector) {
            if (mPinchToZoomAnimating) {
                mPinchToZoomAnimating = false;
                mWebView.setViewSizeAnchor(mWebView.viewToContentX((int) mZoomCenterX
                        + mWebView.getScrollX()), mWebView.viewToContentY((int) mZoomCenterY
                        + mWebView.getScrollY()));
                mAnchorX = mWebView.viewToContentX((int) mZoomCenterX + mWebView.getScrollX());
                mAnchorY = mWebView.viewToContentY((int) mZoomCenterY + mWebView.getScrollY());
                // don't reflow when zoom in; when zoom out, do reflow if the
                // new scale is almost minimum scale;
                boolean reflowNow = !canZoomOut() || (mActualScale <= 0.8 * mTextWrapScale);
@@ -495,10 +604,8 @@ class ZoomManager {
            int visibleTitleHeight = mWebView.getVisibleTitleHeight();
            mZoomCenterX = 0;
            mZoomCenterY = visibleTitleHeight;
            int anchorX = mWebView.viewToContentX(mWebView.getScrollX());
            int anchorY = mWebView.viewToContentY(visibleTitleHeight + mWebView.getScrollY());
            mWebView.setViewSizeAnchor(anchorX, anchorY);

            mAnchorX = mWebView.viewToContentX(mWebView.getScrollX());
            mAnchorY = mWebView.viewToContentY(visibleTitleHeight + mWebView.getScrollY());
        }

        // update mMinZoomScale if the minimum zoom scale is not fixed
@@ -545,17 +652,12 @@ class ZoomManager {
    }

    public void updateZoomRange(WebViewCore.RestoreState restoreState,
            int viewWidth, int minPrefWidth, boolean updateZoomOverview) {
            int viewWidth, int minPrefWidth) {
        if (restoreState.mMinScale == 0) {
            if (restoreState.mMobileSite) {
                if (minPrefWidth > Math.max(0, viewWidth)) {
                    mMinZoomScale = (float) viewWidth / minPrefWidth;
                    mMinZoomScaleFixed = false;
                    if (updateZoomOverview) {
                        WebSettings settings = mWebView.getSettings();
                        mInZoomOverview = settings.getUseWideViewPort() &&
                                settings.getLoadWithOverviewMode();
                    }
                } else {
                    mMinZoomScale = restoreState.mDefaultScale;
                    mMinZoomScaleFixed = true;
@@ -580,7 +682,6 @@ class ZoomManager {
     * should only be called from the UI thread's message handler.
     */
    public void onNewPicture(WebViewCore.DrawData drawData) {

        final int viewWidth = mWebView.getViewWidth();

        if (mWebView.getSettings().getUseWideViewPort()) {
@@ -588,21 +689,19 @@ class ZoomManager {
            // sMaxViewportWidth so that if the page doesn't behave
            // well, the WebView won't go insane. limit the lower
            // bound to match the default scale for mobile sites.
            mZoomOverviewWidth = Math.min(WebView.sMaxViewportWidth,
            setZoomOverviewWidth(Math.min(WebView.sMaxViewportWidth,
                    Math.max((int) (viewWidth * mInvDefaultScale),
                            Math.max(drawData.mMinPrefWidth,
                                    drawData.mViewPoint.x)));
                            Math.max(drawData.mMinPrefWidth, drawData.mViewPoint.x))));
        }

        final float zoomOverviewScale = getZoomOverviewScale();
        if (!mMinZoomScaleFixed) {
            mMinZoomScale = (float) viewWidth / mZoomOverviewWidth;
        }
        if (!mWebView.drawHistory() && mInZoomOverview) {
            // fit the content width to the current view. Ignore
            // the rounding error case.
            if (Math.abs((viewWidth * mInvActualScale) - mZoomOverviewWidth) > 1) {
                setZoomScale((float) viewWidth / mZoomOverviewWidth,
                        !willScaleTriggerZoom(mTextWrapScale));
            mMinZoomScale = zoomOverviewScale;
        }
        // fit the content width to the current view. Ignore the rounding error case.
        if (!mWebView.drawHistory() && mInZoomOverview
                && Math.abs((viewWidth * mInvActualScale) - mZoomOverviewWidth) > 1) {
            setZoomScale(zoomOverviewScale, !willScaleTriggerZoom(mTextWrapScale));
        }
    }

@@ -618,11 +717,9 @@ class ZoomManager {

        WebViewCore.RestoreState restoreState = drawData.mRestoreState;
        final Point viewSize = drawData.mViewPoint;
        updateZoomRange(restoreState, viewSize.x, drawData.mMinPrefWidth, true);
        updateZoomRange(restoreState, viewSize.x, drawData.mMinPrefWidth);

        if (!mWebView.drawHistory()) {
            mInZoomOverview = false;

            final float scale;
            final boolean reflowText;

@@ -635,9 +732,7 @@ class ZoomManager {
                reflowText = false;
            } else {
                WebSettings settings = mWebView.getSettings();
                mInZoomOverview = settings.getUseWideViewPort() &&
                        settings.getLoadWithOverviewMode();
                if (mInZoomOverview) {
                if (settings.getUseWideViewPort() && settings.getLoadWithOverviewMode()) {
                    scale = (float) mWebView.getViewWidth() / WebView.DEFAULT_VIEWPORT_WIDTH;
                } else {
                    scale = restoreState.mTextWrapScale;