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

Commit a7bc87cb authored by Grace Kloba's avatar Grace Kloba
Browse files

Added pause/resume update Picture to WebViewCore.

When animating zoom, we pause updating picture for
smooth animation.

Fix http://b/issue?id=2359016

Remove the unused param in reducePriority/resumePriority
parent 3ff37c1d
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -3109,6 +3109,7 @@ public class WebView extends AbsoluteLayout
                zoomScale = mZoomScale;
                // set mZoomScale to be 0 as we have done animation
                mZoomScale = 0;
                WebViewCore.resumeUpdatePicture(mWebViewCore);
                // call invalidate() again to draw with the final filters
                invalidate();
                if (mNeedToAdjustWebTextView) {
@@ -4458,7 +4459,7 @@ public class WebView extends AbsoluteLayout
                    deltaX = 0;
                    deltaY = 0;

                    WebViewCore.reducePriority(mWebViewCore);
                    WebViewCore.reducePriority();
                    if (!mDragFromTextInput) {
                        nativeHideCursor();
                    }
@@ -4621,7 +4622,7 @@ public class WebView extends AbsoluteLayout
                                    || computeVerticalScrollExtent() < computeVerticalScrollRange())) {
                                // we will not rewrite drag code here, but we
                                // will try fling if it applies.
                                WebViewCore.reducePriority(mWebViewCore);
                                WebViewCore.reducePriority();
                                // fall through to TOUCH_DRAG_MODE
                            } else {
                                break;
@@ -4658,7 +4659,7 @@ public class WebView extends AbsoluteLayout
                            break;
                        }
                        mLastVelocity = 0;
                        WebViewCore.resumePriority(mWebViewCore);
                        WebViewCore.resumePriority();
                        break;
                    case TOUCH_DRAG_START_MODE:
                    case TOUCH_DONE_MODE:
@@ -4707,7 +4708,7 @@ public class WebView extends AbsoluteLayout
            mVelocityTracker = null;
        }
        if (mTouchMode == TOUCH_DRAG_MODE) {
            WebViewCore.resumePriority(mWebViewCore);
            WebViewCore.resumePriority();
        }
        mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
        mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
@@ -5033,7 +5034,7 @@ public class WebView extends AbsoluteLayout
            vy = vy * 3 / 4;
        }
        if ((maxX == 0 && vy == 0) || (maxY == 0 && vx == 0)) {
            WebViewCore.resumePriority(mWebViewCore);
            WebViewCore.resumePriority();
            return;
        }
        float currentVelocity = mScroller.getCurrVelocity();
@@ -5090,6 +5091,7 @@ public class WebView extends AbsoluteLayout
            mInvInitialZoomScale = 1.0f / oldScale;
            mInvFinalZoomScale = 1.0f / mActualScale;
            mZoomScale = mActualScale;
            WebViewCore.pauseUpdatePicture(mWebViewCore);
            invalidate();
            return true;
        } else {
@@ -5904,7 +5906,7 @@ public class WebView extends AbsoluteLayout
                    }
                    break;
                case RESUME_WEBCORE_PRIORITY:
                    WebViewCore.resumePriority(mWebViewCore);
                    WebViewCore.resumePriority();
                    break;

                case LONG_PRESS_CENTER:
+33 −2
Original line number Diff line number Diff line
@@ -1676,6 +1676,9 @@ final class WebViewCore {
    // Used to avoid posting more than one split picture message.
    private boolean mSplitPictureIsScheduled;

    // Used to suspend drawing.
    private boolean mDrawIsPaused;

    // mRestoreState is set in didFirstLayout(), and reset in the next
    // webkitDraw after passing it to the UI thread.
    private RestoreState mRestoreState = null;
@@ -1788,7 +1791,7 @@ final class WebViewCore {
        return result;
    }

    static void reducePriority(WebViewCore core) {
    static void reducePriority() {
        // remove the pending REDUCE_PRIORITY and RESUME_PRIORITY messages
        sWebCoreHandler.removeMessages(WebCoreThread.REDUCE_PRIORITY);
        sWebCoreHandler.removeMessages(WebCoreThread.RESUME_PRIORITY);
@@ -1796,7 +1799,7 @@ final class WebViewCore {
                .obtainMessage(WebCoreThread.REDUCE_PRIORITY));
    }

    static void resumePriority(WebViewCore core) {
    static void resumePriority() {
        // remove the pending REDUCE_PRIORITY and RESUME_PRIORITY messages
        sWebCoreHandler.removeMessages(WebCoreThread.REDUCE_PRIORITY);
        sWebCoreHandler.removeMessages(WebCoreThread.RESUME_PRIORITY);
@@ -1814,6 +1817,33 @@ final class WebViewCore {
                .obtainMessage(WebCoreThread.BLOCK_CACHE_TICKER));
    }

    static void pauseUpdatePicture(WebViewCore core) {
        // Note: there is one possible failure mode. If pauseUpdatePicture() is
        // called from UI thread while WEBKIT_DRAW is just pulled out of the
        // queue in WebCore thread to be executed. Then update won't be blocked.
        if (core != null) {
            synchronized (core) {
                core.mDrawIsPaused = true;
                if (core.mDrawIsScheduled) {
                    core.mEventHub.removeMessages(EventHub.WEBKIT_DRAW);
                }
            }
        }

    }

    static void resumeUpdatePicture(WebViewCore core) {
        if (core != null) {
            synchronized (core) {
                core.mDrawIsPaused = false;
                if (core.mDrawIsScheduled) {
                    core.mDrawIsScheduled = false;
                    core.contentDraw();
                }
            }
        }
    }

    //////////////////////////////////////////////////////////////////////////

    private void restoreState(int index) {
@@ -1842,6 +1872,7 @@ final class WebViewCore {
        synchronized (this) {
            if (mDrawIsScheduled) return;
            mDrawIsScheduled = true;
            if (mDrawIsPaused) return;
            mEventHub.sendMessage(Message.obtain(null, EventHub.WEBKIT_DRAW));
        }
    }