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

Commit 5da91bd6 authored by Michael Kolb's avatar Michael Kolb
Browse files

fix position of WebTextView on scrolling layers

    Bug: 5677828

    depends on CL: 152845

Change-Id: Ia6fce3ef64954d99fe044e801d7f083055c8b880
parent 88f10c6c
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -507,7 +507,7 @@ public class WebView extends AbsoluteLayout
    private float mLastVelY;

    // The id of the native layer being scrolled.
    private int mScrollingLayer;
    private int mCurrentScrollingLayerId;
    private Rect mScrollingLayerRect = new Rect();

    // only trigger accelerated fling if the new velocity is at least
@@ -3665,7 +3665,7 @@ public class WebView extends AbsoluteLayout
        if (x == mScrollingLayerRect.left && y == mScrollingLayerRect.top) {
            return;
        }
        nativeScrollLayer(mScrollingLayer, x, y);
        nativeScrollLayer(mCurrentScrollingLayerId, x, y);
        mScrollingLayerRect.left = x;
        mScrollingLayerRect.top = y;
        onScrollChanged(mScrollX, mScrollY, mScrollX, mScrollY);
@@ -4470,6 +4470,7 @@ public class WebView extends AbsoluteLayout
        Rect vBox = contentToViewRect(contentBounds);
        Rect visibleRect = new Rect();
        calcOurVisibleRect(visibleRect);
        offsetByLayerScrollPosition(vBox);
        // If the textfield is on screen, place the WebTextView in
        // its new place, accounting for our new scroll/zoom values,
        // and adjust its textsize.
@@ -4505,6 +4506,14 @@ public class WebView extends AbsoluteLayout
        }
    }

    private void offsetByLayerScrollPosition(Rect box) {
        if ((mCurrentScrollingLayerId != 0)
                && (mCurrentScrollingLayerId == nativeFocusCandidateLayerId())) {
            box.offsetTo(box.left - mScrollingLayerRect.left,
                    box.top - mScrollingLayerRect.top);
        }
    }

    void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator,
            boolean isPictureAfterFirstLayout, boolean registerPageSwapCallback) {
        if (mNativeClass == 0)
@@ -4923,6 +4932,7 @@ public class WebView extends AbsoluteLayout
        // should be in content coordinates.
        Rect bounds = nativeFocusCandidateNodeBounds();
        Rect vBox = contentToViewRect(bounds);
        offsetByLayerScrollPosition(vBox);
        mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height());
        if (!Rect.intersects(bounds, visibleRect)) {
            revealSelection();
@@ -5514,10 +5524,10 @@ public class WebView extends AbsoluteLayout
        mMaxAutoScrollX = getViewWidth();
        mMinAutoScrollY = 0;
        mMaxAutoScrollY = getViewHeightWithTitle();
        mScrollingLayer = nativeScrollableLayer(viewToContentX(mSelectX),
        mCurrentScrollingLayerId = nativeScrollableLayer(viewToContentX(mSelectX),
                viewToContentY(mSelectY), mScrollingLayerRect,
                mScrollingLayerBounds);
        if (mScrollingLayer != 0) {
        if (mCurrentScrollingLayerId != 0) {
            if (mScrollingLayerRect.left != mScrollingLayerRect.right) {
                mMinAutoScrollX = Math.max(mMinAutoScrollX,
                        contentToViewX(mScrollingLayerBounds.left));
@@ -6003,9 +6013,9 @@ public class WebView extends AbsoluteLayout
    private void startScrollingLayer(float x, float y) {
        int contentX = viewToContentX((int) x + mScrollX);
        int contentY = viewToContentY((int) y + mScrollY);
        mScrollingLayer = nativeScrollableLayer(contentX, contentY,
        mCurrentScrollingLayerId = nativeScrollableLayer(contentX, contentY,
                mScrollingLayerRect, mScrollingLayerBounds);
        if (mScrollingLayer != 0) {
        if (mCurrentScrollingLayerId != 0) {
            mTouchMode = TOUCH_DRAG_LAYER_MODE;
        }
    }
@@ -6236,7 +6246,7 @@ public class WebView extends AbsoluteLayout
                    ted.mPointsInView[0] = new Point(x, y);
                    ted.mMetaState = ev.getMetaState();
                    ted.mReprocess = mDeferTouchProcess;
                    ted.mNativeLayer = mScrollingLayer;
                    ted.mNativeLayer = mCurrentScrollingLayerId;
                    ted.mNativeLayerRect.set(mScrollingLayerRect);
                    ted.mSequence = mTouchEventQueue.nextTouchSequence();
                    mTouchEventQueue.preQueueTouchEventData(ted);
@@ -6427,7 +6437,7 @@ public class WebView extends AbsoluteLayout
                    ted.mPointsInView[0] = new Point(x, y);
                    ted.mMetaState = ev.getMetaState();
                    ted.mReprocess = mDeferTouchProcess;
                    ted.mNativeLayer = mScrollingLayer;
                    ted.mNativeLayer = mCurrentScrollingLayerId;
                    ted.mNativeLayerRect.set(mScrollingLayerRect);
                    ted.mSequence = mTouchEventQueue.nextTouchSequence();
                    mTouchEventQueue.preQueueTouchEventData(ted);
@@ -6736,7 +6746,7 @@ public class WebView extends AbsoluteLayout
            // directions.  mTouchMode might be TOUCH_DRAG_MODE if we have
            // reached the edge of a layer but mScrollingLayer will be non-zero
            // if we initiated the drag on a layer.
            if (mScrollingLayer != 0) {
            if (mCurrentScrollingLayerId != 0) {
                final int contentX = viewToContentDimension(deltaX);
                final int contentY = viewToContentDimension(deltaY);

@@ -7258,7 +7268,7 @@ public class WebView extends AbsoluteLayout
                    + " vx=" + vx + " vy=" + vy
                    + " maxX=" + maxX + " maxY=" + maxY
                    + " scrollX=" + scrollX + " scrollY=" + scrollY
                    + " layer=" + mScrollingLayer);
                    + " layer=" + mCurrentScrollingLayerId);
        }

        // Allow sloppy flings without overscrolling at the edges.
@@ -8367,7 +8377,7 @@ public class WebView extends AbsoluteLayout
                        mSentAutoScrollMessage = false;
                        break;
                    }
                    if (mScrollingLayer == 0) {
                    if (mCurrentScrollingLayerId == 0) {
                        pinScrollBy(mAutoScrollX, mAutoScrollY, true, 0);
                    } else {
                        scrollLayerTo(mScrollingLayerRect.left + mAutoScrollX,
@@ -9581,6 +9591,7 @@ public class WebView extends AbsoluteLayout
     * See WebTextView.setType()
     */
    private native int      nativeFocusCandidateType();
    private native int      nativeFocusCandidateLayerId();
    private native boolean  nativeFocusIsPlugin();
    private native Rect     nativeFocusNodeBounds();
    /* package */ native int nativeFocusNodePointer();