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

Commit 33149308 authored by George Mount's avatar George Mount
Browse files

DO NOT MERGE Set the initial scroll position for RTL.

 Bug 5268793
 Webkit knows about the correct initial position for web pages.
 On initial show, scroll to the webkit position.

 Cherry-picked from master CL: I2537b84a

 External WebKit CL: I6a91b97f

Change-Id: I2537b84a30a26a79a8a0f23fe62b9ed757f9c5a4
parent d211b488
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1404,4 +1404,17 @@ class BrowserFrame extends Handler {
    native void nativeSslClientCert(int handle,
                                    byte[] pkcs8EncodedPrivateKey,
                                    byte[][] asn1DerEncodedCertificateChain);

    /**
     * Returns true when the contents of the frame is an RTL or vertical-rl
     * page. This is used for determining whether a frame should be initially
     * scrolled right-most as opposed to left-most.
     * @return true when the frame should be initially scrolled right-most
     * based on the text direction and writing mode.
     */
    /* package */ boolean getShouldStartScrolledRight() {
        return nativeGetShouldStartScrolledRight(mNativeFrame);
    }

    private native boolean nativeGetShouldStartScrolledRight(int nativeBrowserFrame);
}
+18 −21
Original line number Diff line number Diff line
@@ -8716,27 +8716,6 @@ public class WebView extends AbsoluteLayout
                    isPictureAfterFirstLayout, registerPageSwapCallback);
        }
        final Point viewSize = draw.mViewSize;
        if (isPictureAfterFirstLayout) {
            // Reset the last sent data here since dealing with new page.
            mLastWidthSent = 0;
            mZoomManager.onFirstLayout(draw);
            if (!mDrawHistory) {
                // Do not send the scroll event for this particular
                // scroll message.  Note that a scroll event may
                // still be fired if the user scrolls before the
                // message can be handled.
                mSendScrollEvent = false;
                setContentScrollTo(viewState.mScrollX, viewState.mScrollY);
                mSendScrollEvent = true;

                // As we are on a new page, remove the WebTextView. This
                // is necessary for page loads driven by webkit, and in
                // particular when the user was on a password field, so
                // the WebTextView was visible.
                clearTextEntry();
            }
        }

        // We update the layout (i.e. request a layout from the
        // view system) if the last view size that we sent to
        // WebCore matches the view size of the picture we just
@@ -8749,7 +8728,25 @@ public class WebView extends AbsoluteLayout
        mSendScrollEvent = false;
        recordNewContentSize(draw.mContentSize.x,
                draw.mContentSize.y, updateLayout);

        if (isPictureAfterFirstLayout) {
            // Reset the last sent data here since dealing with new page.
            mLastWidthSent = 0;
            mZoomManager.onFirstLayout(draw);
            int scrollX = viewState.mShouldStartScrolledRight
                    ? getContentWidth() : viewState.mScrollX;
            int scrollY = viewState.mScrollY;
            setContentScrollTo(scrollX, scrollY);
            if (!mDrawHistory) {
                // As we are on a new page, remove the WebTextView. This
                // is necessary for page loads driven by webkit, and in
                // particular when the user was on a password field, so
                // the WebTextView was visible.
                clearTextEntry();
            }
        }
        mSendScrollEvent = true;

        if (DebugFlags.WEB_VIEW) {
            Rect b = draw.mInvalRegion.getBounds();
            Log.v(LOGTAG, "NEW_PICTURE_MSG_ID {" +
+7 −0
Original line number Diff line number Diff line
@@ -1982,6 +1982,7 @@ public final class WebViewCore {
        int mScrollY;
        boolean mMobileSite;
        boolean mIsRestored;
        boolean mShouldStartScrolledRight;
    }

    static class DrawData {
@@ -2382,6 +2383,7 @@ public final class WebViewCore {
            viewState.mMobileSite = false;
            // for non-mobile site, we don't need minPrefWidth, set it as 0
            viewState.mScrollX = 0;
            viewState.mShouldStartScrolledRight = false;
            Message.obtain(mWebView.mPrivateHandler,
                    WebView.UPDATE_ZOOM_RANGE, viewState).sendToTarget();
            return;
@@ -2412,6 +2414,11 @@ public final class WebViewCore {
        mInitialViewState.mDefaultScale = adjust;
        mInitialViewState.mScrollX = mRestoredX;
        mInitialViewState.mScrollY = mRestoredY;
        mInitialViewState.mShouldStartScrolledRight = (mRestoredX == 0)
                && (mRestoredY == 0)
                && (mBrowserFrame != null)
                && mBrowserFrame.getShouldStartScrolledRight();

        mInitialViewState.mMobileSite = (0 == mViewportWidth);
        if (mIsRestored) {
            mInitialViewState.mIsRestored = true;