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

Commit 413ce9dd authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Pause WebKit drawing when WebView loses window focus."

parents f0ec2dd3 e00e8a78
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -643,10 +643,10 @@ public class WebSettings {

    /**
     * Set whether the WebView will enable smooth transition while panning or
     * zooming. If it is true, WebView will choose a solution to maximize the
     * performance. e.g. the WebView's content may not be updated during the
     * transition. If it is false, WebView will keep its fidelity. The default
     * value is false.
     * zooming or while the window hosting the WebView does not have focus.
     * If it is true, WebView will choose a solution to maximize the performance.
     * e.g. the WebView's content may not be updated during the transition.
     * If it is false, WebView will keep its fidelity. The default value is false.
     */
    public void setEnableSmoothTransition(boolean enable) {
        mEnableSmoothTransition = enable;
+15 −0
Original line number Diff line number Diff line
@@ -908,6 +908,9 @@ public class WebView extends AbsoluteLayout
    // used for serializing asynchronously handled touch events.
    private final TouchEventQueue mTouchEventQueue = new TouchEventQueue();

    // Used to track whether picture updating was paused due to a window focus change.
    private boolean mPictureUpdatePausedForFocusChange = false;

    // Used to notify listeners of a new picture.
    private PictureListener mPictureListener;
    /**
@@ -5570,8 +5573,20 @@ public class WebView extends AbsoluteLayout
        setActive(hasWindowFocus);
        if (hasWindowFocus) {
            JWebCoreJavaBridge.setActiveWebView(this);
            if (mPictureUpdatePausedForFocusChange) {
                WebViewCore.resumeUpdatePicture(mWebViewCore);
                nativeSetIsScrolling(false);
                mPictureUpdatePausedForFocusChange = false;
            }
        } else {
            JWebCoreJavaBridge.removeActiveWebView(this);
            final WebSettings settings = getSettings();
            if (settings != null && settings.enableSmoothTransition() &&
                    mWebViewCore != null && !WebViewCore.isUpdatePicturePaused(mWebViewCore)) {
                WebViewCore.pauseUpdatePicture(mWebViewCore);
                nativeSetIsScrolling(true);
                mPictureUpdatePausedForFocusChange = true;
            }
        }
        super.onWindowFocusChanged(hasWindowFocus);
    }
+4 −0
Original line number Diff line number Diff line
@@ -2107,6 +2107,10 @@ public final class WebViewCore {
        }
    }

    static boolean isUpdatePicturePaused(WebViewCore core) {
        return core != null ? core.mDrawIsPaused : false;
    }

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

    private void restoreState(int index) {