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

Commit 7c2e329e authored by John Reck's avatar John Reck
Browse files

Remove custom scrollbar logic

 Bug: 6505722
 When we scroll the base layer we do so by calling scrollTo on the view,
 which handles all the scrollbar logic for us. Remove the custom keep alive
 code which floods the handler queue, as well as remove the unnecessary
 invalidate and awakenScrollbar calls (View does that for us)

Change-Id: Ia2503c549a22ec71d99295fe62b676fecc367ea3
parent ae147152
Loading
Loading
Loading
Loading
+1 −52
Original line number Original line Diff line number Diff line
@@ -934,7 +934,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
    private static final int RELEASE_SINGLE_TAP         = 5;
    private static final int RELEASE_SINGLE_TAP         = 5;
    private static final int REQUEST_FORM_DATA          = 6;
    private static final int REQUEST_FORM_DATA          = 6;
    private static final int DRAG_HELD_MOTIONLESS       = 8;
    private static final int DRAG_HELD_MOTIONLESS       = 8;
    private static final int AWAKEN_SCROLL_BARS         = 9;
    private static final int PREVENT_DEFAULT_TIMEOUT    = 10;
    private static final int PREVENT_DEFAULT_TIMEOUT    = 10;
    private static final int SCROLL_SELECT_TEXT         = 11;
    private static final int SCROLL_SELECT_TEXT         = 11;


@@ -1002,7 +1001,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        "REQUEST_FORM_DATA", //              = 6;
        "REQUEST_FORM_DATA", //              = 6;
        "RESUME_WEBCORE_PRIORITY", //        = 7;
        "RESUME_WEBCORE_PRIORITY", //        = 7;
        "DRAG_HELD_MOTIONLESS", //           = 8;
        "DRAG_HELD_MOTIONLESS", //           = 8;
        "AWAKEN_SCROLL_BARS", //             = 9;
        "", //             = 9;
        "PREVENT_DEFAULT_TIMEOUT", //        = 10;
        "PREVENT_DEFAULT_TIMEOUT", //        = 10;
        "SCROLL_SELECT_TEXT" //              = 11;
        "SCROLL_SELECT_TEXT" //              = 11;
    };
    };
