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

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

Merge "Webkit text selection"

parents 4125f0b5 74ffdc30
Loading
Loading
Loading
Loading
+149 −241

File changed.

Preview size limit exceeded, changes collapsed.

+28 −4
Original line number Diff line number Diff line
@@ -835,12 +835,14 @@ public final class WebViewCore {
    }

    static class TextSelectionData {
        public TextSelectionData(int start, int end) {
        public TextSelectionData(int start, int end, int selectTextPtr) {
            mStart = start;
            mEnd = end;
            mSelectTextPtr = selectTextPtr;
        }
        int mStart;
        int mEnd;
        int mSelectTextPtr;
    }

    static class TouchUpData {
@@ -1118,6 +1120,8 @@ public final class WebViewCore {
        static final int COPY_TEXT = 210;
        static final int DELETE_TEXT = 211;
        static final int INSERT_TEXT = 212;
        static final int SELECT_TEXT = 213;
        static final int SELECT_WORD_AT = 214;

        // Private handler for WebCore messages.
        private Handler mHandler;
@@ -1746,6 +1750,22 @@ public final class WebViewCore {
                        case INSERT_TEXT:
                            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]);
                            }
                            break;
                        }
                        case SELECT_WORD_AT: {
                            int x = msg.arg1;
                            int y = msg.arg2;
                            nativeSelectWordAt(mNativeClass, x, y);
                            break;
                        }
                    }
                }
            };
@@ -2699,11 +2719,11 @@ public final class WebViewCore {

    // called by JNI
    private void updateTextSelection(int pointer, int start, int end,
            int textGeneration) {
            int textGeneration, int selectionPtr) {
        if (mWebView != null) {
            Message.obtain(mWebView.mPrivateHandler,
                WebView.UPDATE_TEXT_SELECTION_MSG_ID, pointer, textGeneration,
                new TextSelectionData(start, end)).sendToTarget();
                new TextSelectionData(start, end, selectionPtr)).sendToTarget();
        }
    }

@@ -2770,7 +2790,7 @@ public final class WebViewCore {
        if (mWebView != null) {
            Message.obtain(mWebView.mPrivateHandler,
                    WebView.REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID, pointer,
                    textGeneration, new TextSelectionData(selStart, selEnd))
                    textGeneration, new TextSelectionData(selStart, selEnd, 0))
                    .sendToTarget();
        }
    }
@@ -3025,4 +3045,8 @@ 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);
    private native void nativeClearTextSelection(int nativeClass);
    private native void nativeSelectWordAt(int nativeClass, int x, int y);
}