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

Commit 43857a8d authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "Consider current scroll position to move text field into view."

parents 7c22b181 f7a1a84d
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -5541,8 +5541,8 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        if (visibleRect.contains(mEditTextContentBounds)) {
            return; // no need to scroll
        }
        nativeFindMaxVisibleRect(mNativeClass, mEditTextLayerId, visibleRect);
        syncSelectionCursors();
        nativeFindMaxVisibleRect(mNativeClass, mEditTextLayerId, visibleRect);
        final int buffer = Math.max(1, viewToContentDimension(EDIT_RECT_BUFFER));
        Rect showRect = new Rect(
                Math.max(0, mEditTextContentBounds.left - buffer),
@@ -5575,17 +5575,19 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            return; // no need to scroll
        }

        int scrollX = visibleRect.left;
        int scrollX = viewToContentX(getScrollX());
        if (visibleRect.left > showRect.left) {
            scrollX = showRect.left;
            // We are scrolled too far
            scrollX += showRect.left - visibleRect.left;
        } else if (visibleRect.right < showRect.right) {
            scrollX = Math.max(0, showRect.right - visibleRect.width());
            // We aren't scrolled enough to include the right
            scrollX += showRect.right - visibleRect.right;
        }
        int scrollY = visibleRect.top;
        int scrollY = viewToContentY(getScrollY());
        if (visibleRect.top > showRect.top) {
            scrollY = showRect.top;
            scrollY += showRect.top - visibleRect.top;
        } else if (visibleRect.bottom < showRect.bottom) {
            scrollY = Math.max(0, showRect.bottom - visibleRect.height());
            scrollY += showRect.bottom - visibleRect.bottom;
        }

        contentScrollTo(scrollX, scrollY, false);