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

Commit 213478b8 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Hardware accelerated button focus rings"

parents 774f9856 bdfb3c5a
Loading
Loading
Loading
Loading
+28 −10
Original line number Original line Diff line number Diff line
@@ -4078,8 +4078,8 @@ public class WebView extends AbsoluteLayout
        boolean pressed = (mTouchMode == TOUCH_SHORTPRESS_START_MODE
        boolean pressed = (mTouchMode == TOUCH_SHORTPRESS_START_MODE
                || mTouchMode == TOUCH_INIT_MODE
                || mTouchMode == TOUCH_INIT_MODE
                || mTouchMode == TOUCH_SHORTPRESS_MODE);
                || mTouchMode == TOUCH_SHORTPRESS_MODE);
        nativeRecordButtons(hasFocus() && hasWindowFocus(),
        recordButtons(canvas,
                (pressed && !USE_WEBKIT_RINGS)
                hasFocus() && hasWindowFocus(), (pressed && !USE_WEBKIT_RINGS)
                || mTrackballDown || mGotCenterDown, false);
                || mTrackballDown || mGotCenterDown, false);
        drawCoreAndCursorRing(canvas, mBackgroundColor,
        drawCoreAndCursorRing(canvas, mBackgroundColor,
                mDrawCursorRing && drawRings);
                mDrawCursorRing && drawRings);
@@ -5133,7 +5133,7 @@ public class WebView extends AbsoluteLayout
                        .obtainMessage(LONG_PRESS_CENTER), LONG_PRESS_TIMEOUT);
                        .obtainMessage(LONG_PRESS_CENTER), LONG_PRESS_TIMEOUT);
                // Already checked mNativeClass, so we do not need to check it
                // Already checked mNativeClass, so we do not need to check it
                // again.
                // again.
                nativeRecordButtons(hasFocus() && hasWindowFocus(), true, true);
                recordButtons(null, hasFocus() && hasWindowFocus(), true, true);
                if (!wantsKeyEvents) return true;
                if (!wantsKeyEvents) return true;
            }
            }
            // Bubble up the key event as WebView doesn't handle it
            // Bubble up the key event as WebView doesn't handle it
@@ -5561,7 +5561,7 @@ public class WebView extends AbsoluteLayout
                mDrawCursorRing = true;
                mDrawCursorRing = true;
                setFocusControllerActive(true);
                setFocusControllerActive(true);
                if (mNativeClass != 0) {
                if (mNativeClass != 0) {
                    nativeRecordButtons(true, false, true);
                    recordButtons(null, true, false, true);
                }
                }
            } else {
            } else {
                if (!inEditingMode()) {
                if (!inEditingMode()) {
@@ -5570,7 +5570,7 @@ public class WebView extends AbsoluteLayout
                    mDrawCursorRing = false;
                    mDrawCursorRing = false;
                    setFocusControllerActive(false);
                    setFocusControllerActive(false);
                }
                }
                // We do not call nativeRecordButtons here because we assume
                // We do not call recordButtons here because we assume
                // that when we lost focus, or window focus, it got called with
                // that when we lost focus, or window focus, it got called with
                // false for the first parameter
                // false for the first parameter
            }
            }
@@ -5589,7 +5589,7 @@ public class WebView extends AbsoluteLayout
            mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
            mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
            mTouchMode = TOUCH_DONE_MODE;
            mTouchMode = TOUCH_DONE_MODE;
            if (mNativeClass != 0) {
            if (mNativeClass != 0) {
                nativeRecordButtons(false, false, true);
                recordButtons(null, false, false, true);
            }
            }
            setFocusControllerActive(false);
            setFocusControllerActive(false);
        }
        }
@@ -5647,13 +5647,13 @@ public class WebView extends AbsoluteLayout
            if (hasWindowFocus()) {
            if (hasWindowFocus()) {
                mDrawCursorRing = true;
                mDrawCursorRing = true;
                if (mNativeClass != 0) {
                if (mNativeClass != 0) {
                    nativeRecordButtons(true, false, true);
                    recordButtons(null, true, false, true);
                }
                }
                setFocusControllerActive(true);
                setFocusControllerActive(true);
            //} else {
            //} else {
                // The WebView has gained focus while we do not have
                // The WebView has gained focus while we do not have
                // windowfocus.  When our window lost focus, we should have
                // windowfocus.  When our window lost focus, we should have
                // called nativeRecordButtons(false...)
                // called recordButtons(false...)
            }
            }
        } else {
        } else {
            // When we lost focus, unless focus went to the TextView (which is
            // When we lost focus, unless focus went to the TextView (which is
@@ -5661,7 +5661,7 @@ public class WebView extends AbsoluteLayout
            if (!inEditingMode()) {
            if (!inEditingMode()) {
                mDrawCursorRing = false;
                mDrawCursorRing = false;
                if (mNativeClass != 0) {
                if (mNativeClass != 0) {
                    nativeRecordButtons(false, false, true);
                    recordButtons(null, false, false, true);
                }
                }
                setFocusControllerActive(false);
                setFocusControllerActive(false);
            }
            }
@@ -6762,7 +6762,7 @@ public class WebView extends AbsoluteLayout
            if (mNativeClass == 0) {
            if (mNativeClass == 0) {
                return false;
                return false;
            }
            }
            nativeRecordButtons(hasFocus() && hasWindowFocus(), true, true);
            recordButtons(null, hasFocus() && hasWindowFocus(), true, true);
            if (time - mLastCursorTime <= TRACKBALL_TIMEOUT
            if (time - mLastCursorTime <= TRACKBALL_TIMEOUT
                    && !mLastCursorBounds.equals(nativeGetCursorRingBounds())) {
                    && !mLastCursorBounds.equals(nativeGetCursorRingBounds())) {
                nativeSelectBestAt(mLastCursorBounds);
                nativeSelectBestAt(mLastCursorBounds);
@@ -9349,6 +9349,24 @@ public class WebView extends AbsoluteLayout
        return nativeTileProfilingGetFloat(frame, tile, key);
        return nativeTileProfilingGetFloat(frame, tile, key);
    }
    }


    /**
     * Helper method to deal with differences between hardware and software rendering
     */
    private void recordButtons(Canvas canvas, boolean focus, boolean pressed,
            boolean inval) {
        boolean isHardwareAccel = canvas != null
                ? canvas.isHardwareAccelerated()
                : isHardwareAccelerated();
        if (isHardwareAccel) {
            // We never want to change button state if we are hardware accelerated,
            // but we DO want to invalidate as necessary so that the GL ring
            // can be drawn
            nativeRecordButtons(false, false, inval);
        } else {
            nativeRecordButtons(focus, pressed, inval);
        }
    }

    private native int nativeCacheHitFramePointer();
    private native int nativeCacheHitFramePointer();
    private native boolean  nativeCacheHitIsPlugin();
    private native boolean  nativeCacheHitIsPlugin();
    private native Rect nativeCacheHitNodeBounds();
    private native Rect nativeCacheHitNodeBounds();