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

Commit f3616da6 authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "Make paste window and caret handle show up at the right time."

parents ceb0909b f796fdfe
Loading
Loading
Loading
Loading
+31 −12
Original line number Diff line number Diff line
@@ -1255,6 +1255,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
    static final int AUTOFILL_FORM                      = 148;
    static final int ANIMATE_TEXT_SCROLL                = 149;
    static final int EDIT_TEXT_SIZE_CHANGED             = 150;
    static final int SHOW_CARET_HANDLE                  = 151;

    private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
    private static final int LAST_PACKAGE_MSG_ID = HIT_TEST_RESULT;
@@ -5468,9 +5469,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc

    private boolean setupWebkitSelect() {
        syncSelectionCursors();
        if (mIsCaretSelection) {
            showPasteWindow();
        } else if (!startSelectActionMode()) {
        if (!mIsCaretSelection && !startSelectActionMode()) {
            selectionDone();
            return false;
        }
@@ -5539,7 +5538,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            if (!mIsCaretSelection) {
                updateWebkitSelection();
            }
            mIsCaretSelection = false;
            invalidate(); // redraw without selection
            mAutoScrollX = 0;
            mAutoScrollY = 0;
@@ -6378,8 +6376,15 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            case MotionEvent.ACTION_UP: {
                mGestureDetector.onTouchEvent(ev);
                if (mTouchInEditText && mConfirmMove) {
                    stopTouch();
                    break; // We've been scrolling the edit text.
                }
                if (!mConfirmMove && mIsEditingText && mSelectionStarted &&
                        mIsCaretSelection) {
                    showPasteWindow();
                    stopTouch();
                    break;
                }
                // pass the touch events from UI thread to WebCore thread
                if (shouldForwardTouchEvent()) {
                    TouchEventData ted = new TouchEventData();
@@ -6765,7 +6770,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            syncSelectionCursors();
            if (mIsCaretSelection) {
                resetCaretTimer();
                showPasteWindow();
            }
            invalidate();
        }
@@ -8524,6 +8528,14 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                    }
                    break;

                case SHOW_CARET_HANDLE:
                    if (!mSelectingText && mIsEditingText && mIsCaretSelection) {
                        setupWebkitSelect();
                        resetCaretTimer();
                        showPasteWindow();
                    }
                    break;

                default:
                    super.handleMessage(msg);
                    break;
@@ -8823,6 +8835,12 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                (data.mStart != data.mEnd ||
                (mFieldPointer == nodePointer && mFieldPointer != 0))) {
            mIsCaretSelection = (data.mStart == data.mEnd);
            if (mIsCaretSelection &&
                    (mInputConnection == null ||
                    mInputConnection.getEditable().length() == 0)) {
                // There's no text, don't show caret handle.
                selectionDone();
            } else {
                if (!mSelectingText) {
                    setupWebkitSelect();
                } else if (!mSelectionStarted) {
@@ -8831,6 +8849,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                if (mIsCaretSelection) {
                    resetCaretTimer();
                }
            }
        } else {
            selectionDone();
        }
+5 −2
Original line number Diff line number Diff line
@@ -1778,7 +1778,10 @@ public final class WebViewCore {
                        case SELECT_WORD_AT: {
                            int x = msg.arg1;
                            int y = msg.arg2;
                            nativeSelectWordAt(mNativeClass, x, y);
                            if (!nativeSelectWordAt(mNativeClass, x, y)) {
                                mWebView.mPrivateHandler.obtainMessage(WebViewClassic.SHOW_CARET_HANDLE)
                                    .sendToTarget();
                            }
                            break;
                        }
                        case SELECT_ALL:
@@ -3120,7 +3123,7 @@ public final class WebViewCore {
    private native void nativeSelectText(int nativeClass,
            int startX, int startY, int endX, int endY);
    private native void nativeClearTextSelection(int nativeClass);
    private native void nativeSelectWordAt(int nativeClass, int x, int y);
    private native boolean nativeSelectWordAt(int nativeClass, int x, int y);
    private native void nativeSelectAll(int nativeClass);

    private static native void nativeCertTrustChanged();