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

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

Merge "Support selections within scrollable text areas."

parents 6787dd27 f1c00f90
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -5159,18 +5159,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
    }

    private void updateWebkitSelection() {
        int[] handles = null;
        if (mIsCaretSelection) {
            mSelectCursorExtent.set(mSelectCursorBase.x, mSelectCursorBase.y);
        }
        if (mSelectingText) {
            handles = new int[4];
            getSelectionHandles(handles);
        } else {
            nativeSetTextSelection(mNativeClass, 0);
        }
        int handleId = (mSelectDraggingCursor == mSelectCursorBase)
                ? HANDLE_ID_BASE : HANDLE_ID_EXTENT;
        mWebViewCore.removeMessages(EventHub.SELECT_TEXT);
        mWebViewCore.sendMessageAtFrontOfQueue(EventHub.SELECT_TEXT, handles);
        mWebViewCore.sendMessageAtFrontOfQueue(EventHub.SELECT_TEXT,
                mSelectDraggingCursor.x, mSelectDraggingCursor.y, (Integer)handleId);
    }

    private void resetCaretTimer() {
@@ -6104,6 +6097,10 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        }
    }

    private static int getSelectionCoordinate(int coordinate, int min, int max) {
        return Math.max(Math.min(coordinate, max), min);
    }

    private void beginScrollEdit() {
        if (mLastEditScroll == 0) {
            mLastEditScroll = SystemClock.uptimeMillis() -
@@ -6157,11 +6154,15 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                    scrollY = Math.min(getMaxTextScrollY(), scrollY);
                    scrollY = Math.max(0, scrollY);
                    scrollEditText(scrollX, scrollY);
                    int cursorX = mSelectDraggingCursor.x;
                    int cursorY = mSelectDraggingCursor.y;
                    mSelectDraggingCursor.set(x - deltaX, y - deltaY);
                    int selectionX = getSelectionCoordinate(x,
                            mEditTextContentBounds.left, mEditTextContentBounds.right);
                    int selectionY = getSelectionCoordinate(y,
                            mEditTextContentBounds.top, mEditTextContentBounds.bottom);
                    int oldX = mSelectDraggingCursor.x;
                    int oldY = mSelectDraggingCursor.y;
                    mSelectDraggingCursor.set(selectionX, selectionY);
                    updateWebkitSelection();
                    mSelectDraggingCursor.set(cursorX, cursorY);
                    mSelectDraggingCursor.set(oldX, oldY);
                }
            }
        }
+4 −8
Original line number Diff line number Diff line
@@ -1715,13 +1715,9 @@ public final class WebViewCore {
                            nativeInsertText(mNativeClass, (String) msg.obj);
                            break;
                        case SELECT_TEXT: {
                            int[] args = (int[]) msg.obj;
                            if (args == null) {
                                nativeClearTextSelection(mNativeClass);
                            } else {
                                nativeSelectText(mNativeClass, args[0],
                                        args[1], args[2], args[3]);
                            }
                            int handleId = (Integer) msg.obj;
                            nativeSelectText(mNativeClass, handleId,
                                    msg.arg1, msg.arg2);
                            break;
                        }
                        case SELECT_WORD_AT: {
@@ -3150,7 +3146,7 @@ public final class WebViewCore {
    private native String nativeGetText(int nativeClass,
            int startX, int startY, int endX, int endY);
    private native void nativeSelectText(int nativeClass,
            int startX, int startY, int endX, int endY);
            int handleId, int x, int y);
    private native void nativeClearTextSelection(int nativeClass);
    private native boolean nativeSelectWordAt(int nativeClass, int x, int y);
    private native void nativeSelectAll(int nativeClass);