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

Commit 87232e63 authored by Leon Scroggins's avatar Leon Scroggins Committed by Android Git Automerger
Browse files

am 1b9d7605: am e26efa32: If the DOM changes textfield focus, make the IME work properly.

Merge commit '1b9d7605'

* commit '1b9d7605':
  If the DOM changes textfield focus, make the IME work properly.
parents 7fd0fee9 1b9d7605
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -84,12 +84,6 @@ import java.util.ArrayList;
    // True if the most recent drag event has caused either the TextView to
    // scroll or the web page to scroll.  Gets reset after a touch down.
    private boolean         mScrolled;
    // Gets set to true any time the WebTextView has focus, but the navigation
    // cache does not yet know that the focus has been changed.  This happens
    // if the user presses "Next", if the user moves the cursor to a textfield
    // and starts typing or clicks the trackball/center key, and when the user
    // touches a textfield.
    boolean                 mOkayForFocusNotToMatch;
    // Whether or not a selection change was generated from webkit.  If it was,
    // we do not need to pass the selection back to webkit.
    private boolean         mFromWebKit;
@@ -151,22 +145,6 @@ import java.util.ArrayList;
                break;
        }

        if (down) {
            if (mOkayForFocusNotToMatch) {
                if (mWebView.nativeFocusNodePointer() == mNodePointer) {
                    mOkayForFocusNotToMatch = false;
                }
            } else if (mWebView.nativeFocusNodePointer() != mNodePointer
                    && !isArrowKey) {
                mWebView.nativeClearCursor();
                // Do not call remove() here, which hides the soft keyboard.  If
                // the soft keyboard is being displayed, the user will still want
                // it there.
                mWebView.removeView(this);
                mWebView.requestFocus();
                return mWebView.dispatchKeyEvent(event);
            }
        }
        Spannable text = (Spannable) getText();
        int oldLength = text.length();
        // Normally the delete key's dom events are sent via onTextChanged.
@@ -324,7 +302,6 @@ import java.util.ArrayList;
            // focus, set the focus controller back to inactive
            mWebView.setFocusControllerInactive();
            mWebView.nativeMoveCursorToNextTextInput();
            mOkayForFocusNotToMatch = true;
            // Preemptively rebuild the WebTextView, so that the action will
            // be set properly.
            mWebView.rebuildWebTextView();
+18 −14
Original line number Diff line number Diff line
@@ -493,6 +493,7 @@ public class WebView extends AbsoluteLayout
    static final int DO_MOTION_UP                       = 28;
    static final int SHOW_FULLSCREEN                    = 29;
    static final int HIDE_FULLSCREEN                    = 30;
    static final int DOM_FOCUS_CHANGED                  = 31;

    static final String[] HandlerDebugString = {
        "REMEMBER_PASSWORD", //              = 1;
@@ -524,7 +525,8 @@ public class WebView extends AbsoluteLayout
        "REQUEST_KEYBOARD", //               = 27;
        "DO_MOTION_UP", //                   = 28;
        "SHOW_FULLSCREEN", //                = 29;
        "HIDE_FULLSCREEN" //                 = 30;
        "HIDE_FULLSCREEN", //                = 30;
        "DOM_FOCUS_CHANGED" //               = 31;
    };

    // If the site doesn't use the viewport meta tag to specify the viewport,
@@ -1726,6 +1728,13 @@ public class WebView extends AbsoluteLayout
        return result;
    }

    // Called by JNI when the DOM has changed the focus.  Clear the focus so
    // that new keys will go to the newly focused field
    private void domChangedFocus() {
        if (inEditingMode()) {
            mPrivateHandler.obtainMessage(DOM_FOCUS_CHANGED).sendToTarget();
        }
    }
    /**
     * Request the href of an anchor element due to getFocusNodePath returning
     * "href." If hrefMsg is null, this method returns immediately and does not
@@ -3191,16 +3200,6 @@ public class WebView extends AbsoluteLayout
        imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
    }

    /**
     * Only for calling from JNI.  Allows a click on an unfocused textfield to
     * put the textfield in focus.
     */
    private void setOkayNotToMatch() {
        if (inEditingMode()) {
            mWebTextView.mOkayForFocusNotToMatch = true;
        }
    }

    /*
     * This method checks the current focus and cursor and potentially rebuilds
     * mWebTextView to have the appropriate properties, such as password,
@@ -3462,7 +3461,6 @@ public class WebView extends AbsoluteLayout
            // Now we need to pass the event to it
            if (inEditingMode()) {
                mWebTextView.setDefaultSelection();
                mWebTextView.mOkayForFocusNotToMatch = true;
                return mWebTextView.dispatchKeyEvent(event);
            }
        } else if (nativeHasFocusNode()) {
@@ -3559,7 +3557,6 @@ public class WebView extends AbsoluteLayout
                centerKeyPressOnTextField();
                if (inEditingMode()) {
                    mWebTextView.setDefaultSelection();
                    mWebTextView.mOkayForFocusNotToMatch = true;
                }
                return true;
            }
@@ -5311,7 +5308,7 @@ public class WebView extends AbsoluteLayout
            // exclude INVAL_RECT_MSG_ID since it is frequently output
            if (DebugFlags.WEB_VIEW && msg.what != INVAL_RECT_MSG_ID) {
                Log.v(LOGTAG, msg.what < REMEMBER_PASSWORD || msg.what
                        > HIDE_FULLSCREEN ? Integer.toString(msg.what)
                        > DOM_FOCUS_CHANGED ? Integer.toString(msg.what)
                        : HandlerDebugString[msg.what - REMEMBER_PASSWORD]);
            }
            if (mWebViewCore == null) {
@@ -5736,6 +5733,13 @@ public class WebView extends AbsoluteLayout
                    }
                    break;

                case DOM_FOCUS_CHANGED:
                    if (inEditingMode()) {
                        nativeClearCursor();
                        rebuildWebTextView();
                    }
                    break;

                default:
                    super.handleMessage(msg);
                    break;