@@ -3775,7 +3774,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            //        Log.d(LOGTAG, "startScroll: " + dx + " " + dy);
            //        Log.d(LOGTAG, "startScroll: " + dx + " " + dy);
            mScroller.startScroll(getScrollX(), getScrollY(), dx, dy,
            mScroller.startScroll(getScrollX(), getScrollY(), dx, dy,
                    animationDuration > 0 ? animationDuration : computeDuration(dx, dy));
                    animationDuration > 0 ? animationDuration : computeDuration(dx, dy));
            mWebViewPrivate.awakenScrollBars(mScroller.getDuration());
            invalidate();
            invalidate();
        } else {
        } else {
            mWebView.scrollTo(x, y);
            mWebView.scrollTo(x, y);
@@ -4158,15 +4156,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        if (mTouchMode == TOUCH_DRAG_MODE) {
        if (mTouchMode == TOUCH_DRAG_MODE) {
            if (mHeldMotionless == MOTIONLESS_PENDING) {
            if (mHeldMotionless == MOTIONLESS_PENDING) {
                mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
                mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
                mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
                mHeldMotionless = MOTIONLESS_FALSE;
                mHeldMotionless = MOTIONLESS_FALSE;
            }
            }
            if (mHeldMotionless == MOTIONLESS_FALSE) {
            if (mHeldMotionless == MOTIONLESS_FALSE) {
                mPrivateHandler.sendMessageDelayed(mPrivateHandler
                mPrivateHandler.sendMessageDelayed(mPrivateHandler
                        .obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
                        .obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
                mPrivateHandler.sendMessageDelayed(mPrivateHandler
                        .obtainMessage(AWAKEN_SCROLL_BARS),
                            ViewConfiguration.getScrollDefaultDelay());
                mHeldMotionless = MOTIONLESS_PENDING;
                mHeldMotionless = MOTIONLESS_PENDING;
            }
            }
        }
        }
@@ -6048,27 +6042,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                    }
                    }
                }
                }


                // Turn off scrollbars when dragging a layer.
                if (keepScrollBarsVisible &&
                        mTouchMode != TOUCH_DRAG_LAYER_MODE &&
                        mTouchMode != TOUCH_DRAG_TEXT_MODE) {
                    if (mHeldMotionless != MOTIONLESS_TRUE) {
                        mHeldMotionless = MOTIONLESS_TRUE;
                        invalidate();
                    }
                    // keep the scrollbar on the screen even there is no scroll
                    mWebViewPrivate.awakenScrollBars(ViewConfiguration.getScrollDefaultDelay(),
                            false);
                    // Post a message so that we'll keep them alive while we're not scrolling.
                    mPrivateHandler.sendMessageDelayed(mPrivateHandler
                            .obtainMessage(AWAKEN_SCROLL_BARS),
                            ViewConfiguration.getScrollDefaultDelay());
                    // return false to indicate that we can't pan out of the
                    // view space
                    return;
                } else {
                    mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
                }
                break;
                break;
            }
            }
            case MotionEvent.ACTION_UP: {
            case MotionEvent.ACTION_UP: {
@@ -6116,7 +6089,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                    case TOUCH_DRAG_LAYER_MODE:
                    case TOUCH_DRAG_LAYER_MODE:
                    case TOUCH_DRAG_TEXT_MODE:
                    case TOUCH_DRAG_TEXT_MODE:
                        mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
                        mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
                        mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
                        // if the user waits a while w/o moving before the
                        // if the user waits a while w/o moving before the
                        // up, we don't want to do a fling
                        // up, we don't want to do a fling
                        if (eventTime - mLastTouchTime <= MIN_FLING_TIME) {
                        if (eventTime - mLastTouchTime <= MIN_FLING_TIME) {
@@ -6382,7 +6354,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
        mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
        mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
        mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
        mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
        mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
        mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
        removeTouchHighlight();
        removeTouchHighlight();
        mHeldMotionless = MOTIONLESS_TRUE;
        mHeldMotionless = MOTIONLESS_TRUE;
        mTouchMode = TOUCH_DONE_MODE;
        mTouchMode = TOUCH_DONE_MODE;
@@ -6814,17 +6785,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        // no horizontal overscroll if the content just fits
        // no horizontal overscroll if the content just fits
        mScroller.fling(scrollX, scrollY, -vx, -vy, 0, maxX, 0, maxY,
        mScroller.fling(scrollX, scrollY, -vx, -vy, 0, maxX, 0, maxY,
                maxX == 0 ? 0 : overflingDistance, overflingDistance);
                maxX == 0 ? 0 : overflingDistance, overflingDistance);
        // Duration is calculated based on velocity. With range boundaries and overscroll
        // we may not know how long the final animation will take. (Hence the deprecation
        // warning on the call below.) It's not a big deal for scroll bars but if webcore
        // resumes during this effect we will take a performance hit. See computeScroll;
        // we resume webcore there when the animation is finished.
        final int time = mScroller.getDuration();

        // Suppress scrollbars for layer scrolling.
        if (mTouchMode != TOUCH_DRAG_LAYER_MODE && mTouchMode != TOUCH_DRAG_TEXT_MODE) {
            mWebViewPrivate.awakenScrollBars(time);
        }


        invalidate();
        invalidate();
    }
    }
@@ -7362,17 +7322,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                case DRAG_HELD_MOTIONLESS:
                case DRAG_HELD_MOTIONLESS:
                    mHeldMotionless = MOTIONLESS_TRUE;
                    mHeldMotionless = MOTIONLESS_TRUE;
                    invalidate();
                    invalidate();
                    // fall through to keep scrollbars awake

                case AWAKEN_SCROLL_BARS:
                    if (mTouchMode == TOUCH_DRAG_MODE
                            && mHeldMotionless == MOTIONLESS_TRUE) {
                        mWebViewPrivate.awakenScrollBars(ViewConfiguration
                                .getScrollDefaultDelay(), false);
                        mPrivateHandler.sendMessageDelayed(mPrivateHandler
                                .obtainMessage(AWAKEN_SCROLL_BARS),
                                ViewConfiguration.getScrollDefaultDelay());
                    }
                    break;
                    break;


                case SCREEN_ON:
                case SCREEN_ON: