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

Commit 5cf78f7b authored by Chris Craik's avatar Chris Craik
Browse files

use pageswap callback to sync WebTextView with drawing of page

bug:5008210

Redraw the WebTextView when the page swaps (and thus the background is updated)
That way it updates at (approximately) the same time as the page. In software
rendering, do as before.

Depends on following external/webkit change:
https://android-git.corp.google.com/g/#change,124606

Change-Id: I59d7266a49d0ba734efdb88fef5fafe68aecfbce
parent a7ffaee2
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -2285,7 +2285,7 @@ public class WebView extends AbsoluteLayout
        checkThread();
        mContentWidth = 0;
        mContentHeight = 0;
        setBaseLayer(0, null, false, false);
        setBaseLayer(0, null, false, false, false);
        mWebViewCore.sendMessage(EventHub.CLEAR_CONTENT);
    }

@@ -4268,11 +4268,11 @@ public class WebView extends AbsoluteLayout
    }

    void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator,
            boolean isPictureAfterFirstLayout) {
            boolean isPictureAfterFirstLayout, boolean registerPageSwapCallback) {
        if (mNativeClass == 0)
            return;
        nativeSetBaseLayer(layer, invalRegion, showVisualIndicator,
                isPictureAfterFirstLayout);
                isPictureAfterFirstLayout, registerPageSwapCallback);
        if (mHTML5VideoViewProxy != null) {
            mHTML5VideoViewProxy.setBaseLayer(layer);
        }
@@ -4420,8 +4420,9 @@ public class WebView extends AbsoluteLayout
            mFocusSizeChanged = false;
            // If we are zooming, this will get handled above, when the zoom
            // finishes.  We also do not need to do this unless the WebTextView
            // is showing.
            if (!animateZoom && inEditingMode()) {
            // is showing. With hardware acceleration, the pageSwapCallback()
            // updates the WebTextView position in sync with page swapping
            if (!canvas.isHardwareAccelerated() && !animateZoom && inEditingMode()) {
                didUpdateWebTextViewDimensions(ANYWHERE);
            }
        }
@@ -8395,6 +8396,14 @@ public class WebView extends AbsoluteLayout
        }
    }

    // Called by JNI to invalidate the View, given rectangle coordinates in
    // content space
    private void pageSwapCallback() {
        if (inEditingMode()) {
            didUpdateWebTextViewDimensions(ANYWHERE);
        }
    }

    void setNewPicture(final WebViewCore.DrawData draw, boolean updateBaseLayer) {
        if (mNativeClass == 0) {
            if (mDelaySetPicture != null) {
@@ -8407,10 +8416,15 @@ public class WebView extends AbsoluteLayout
        }
        WebViewCore.ViewState viewState = draw.mViewState;
        boolean isPictureAfterFirstLayout = viewState != null;

        // Request a callback on pageSwap (to reposition the webtextview)
        boolean registerPageSwapCallback =
            !mZoomManager.isFixedLengthAnimationInProgress() && inEditingMode();

        if (updateBaseLayer) {
            setBaseLayer(draw.mBaseLayer, draw.mInvalRegion,
                    getSettings().getShowVisualIndicator(),
                    isPictureAfterFirstLayout);
                    isPictureAfterFirstLayout, registerPageSwapCallback);
        }
        final Point viewSize = draw.mViewSize;
        if (isPictureAfterFirstLayout) {
@@ -9209,7 +9223,8 @@ public class WebView extends AbsoluteLayout
    private native void     nativeSetFindIsUp(boolean isUp);
    private native void     nativeSetHeightCanMeasure(boolean measure);
    private native void     nativeSetBaseLayer(int layer, Region invalRegion,
            boolean showVisualIndicator, boolean isPictureAfterFirstLayout);
            boolean showVisualIndicator, boolean isPictureAfterFirstLayout,
            boolean registerPageSwapCallback);
    private native int      nativeGetBaseLayer();
    private native void     nativeShowCursorTimed();
    private native void     nativeReplaceBaseContent(int content);