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

Commit 200c13d3 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Do not put the selection on screen for non password fields.

Instead, allow webkit to do it.

Requires a change to external/webkit.

Bug 2679411
Bug 2659028

Change-Id: Ibe5dfc90b13d13f7575649e4c90d5166de10dbb2
parent 610d92f4
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -635,10 +635,23 @@ import java.util.ArrayList;
        mWebView.requestFocus();
    }

    /**
     * Move the caret/selection into view.
     */
    /* package */ void bringIntoView() {
        if (getLayout() != null) {
        bringPointIntoView(Selection.getSelectionEnd(getText()));
    }

    @Override
    public boolean bringPointIntoView(int offset) {
        if (mWebView == null) return false;
        if (mWebView.nativeFocusCandidateIsPassword()) {
            return getLayout() != null && super.bringPointIntoView(offset);
        }
        // For non password text input, tell webkit to move the caret/selection
        // on screen, since webkit draws them.
        mWebView.revealSelection();
        return true;
    }

    /**
+10 −1
Original line number Diff line number Diff line
@@ -3689,7 +3689,7 @@ public class WebView extends AbsoluteLayout
                return;
            }
        }
        // Used by plugins.
        // Used by plugins and contentEditable.
        // Also used if the navigation cache is out of date, and
        // does not recognize that a textfield is in focus.  In that
        // case, use WebView as the targeted view.
@@ -3781,6 +3781,15 @@ public class WebView extends AbsoluteLayout
        mWebTextView.requestFocus();
    }

    /**
     * Tell webkit to put the cursor on screen.
     */
    /* package */ void revealSelection() {
        if (mWebViewCore != null) {
            mWebViewCore.sendMessage(EventHub.REVEAL_SELECTION);
        }
    }

    /**
     * Called by WebTextView to find saved form data associated with the
     * textfield
+14 −4
Original line number Diff line number Diff line
@@ -731,6 +731,7 @@ final class WebViewCore {
    }

        static final String[] HandlerDebugString = {
            "REVEAL_SELECTION", // 96
            "REQUEST_LABEL", // 97
            "UPDATE_FRAME_CACHE_IF_LOADING", // = 98
            "SCROLL_TEXT_INPUT", // = 99
@@ -786,6 +787,7 @@ final class WebViewCore {

    class EventHub {
        // Message Ids
        static final int REVEAL_SELECTION = 96;
        static final int REQUEST_LABEL = 97;
        static final int UPDATE_FRAME_CACHE_IF_LOADING = 98;
        static final int SCROLL_TEXT_INPUT = 99;
@@ -907,6 +909,9 @@ final class WebViewCore {
         */
        private EventHub() {}

        private static final int FIRST_PACKAGE_MSG_ID = REVEAL_SELECTION;
        private static final int LAST_PACKAGE_MSG_ID = VALID_NODE_BOUNDS;

        /**
         * Transfer all messages to the newly created webcore thread handler.
         */
@@ -918,11 +923,11 @@ final class WebViewCore {
                @Override
                public void handleMessage(Message msg) {
                    if (DebugFlags.WEB_VIEW_CORE) {
                        Log.v(LOGTAG, (msg.what < REQUEST_LABEL
                                || msg.what
                                > VALID_NODE_BOUNDS ? Integer.toString(msg.what)
                        Log.v(LOGTAG, (msg.what < FIRST_PACKAGE_MSG_ID
                                || msg.what > LAST_PACKAGE_MSG_ID
                                ? Integer.toString(msg.what)
                                : HandlerDebugString[msg.what
                                        - REQUEST_LABEL])
                                        - FIRST_PACKAGE_MSG_ID])
                                + " arg1=" + msg.arg1 + " arg2=" + msg.arg2
                                + " obj=" + msg.obj);
                    }
@@ -943,6 +948,10 @@ final class WebViewCore {
                            }
                            break;

                        case REVEAL_SELECTION:
                            nativeRevealSelection();
                            break;

                        case REQUEST_LABEL:
                            if (mWebView != null) {
                                int nodePointer = msg.arg2;
@@ -2306,6 +2315,7 @@ final class WebViewCore {
    }

    private native void nativeUpdateFrameCacheIfLoading();
    private native void nativeRevealSelection();
    private native String nativeRequestLabel(int framePtr, int nodePtr);
    /**
     * Scroll the focused textfield to (xPercent, y) in document space