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

Commit 5fd3dc25 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 2713

* changes:
  in the browser, make the trackball more like a mouse
parents 8eff8420 d6982c9b
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -121,6 +121,10 @@ import java.util.ArrayList;
            if (isPopupShowing()) {
                return super.dispatchKeyEvent(event);
            }
            if (!mWebView.nativeCursorMatchesFocus()) {
                return down ? mWebView.onKeyDown(keyCode, event) : mWebView
                        .onKeyUp(keyCode, event);
            }
            // Center key should be passed to a potential onClick
            if (!down) {
                mWebView.shortPressOnTextField();
@@ -128,6 +132,20 @@ import java.util.ArrayList;
            // Pass to super to handle longpress.
            return super.dispatchKeyEvent(event);
        }
        boolean isArrowKey = false;
        switch(keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_DPAD_UP:
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!mWebView.nativeCursorMatchesFocus()) {
                    return down ? mWebView.onKeyDown(keyCode, event) : mWebView
                            .onKeyUp(keyCode, event);

                }
                isArrowKey = true;
                break;
        }

        // Ensure there is a layout so arrow keys are handled properly.
        if (getLayout() == null) {
@@ -157,22 +175,11 @@ import java.util.ArrayList;
            // so do not pass down to javascript, and instead
            // return true.  If it is an arrow key or a delete key, we can go
            // ahead and pass it down.
            boolean isArrowKey;
            switch(keyCode) {
                case KeyEvent.KEYCODE_DPAD_LEFT:
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                case KeyEvent.KEYCODE_DPAD_UP:
                case KeyEvent.KEYCODE_DPAD_DOWN:
                    isArrowKey = true;
                    break;
                case KeyEvent.KEYCODE_ENTER:
            if (KeyEvent.KEYCODE_ENTER == keyCode) {
                // For multi-line text boxes, newlines will
                // trigger onTextChanged for key down (which will send both
                // key up and key down) but not key up.
                mGotEnterDown = true;
                default:
                    isArrowKey = false;
                    break;
            }
            if (maxedOut && !isArrowKey && keyCode != KeyEvent.KEYCODE_DEL) {
                if (oldEnd == oldStart) {
@@ -216,10 +223,7 @@ import java.util.ArrayList;
            return true;
        }
        // if it is a navigation key, pass it to WebView
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT
                || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
                || keyCode == KeyEvent.KEYCODE_DPAD_UP
                || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        if (isArrowKey) {
            // WebView check the trackballtime in onKeyDown to avoid calling
            // native from both trackball and key handling. As this is called 
            // from TextDialog, we always want WebView to check with native. 
@@ -333,6 +337,11 @@ import java.util.ArrayList;
        if (event.getAction() != MotionEvent.ACTION_MOVE) {
            return false;
        }
        // If the Cursor is not on the text input, webview should handle the
        // trackball
        if (!mWebView.nativeCursorMatchesFocus()) {
            return mWebView.onTrackballEvent(event);
        }
        Spannable text = (Spannable) getText();
        MovementMethod move = getMovementMethod();
        if (move != null && getLayout() != null &&
+346 −429

File changed.

Preview size limit exceeded, changes collapsed.

+86 −104
Original line number Diff line number Diff line
@@ -373,18 +373,18 @@ final class WebViewCore {

    private native void nativeSaveDocumentState(int frame);

    private native void nativeSetFinalFocus(int framePtr, int nodePtr, int x,
            int y, boolean block);
    private native void nativeMoveMouse(int framePtr, int nodePtr, int x,
            int y);

    private native void nativeSetKitFocus(int moveGeneration,
            int buildGeneration, int framePtr, int nodePtr, int x, int y,
    private native void nativeMoveMouseIfLatest(int moveGeneration,
            int framePtr, int nodePtr, int x, int y,
            boolean ignoreNullFocus);

    private native String nativeRetrieveHref(int framePtr, int nodePtr);

    private native void nativeTouchUp(int touchGeneration,
            int buildGeneration, int framePtr, int nodePtr, int x, int y, 
            int size, boolean retry);
            int framePtr, int nodePtr, int x, int y,
            int size);

    private native boolean nativeHandleTouchEvent(int action, int x, int y);

@@ -510,19 +510,15 @@ final class WebViewCore {
        }
    }

    static class FocusData {
        FocusData() {}
        FocusData(FocusData d) {
            mMoveGeneration = d.mMoveGeneration;
            mBuildGeneration = d.mBuildGeneration;
            mFrame = d.mFrame;
            mNode = d.mNode;
            mX = d.mX;
            mY = d.mY;
            mIgnoreNullFocus = d.mIgnoreNullFocus;
    static class CursorData {
        CursorData() {}
        CursorData(int frame, int node, int x, int y) {
            mFrame = frame;
            mNode = node;
            mX = x;
            mY = y;
        }
        int mMoveGeneration;
        int mBuildGeneration;
        int mFrame;
        int mNode;
        int mX;
@@ -532,13 +528,11 @@ final class WebViewCore {

    static class TouchUpData {
        int mMoveGeneration;
        int mBuildGeneration;
        int mFrame;
        int mNode;
        int mX;
        int mY;
        int mSize;
        boolean mRetry;
    }

    static class TouchEventData {
@@ -583,8 +577,8 @@ final class WebViewCore {
            "POST_URL", // = 132;
            "SPLIT_PICTURE_SET", // = 133;
            "CLEAR_CONTENT", // = 134;
            "SET_FINAL_FOCUS", // = 135;
            "SET_KIT_FOCUS", // = 136;
            "SET_MOVE_MOUSE", // = 135;
            "SET_MOVE_MOUSE_IF_LATEST", // = 136;
            "REQUEST_FOCUS_HREF", // = 137;
            "ADD_JS_INTERFACE", // = 138;
            "LOAD_DATA", // = 139;
@@ -634,8 +628,8 @@ final class WebViewCore {
        static final int CLEAR_CONTENT = 134;

        // UI nav messages
        static final int SET_FINAL_FOCUS = 135;
        static final int SET_KIT_FOCUS = 136;
        static final int SET_MOVE_MOUSE = 135;
        static final int SET_MOVE_MOUSE_IF_LATEST = 136;
        static final int REQUEST_FOCUS_HREF = 137;
        static final int ADD_JS_INTERFACE = 138;
        static final int LOAD_DATA = 139;
@@ -879,7 +873,7 @@ final class WebViewCore {

                        case REPLACE_TEXT:
                            HashMap jMap = (HashMap) msg.obj;
                            FocusData fData = (FocusData) jMap.get("focusData");
                            CursorData fData = (CursorData) jMap.get("focusData");
                            String replace = (String) jMap.get("replace");
                            int newStart =
                                    ((Integer) jMap.get("start")).intValue();
@@ -892,7 +886,7 @@ final class WebViewCore {

                        case PASS_TO_JS: {
                            HashMap jsMap = (HashMap) msg.obj;
                            FocusData fDat = (FocusData) jsMap.get("focusData");
                            CursorData fDat = (CursorData) jsMap.get("focusData");
                            KeyEvent evt = (KeyEvent) jsMap.get("event");
                            int keyCode = evt.getKeyCode();
                            int keyValue = evt.getUnicodeChar();
@@ -909,7 +903,7 @@ final class WebViewCore {
                        }

                        case SAVE_DOCUMENT_STATE: {
                            FocusData fDat = (FocusData) msg.obj;
                            CursorData fDat = (CursorData) msg.obj;
                            nativeSaveDocumentState(fDat.mFrame);
                            break;
                        }
@@ -922,11 +916,9 @@ final class WebViewCore {
                        case TOUCH_UP:
                            TouchUpData touchUpData = (TouchUpData) msg.obj;
                            nativeTouchUp(touchUpData.mMoveGeneration,
                                    touchUpData.mBuildGeneration,
                                    touchUpData.mFrame, touchUpData.mNode,
                                    touchUpData.mX, touchUpData.mY,
                                    touchUpData.mSize,
                                    touchUpData.mRetry);
                                    touchUpData.mSize);
                            break;

                        case TOUCH_EVENT: {
@@ -961,22 +953,20 @@ final class WebViewCore {
                            mBrowserFrame.documentAsText((Message) msg.obj);
                            break;

                        case SET_FINAL_FOCUS:
                            FocusData finalData = (FocusData) msg.obj;
                            nativeSetFinalFocus(finalData.mFrame,
                        case SET_MOVE_MOUSE:
                            CursorData finalData = (CursorData) msg.obj;
                            nativeMoveMouse(finalData.mFrame,
                                     finalData.mNode, finalData.mX,
                                     finalData.mY, msg.arg1 
                                     != EventHub.NO_FOCUS_CHANGE_BLOCK);
                                     finalData.mY);
                            break;

                        case UNBLOCK_FOCUS:
                            nativeUnblockFocus();
                            break;

                        case SET_KIT_FOCUS:
                            FocusData focusData = (FocusData) msg.obj;
                            nativeSetKitFocus(focusData.mMoveGeneration,
                                    focusData.mBuildGeneration,
                        case SET_MOVE_MOUSE_IF_LATEST:
                            CursorData focusData = (CursorData) msg.obj;
                            nativeMoveMouseIfLatest(focusData.mMoveGeneration,
                                    focusData.mFrame, focusData.mNode,
                                    focusData.mX, focusData.mY,
                                    focusData.mIgnoreNullFocus);
@@ -1011,14 +1001,14 @@ final class WebViewCore {
                            break;

                        case DELETE_SELECTION:
                            FocusData delData = (FocusData) msg.obj;
                            CursorData delData = (CursorData) msg.obj;
                            nativeDeleteSelection(delData.mFrame,
                                     delData.mNode, delData.mX,
                                     delData.mY, msg.arg1, msg.arg2);
                            break;

                        case SET_SELECTION:
                            FocusData selData = (FocusData) msg.obj;
                            CursorData selData = (CursorData) msg.obj;
                            nativeSetSelection(selData.mFrame,
                                     selData.mNode, selData.mX,
                                     selData.mY, msg.arg1, msg.arg2);
@@ -1573,14 +1563,6 @@ final class WebViewCore {
        }
    }

    // called by JNI
    private void sendNotifyFocusSet() {
        if (mWebView != null) {
            Message.obtain(mWebView.mPrivateHandler,
                    WebView.NOTIFY_FOCUS_SET_MSG_ID).sendToTarget();
        }
    }

    // called by JNI
    private void sendNotifyProgressFinished() {
        sendUpdateTextEntry();
+1 −2
Original line number Diff line number Diff line
@@ -503,12 +503,11 @@ android.webkit.WebSyncManager
android.webkit.WebSyncManager$SyncHandler
android.webkit.WebView
android.webkit.WebView$ExtendedZoomControls
android.webkit.WebView$FocusNode
android.webkit.WebView$PrivateHandler
android.webkit.WebViewCore
android.webkit.WebViewCore$CursorData
android.webkit.WebViewCore$EventHub
android.webkit.WebViewCore$EventHub$1
android.webkit.WebViewCore$FocusData
android.webkit.WebViewCore$WebCoreThread
android.webkit.WebViewCore$WebCoreThread$1
android.webkit.WebViewDatabase