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

Commit f796fdfe authored by George Mount's avatar George Mount
Browse files

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

 Bug 6194009
 Webkit Change: I7f8bc7266df52a67245b0a971826fd14e0d715c5

Change-Id: I460db436bd79d8ff72b457b5878ffe468400031f
parent ddc421d1
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;
@@ -5455,9 +5456,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;
        }
@@ -5526,7 +5525,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            if (!mIsCaretSelection) {
                updateWebkitSelection();
            }
            mIsCaretSelection = false;
            invalidate(); // redraw without selection
            mAutoScrollX = 0;
            mAutoScrollY = 0;
@@ -6362,8 +6360,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();
@@ -6749,7 +6754,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
            syncSelectionCursors();
            if (mIsCaretSelection) {
                resetCaretTimer();
                showPasteWindow();
            }
            invalidate();
        }
@@ -8511,6 +8515,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;
@@ -8810,6 +8822,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) {
@@ -8818,6 +8836,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                if (mIsCaretSelection) {
                    resetCaretTimer();
                }
            }
        } else {
            selectionDone();
        }
+5 −2
Original line number Diff line number Diff line
@@ -1777,7 +1777,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:
@@ -3106,7 +3109,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();