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

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

Merge "Fix scrolling behavior for text input and textarea."

parents 4d7d5268 c6c83ce4
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -6147,18 +6147,19 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                long timeSinceLastUpdate = currentTime - mLastEditScroll;
                int deltaX = getTextScrollDelta(scrollSpeedX, timeSinceLastUpdate);
                int deltaY = getTextScrollDelta(scrollSpeedY, timeSinceLastUpdate);
                mLastEditScroll = currentTime;
                if (deltaX == 0 && deltaY == 0) {
                    // By probability no text scroll this time. Try again later.
                    mPrivateHandler.sendEmptyMessageDelayed(SCROLL_EDIT_TEXT,
                            TEXT_SCROLL_FIRST_SCROLL_MS);
                } else {
                int scrollX = getTextScrollX() + deltaX;
                scrollX = Math.min(getMaxTextScrollX(), scrollX);
                scrollX = Math.max(0, scrollX);
                int scrollY = getTextScrollY() + deltaY;
                scrollY = Math.min(getMaxTextScrollY(), scrollY);
                scrollY = Math.max(0, scrollY);

                mLastEditScroll = currentTime;
                if (scrollX == getTextScrollX() && scrollY == getTextScrollY()) {
                    // By probability no text scroll this time. Try again later.
                    mPrivateHandler.sendEmptyMessageDelayed(SCROLL_EDIT_TEXT,
                            TEXT_SCROLL_FIRST_SCROLL_MS);
                } else {
                    scrollEditText(scrollX, scrollY);
                    int selectionX = getSelectionCoordinate(x,
                            mEditTextContentBounds.left, mEditTextContentBounds.right);
@@ -7429,7 +7430,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                        mEditTextLayerId = initData.mNodeLayerId;
                        nativeMapLayerRect(mNativeClass, mEditTextLayerId,
                                mEditTextContentBounds);
                        mEditTextContent.set(initData.mContentRect);
                        mEditTextContent.set(initData.mClientRect);
                        relocateAutoCompletePopup();
                    }
                    break;
+3 −8
Original line number Diff line number Diff line
@@ -962,7 +962,7 @@ public final class WebViewCore {
        public int mMaxLength;
        public Rect mContentBounds;
        public int mNodeLayerId;
        public Rect mContentRect;
        public Rect mClientRect;
    }

    // mAction of TouchEventData can be MotionEvent.getAction() which uses the
@@ -1309,13 +1309,8 @@ public final class WebViewCore {
                            } else {
                                xPercent = ((Float) msg.obj).floatValue();
                            }
                            Rect contentBounds = new Rect();
                            nativeScrollFocusedTextInput(mNativeClass, xPercent,
                                    msg.arg2, contentBounds);
                            Message.obtain(
                                    mWebViewClassic.mPrivateHandler,
                                    WebViewClassic.UPDATE_CONTENT_BOUNDS,
                                    contentBounds).sendToTarget();
                                    msg.arg2);
                            break;

                        case LOAD_URL: {
@@ -2856,7 +2851,7 @@ public final class WebViewCore {
     * Scroll the focused textfield to (xPercent, y) in document space
     */
    private native void nativeScrollFocusedTextInput(int nativeClass,
            float xPercent, int y, Rect contentBounds);
            float xPercent, int y);

    // these must be in document space (i.e. not scaled/zoomed).
    private native void nativeSetScrollOffset(int nativeClass,