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

Commit 608f9f47 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

When zooming, do not draw the WebTextView. Resize it when done.

Fix for issue http://b/issue?id=2074429

Change-Id: Iae46df57310a360f07c9d6afef24ca3ff9d04bdc
parent 3c32474f
Loading
Loading
Loading
Loading
+35 −0
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@ import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver;
import android.view.animation.AlphaAnimation;
import android.view.animation.AlphaAnimation;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebTextView.AutoCompleteAdapter;
import android.webkit.WebTextView.AutoCompleteAdapter;
import android.webkit.WebViewCore.EventHub;
import android.webkit.WebViewCore.EventHub;
@@ -2733,6 +2734,15 @@ public class WebView extends AbsoluteLayout
        }
        }
    }
    }


    /**
     * Need to adjust the WebTextView after a change in zoom, since mActualScale
     * has changed.  This is especially important for password fields, which are
     * drawn by the WebTextView, since it conveys more information than what
     * webkit draws.  Thus we need to reposition it to show in the correct
     * place.
     */
    private boolean mNeedToAdjustWebTextView;

    private void drawCoreAndCursorRing(Canvas canvas, int color,
    private void drawCoreAndCursorRing(Canvas canvas, int color,
        boolean drawCursorRing) {
        boolean drawCursorRing) {
        if (mDrawHistory) {
        if (mDrawHistory) {
@@ -2756,6 +2766,20 @@ public class WebView extends AbsoluteLayout
                zoomScale = mZoomScale;
                zoomScale = mZoomScale;
                // set mZoomScale to be 0 as we have done animation
                // set mZoomScale to be 0 as we have done animation
                mZoomScale = 0;
                mZoomScale = 0;
                if (mNeedToAdjustWebTextView) {
                    mNeedToAdjustWebTextView = false;
                    mWebTextView.setTextSize(contentToViewDimension(
                            nativeFocusCandidateTextSize()));
                    Rect bounds = nativeFocusCandidateNodeBounds();
                    Rect vBox = contentToView(bounds);
                    mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
                            vBox.height());
                    // If it is a password field, start drawing the
                    // WebTextView once again.
                    if (nativeFocusCandidateIsPassword()) {
                        mWebTextView.setInPassword(true);
                    }
                }
            }
            }
            float scale = zoomScale * mInvInitialZoomScale;
            float scale = zoomScale * mInvInitialZoomScale;
            int tx = Math.round(scale * (mInitialScrollX + mZoomCenterX)
            int tx = Math.round(scale * (mInitialScrollX + mZoomCenterX)
@@ -2768,6 +2792,17 @@ public class WebView extends AbsoluteLayout
                    * zoomScale)) + mScrollY;
                    * zoomScale)) + mScrollY;
            canvas.translate(tx, ty);
            canvas.translate(tx, ty);
            canvas.scale(zoomScale, zoomScale);
            canvas.scale(zoomScale, zoomScale);
            if (inEditingMode() && !mNeedToAdjustWebTextView
                    && mZoomScale != 0) {
                // The WebTextView is up.  Keep track of this so we can adjust
                // its size and placement when we finish zooming
                mNeedToAdjustWebTextView = true;
                // If it is in password mode, turn it off so it does not draw
                // misplaced.
                if (nativeFocusCandidateIsPassword()) {
                    mWebTextView.setInPassword(false);
                }
            }
        } else {
        } else {
            canvas.scale(mActualScale, mActualScale);
            canvas.scale(mActualScale, mActualScale);
        }
        }