Delete more navcache stuff

Change-Id: Ic32559948b90abb3e8e755c5eb533dd9e83b3190
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index a01c42d..911073d 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -16,148 +16,15 @@
 
 package android.webkit;
 
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.ColorFilter;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.PixelFormat;
-import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.ResultReceiver;
-import android.text.BoringLayout.Metrics;
-import android.text.DynamicLayout;
-import android.text.Editable;
-import android.text.InputFilter;
-import android.text.InputType;
-import android.text.Layout;
-import android.text.Selection;
-import android.text.Spannable;
-import android.text.TextPaint;
-import android.text.TextUtils;
-import android.text.method.MovementMethod;
-import android.text.method.Touch;
 import android.util.Log;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewConfiguration;
-import android.view.ViewGroup;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputConnection;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.AbsoluteLayout.LayoutParams;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.TextView;
-
-import junit.framework.Assert;
 
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
 
-/**
- * WebTextView is a specialized version of EditText used by WebView
- * to overlay html textfields (and textareas) to use our standard
- * text editing.
- */
-/* package */ class WebTextView extends AutoCompleteTextView
-        implements AdapterView.OnItemClickListener {
+// TODO: Move these to a better place.
+/* package */ abstract class WebTextView {
 
-    static final String LOGTAG = "webtextview";
-
-    private int mRingInset;
-
-    private WebViewClassic  mWebView;
-    private boolean         mSingle;
-    private int             mWidthSpec;
-    private int             mHeightSpec;
-    private int             mNodePointer;
-    // FIXME: This is a hack for blocking unmatched key ups, in particular
-    // on the enter key.  The method for blocking unmatched key ups prevents
-    // the shift key from working properly.
-    private boolean         mGotEnterDown;
-    private int             mMaxLength;
-    // Keep track of the text before the change so we know whether we actually
-    // need to send down the DOM events.
-    private String          mPreChange;
-    // Variables for keeping track of the touch down, to send to the WebView
-    // when a drag starts
-    private float           mDragStartX;
-    private float           mDragStartY;
-    private long            mDragStartTime;
-    private boolean         mDragSent;
-    // 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;
-    // 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;
-    // Whether or not a selection change was generated from the WebTextView
-    // gaining focus.  If it is, we do not want to pass it to webkit.  This
-    // selection comes from the MovementMethod, but we behave differently.  If
-    // WebTextView gained focus from a touch, webkit will determine the
-    // selection.
-    private boolean         mFromFocusChange;
-    // Whether or not a selection change was generated from setInputType.  We
-    // do not want to pass this change to webkit.
-    private boolean         mFromSetInputType;
-    private boolean         mGotTouchDown;
-    // Keep track of whether a long press has happened.  Only meaningful after
-    // an ACTION_DOWN MotionEvent
-    private boolean         mHasPerformedLongClick;
-    private boolean         mInSetTextAndKeepSelection;
-    // Array to store the final character added in onTextChanged, so that its
-    // KeyEvents may be determined.
-    private char[]          mCharacter = new char[1];
-    // This is used to reset the length filter when on a textfield
-    // with no max length.
-    // FIXME: This can be replaced with TextView.NO_FILTERS if that
-    // is made public/protected.
-    private static final InputFilter[] NO_FILTERS = new InputFilter[0];
-    // For keeping track of the fact that the delete key was pressed, so
-    // we can simply pass a delete key instead of calling deleteSelection.
-    private boolean mGotDelete;
-    private int mDelSelStart;
-    private int mDelSelEnd;
-
-    // Keep in sync with native constant in
-    // external/webkit/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
-    /* package */ static final int FORM_NOT_AUTOFILLABLE = -1;
-
-    private boolean mAutoFillable; // Is this textview part of an autofillable form?
-    private int mQueryId;
-    private boolean mAutoFillProfileIsSet;
-    // Used to determine whether onFocusChanged was called as a result of
-    // calling remove().
-    private boolean mInsideRemove;
-    private class MyResultReceiver extends ResultReceiver {
-        @Override
-        protected void onReceiveResult(int resultCode, Bundle resultData) {
-            if (resultCode == InputMethodManager.RESULT_SHOWN
-                    && mWebView != null) {
-                mWebView.revealSelection();
-            }
-        }
-
-        /**
-         * @param handler
-         */
-        public MyResultReceiver(Handler handler) {
-            super(handler);
-        }
-    }
-    private MyResultReceiver mReceiver;
+    private static final String LOGTAG = "WebTextView";
 
     // Types used with setType.  Keep in sync with CachedInput.h
     static final int NORMAL_TEXT_FIELD = 0;
@@ -169,1006 +36,7 @@
     static final int TELEPHONE = 6;
     static final int URL = 7;
 
-    private static final int AUTOFILL_FORM = 100;
-    private Handler mHandler;
-
-    /**
-     * Create a new WebTextView.
-     * @param   context The Context for this WebTextView.
-     * @param   webView The WebView that created this.
-     */
-    /* package */ WebTextView(Context context, WebViewClassic webView, int autoFillQueryId) {
-        super(context, null, com.android.internal.R.attr.webTextViewStyle);
-        mWebView = webView;
-        mMaxLength = -1;
-        setAutoFillable(autoFillQueryId);
-        // Turn on subpixel text, and turn off kerning, so it better matches
-        // the text in webkit.
-        TextPaint paint = getPaint();
-        int flags = paint.getFlags() & ~Paint.DEV_KERN_TEXT_FLAG
-                | Paint.SUBPIXEL_TEXT_FLAG | Paint.DITHER_FLAG;
-        paint.setFlags(flags);
-
-        // Set the text color to black, regardless of the theme.  This ensures
-        // that other applications that use embedded WebViews will properly
-        // display the text in password textfields.
-        setTextColor(DebugFlags.DRAW_WEBTEXTVIEW ? Color.RED : Color.BLACK);
-        setBackgroundDrawable(DebugFlags.DRAW_WEBTEXTVIEW ? null : new ColorDrawable(Color.WHITE));
-
-        // This helps to align the text better with the text in the web page.
-        setIncludeFontPadding(false);
-
-        mHandler = new Handler() {
-            @Override
-            public void handleMessage(Message msg) {
-                switch (msg.what) {
-                case AUTOFILL_FORM:
-                    mWebView.autoFillForm(mQueryId);
-                    break;
-                }
-            }
-        };
-        mReceiver = new MyResultReceiver(mHandler);
-        float ringWidth = 2f * context.getResources().getDisplayMetrics().density;
-        mRingInset = (int) ringWidth;
-        setBackgroundDrawable(new BackgroundDrawable(mRingInset));
-        setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(),
-                getPaddingBottom());
-    }
-
-    private static class BackgroundDrawable extends Drawable {
-
-        private Paint mPaint = new Paint();
-        private int mBorderWidth;
-        private Rect mInsetRect = new Rect();
-
-        public BackgroundDrawable(int width) {
-            mPaint = new Paint();
-            mPaint.setStrokeWidth(width);
-            mBorderWidth = width;
-        }
-
-        @Override
-        public void draw(Canvas canvas) {
-            mPaint.setColor(0x6633b5e5);
-            canvas.drawRect(getBounds(), mPaint);
-            mInsetRect.left = getBounds().left + mBorderWidth;
-            mInsetRect.top = getBounds().top + mBorderWidth;
-            mInsetRect.right = getBounds().right - mBorderWidth;
-            mInsetRect.bottom = getBounds().bottom - mBorderWidth;
-            mPaint.setColor(Color.WHITE);
-            canvas.drawRect(mInsetRect, mPaint);
-        }
-
-        @Override
-        public void setAlpha(int alpha) {
-        }
-
-        @Override
-        public void setColorFilter(ColorFilter cf) {
-        }
-
-        @Override
-        public int getOpacity() {
-            return PixelFormat.TRANSLUCENT;
-        }
-
-    }
-
-    public void setAutoFillable(int queryId) {
-        mAutoFillable = mWebView.getSettings().getAutoFillEnabled()
-                && (queryId != FORM_NOT_AUTOFILLABLE);
-        mQueryId = queryId;
-    }
-
-    @Override
-    public void setPadding(int left, int top, int right, int bottom) {
-        super.setPadding(left + mRingInset, top + mRingInset,
-                right + mRingInset, bottom + mRingInset);
-    }
-
-    @Override
-    public boolean dispatchKeyEvent(KeyEvent event) {
-        if (event.isSystem()) {
-            return super.dispatchKeyEvent(event);
-        }
-        // Treat ACTION_DOWN and ACTION MULTIPLE the same
-        boolean down = event.getAction() != KeyEvent.ACTION_UP;
-        int keyCode = event.getKeyCode();
-
-        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:
-                isArrowKey = true;
-                break;
-        }
-
-        if (KeyEvent.KEYCODE_TAB == keyCode) {
-            if (down) {
-                onEditorAction(EditorInfo.IME_ACTION_NEXT);
-            }
-            return true;
-        }
-        Spannable text = (Spannable) getText();
-        int oldStart = Selection.getSelectionStart(text);
-        int oldEnd = Selection.getSelectionEnd(text);
-        // Normally the delete key's dom events are sent via onTextChanged.
-        // However, if the cursor is at the beginning of the field, which
-        // includes the case where it has zero length, then the text is not
-        // changed, so send the events immediately.
-        if (KeyEvent.KEYCODE_DEL == keyCode) {
-            if (oldStart == 0 && oldEnd == 0) {
-                sendDomEvent(event);
-                return true;
-            }
-            if (down) {
-                mGotDelete = true;
-                mDelSelStart = oldStart;
-                mDelSelEnd = oldEnd;
-            }
-        }
-
-        if (mSingle && (KeyEvent.KEYCODE_ENTER == keyCode
-                    || KeyEvent.KEYCODE_NUMPAD_ENTER == keyCode)) {
-            if (isPopupShowing()) {
-                return super.dispatchKeyEvent(event);
-            }
-            if (!down) {
-                // Hide the keyboard, since the user has just submitted this
-                // form.  The submission happens thanks to the two calls
-                // to sendDomEvent.
-                InputMethodManager.getInstance(mContext)
-                        .hideSoftInputFromWindow(getWindowToken(), 0);
-                sendDomEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
-                sendDomEvent(event);
-            }
-            return super.dispatchKeyEvent(event);
-        } else if (KeyEvent.KEYCODE_DPAD_CENTER == keyCode) {
-            // Note that this handles center key and trackball.
-            if (isPopupShowing()) {
-                return super.dispatchKeyEvent(event);
-            }
-            // Center key should be passed to a potential onClick
-            if (!down) {
-                mWebView.centerKeyPressOnTextField();
-            }
-            // Pass to super to handle longpress.
-            return super.dispatchKeyEvent(event);
-        }
-
-        // Ensure there is a layout so arrow keys are handled properly.
-        if (getLayout() == null) {
-            measure(mWidthSpec, mHeightSpec);
-        }
-
-        int oldLength = text.length();
-        boolean maxedOut = mMaxLength != -1 && oldLength == mMaxLength;
-        // If we are at max length, and there is a selection rather than a
-        // cursor, we need to store the text to compare later, since the key
-        // may have changed the string.
-        String oldText;
-        if (maxedOut && oldEnd != oldStart) {
-            oldText = text.toString();
-        } else {
-            oldText = "";
-        }
-        if (super.dispatchKeyEvent(event)) {
-            // If the WebTextView handled the key it was either an alphanumeric
-            // key, a delete, or a movement within the text. All of those are
-            // ok to pass to javascript.
-
-            // UNLESS there is a max length determined by the html.  In that
-            // case, if the string was already at the max length, an
-            // alphanumeric key will be erased by the LengthFilter,
-            // 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.
-            if (KeyEvent.KEYCODE_ENTER == keyCode
-                        || KeyEvent.KEYCODE_NUMPAD_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;
-            }
-            if (maxedOut && !isArrowKey && keyCode != KeyEvent.KEYCODE_DEL) {
-                if (oldEnd == oldStart) {
-                    // Return true so the key gets dropped.
-                    return true;
-                } else if (!oldText.equals(getText().toString())) {
-                    // FIXME: This makes the text work properly, but it
-                    // does not pass down the key event, so it may not
-                    // work for a textfield that has the type of
-                    // behavior of GoogleSuggest.  That said, it is
-                    // unlikely that a site would combine the two in
-                    // one textfield.
-                    Spannable span = (Spannable) getText();
-                    int newStart = Selection.getSelectionStart(span);
-                    int newEnd = Selection.getSelectionEnd(span);
-                    mWebView.replaceTextfieldText(0, oldLength, span.toString(),
-                            newStart, newEnd);
-                    return true;
-                }
-            }
-            /* FIXME:
-             * In theory, we would like to send the events for the arrow keys.
-             * However, the TextView can arbitrarily change the selection (i.e.
-             * long press followed by using the trackball).  Therefore, we keep
-             * in sync with the TextView via onSelectionChanged.  If we also
-             * send the DOM event, we lose the correct selection.
-            if (isArrowKey) {
-                // Arrow key does not change the text, but we still want to send
-                // the DOM events.
-                sendDomEvent(event);
-            }
-             */
-            return true;
-        }
-        // Ignore the key up event for newlines. This prevents
-        // multiple newlines in the native textarea.
-        if (mGotEnterDown && !down) {
-            return true;
-        }
-        // if it is a navigation key, pass it to WebView
-        if (isArrowKey) {
-            // WebView check the trackballtime in onKeyDown to avoid calling
-            // native from both trackball and key handling. As this is called
-            // from WebTextView, we always want WebView to check with native.
-            // Reset trackballtime to ensure it.
-            mWebView.resetTrackballTime();
-            return down ? mWebView.onKeyDown(keyCode, event) : mWebView
-                    .onKeyUp(keyCode, event);
-        }
-        return false;
-    }
-
-    void ensureLayout() {
-        if (getLayout() == null) {
-            // Ensure we have a Layout
-            measure(mWidthSpec, mHeightSpec);
-            LayoutParams params = (LayoutParams) getLayoutParams();
-            if (params != null) {
-                layout(params.x, params.y, params.x + params.width,
-                        params.y + params.height);
-            }
-        }
-    }
-
-    /* package */ ResultReceiver getResultReceiver() { return mReceiver; }
-
-    /**
-     *  Determine whether this WebTextView currently represents the node
-     *  represented by ptr.
-     *  @param  ptr Pointer to a node to compare to.
-     *  @return boolean Whether this WebTextView already represents the node
-     *          pointed to by ptr.
-     */
-    /* package */ boolean isSameTextField(int ptr) {
-        return ptr == mNodePointer;
-    }
-
-    /**
-     * Ensure that the underlying text field/area is lined up with the WebTextView.
-     */
-    private void lineUpScroll() {
-        Layout layout = getLayout();
-        if (mWebView != null && layout != null) {
-            if (mSingle) {
-                // textfields only need to be lined up horizontally.
-                float maxScrollX = layout.getLineRight(0) - getWidth();
-                if (DebugFlags.WEB_TEXT_VIEW) {
-                    Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y="
-                            + mScrollY + " maxX=" + maxScrollX);
-                }
-                mWebView.scrollFocusedTextInputX(maxScrollX > 0 ?
-                        mScrollX / maxScrollX : 0);
-            } else {
-                // textareas only need to be lined up vertically.
-                mWebView.scrollFocusedTextInputY(mScrollY);
-            }
-        }
-    }
-
-    @Override
-    protected void makeNewLayout(int w, int hintWidth, Metrics boring,
-            Metrics hintBoring, int ellipsisWidth, boolean bringIntoView) {
-        // Necessary to get a Layout to work with, and to do the other work that
-        // makeNewLayout does.
-        super.makeNewLayout(w, hintWidth, boring, hintBoring, ellipsisWidth,
-                bringIntoView);
-        lineUpScroll();
-    }
-
-    /**
-     * Custom layout which figures out its line spacing.  If -1 is passed in for
-     * the height, it will use the ascent and descent from the paint to
-     * determine the line spacing.  Otherwise it will use the spacing provided.
-     */
-    private static class WebTextViewLayout extends DynamicLayout {
-        private float mLineHeight;
-        private float mDifference;
-        public WebTextViewLayout(CharSequence base, CharSequence display,
-                TextPaint paint,
-                int width, Alignment align,
-                float spacingMult, float spacingAdd,
-                boolean includepad,
-                TextUtils.TruncateAt ellipsize, int ellipsizedWidth,
-                float lineHeight) {
-            super(base, display, paint, width, align, spacingMult, spacingAdd,
-                    includepad, ellipsize, ellipsizedWidth);
-            float paintLineHeight = paint.descent() - paint.ascent();
-            if (lineHeight == -1f) {
-                mLineHeight = paintLineHeight;
-                mDifference = 0f;
-            } else {
-                mLineHeight = lineHeight;
-                // Through trial and error, I found this calculation to improve
-                // the accuracy of line placement.
-                mDifference = (lineHeight - paintLineHeight) / 2;
-            }
-        }
-
-        @Override
-        public int getLineTop(int line) {
-            return Math.round(mLineHeight * line - mDifference);
-        }
-    }
-
-    @Override public InputConnection onCreateInputConnection(
-            EditorInfo outAttrs) {
-        InputConnection connection = super.onCreateInputConnection(outAttrs);
-        if (mWebView != null) {
-            // Use the name of the textfield + the url.  Use backslash as an
-            // arbitrary separator.
-            outAttrs.fieldName = mWebView.nativeFocusCandidateName() + "\\"
-                    + mWebView.getUrl();
-        }
-        return connection;
-    }
-
-    @Override
-    public void onEditorAction(int actionCode) {
-        switch (actionCode) {
-        case EditorInfo.IME_ACTION_NEXT:
-            if (mWebView.nativeMoveCursorToNextTextInput()) {
-                // Preemptively rebuild the WebTextView, so that the action will
-                // be set properly.
-                mWebView.rebuildWebTextView();
-                setDefaultSelection();
-                mWebView.invalidate();
-            }
-            break;
-        case EditorInfo.IME_ACTION_DONE:
-            super.onEditorAction(actionCode);
-            break;
-        case EditorInfo.IME_ACTION_GO:
-        case EditorInfo.IME_ACTION_SEARCH:
-            // Send an enter and hide the soft keyboard
-            InputMethodManager.getInstance(mContext)
-                    .hideSoftInputFromWindow(getWindowToken(), 0);
-            sendDomEvent(new KeyEvent(KeyEvent.ACTION_DOWN,
-                    KeyEvent.KEYCODE_ENTER));
-            sendDomEvent(new KeyEvent(KeyEvent.ACTION_UP,
-                    KeyEvent.KEYCODE_ENTER));
-
-        default:
-            break;
-        }
-    }
-
-    @Override
-    protected void onFocusChanged(boolean focused, int direction,
-            Rect previouslyFocusedRect) {
-        mFromFocusChange = true;
-        super.onFocusChanged(focused, direction, previouslyFocusedRect);
-        if (focused) {
-            mWebView.setActive(true);
-        } else if (!mInsideRemove) {
-            mWebView.setActive(false);
-        }
-        mFromFocusChange = false;
-    }
-
-    // AdapterView.OnItemClickListener implementation
-
-    @Override
-    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-        if (id == 0 && position == 0) {
-            // Blank out the text box while we wait for WebCore to fill the form.
-            replaceText("");
-            WebSettings settings = mWebView.getSettings();
-            if (mAutoFillProfileIsSet) {
-                // Call a webview method to tell WebCore to autofill the form.
-                mWebView.autoFillForm(mQueryId);
-            } else {
-                // There is no autofill profile setup yet and the user has
-                // elected to try and set one up. Call through to the
-                // embedder to action that.
-                mWebView.getWebChromeClient().setupAutoFill(
-                        mHandler.obtainMessage(AUTOFILL_FORM));
-            }
-        }
-    }
-
-    @Override
-    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
-        super.onScrollChanged(l, t, oldl, oldt);
-        lineUpScroll();
-    }
-
-    @Override
-    protected void onSelectionChanged(int selStart, int selEnd) {
-        if (!mFromWebKit && !mFromFocusChange && !mFromSetInputType
-                && mWebView != null && !mInSetTextAndKeepSelection) {
-            if (DebugFlags.WEB_TEXT_VIEW) {
-                Log.v(LOGTAG, "onSelectionChanged selStart=" + selStart
-                        + " selEnd=" + selEnd);
-            }
-            mWebView.setSelection(selStart, selEnd);
-            lineUpScroll();
-        }
-    }
-
-    @Override
-    protected void onTextChanged(CharSequence s,int start,int before,int count){
-        super.onTextChanged(s, start, before, count);
-        String postChange = s.toString();
-        // Prevent calls to setText from invoking onTextChanged (since this will
-        // mean we are on a different textfield).  Also prevent the change when
-        // going from a textfield with a string of text to one with a smaller
-        // limit on text length from registering the onTextChanged event.
-        if (mPreChange == null || mPreChange.equals(postChange) ||
-                (mMaxLength > -1 && mPreChange.length() > mMaxLength &&
-                mPreChange.substring(0, mMaxLength).equals(postChange))) {
-            return;
-        }
-        if (0 == count) {
-            if (before > 0) {
-                // For this and all changes to the text, update our cache
-                updateCachedTextfield();
-                if (mGotDelete) {
-                    mGotDelete = false;
-                    int oldEnd = start + before;
-                    if (mDelSelEnd == oldEnd
-                            && (mDelSelStart == start
-                            || (mDelSelStart == oldEnd && before == 1))) {
-                        // If the selection is set up properly before the
-                        // delete, send the DOM events.
-                        sendDomEvent(new KeyEvent(KeyEvent.ACTION_DOWN,
-                                KeyEvent.KEYCODE_DEL));
-                        sendDomEvent(new KeyEvent(KeyEvent.ACTION_UP,
-                                KeyEvent.KEYCODE_DEL));
-                        return;
-                    }
-                }
-                // This was simply a delete or a cut, so just delete the
-                // selection.
-                mWebView.deleteSelection(start, start + before);
-            }
-            mGotDelete = false;
-            // before should never be negative, so whether it was a cut
-            // (handled above), or before is 0, in which case nothing has
-            // changed, we should return.
-            return;
-        }
-        // Ensure that this flag gets cleared, since with autocorrect on, a
-        // delete key press may have a more complex result than deleting one
-        // character or the existing selection, so it will not get cleared
-        // above.
-        mGotDelete = false;
-        // Prefer sending javascript events, so when adding one character,
-        // don't replace the unchanged text.
-        if (count > 1 && before == count - 1) {
-            String replaceButOne =  mPreChange.subSequence(start,
-                    start + before).toString();
-            String replacedString = s.subSequence(start,
-                    start + before).toString();
-            if (replaceButOne.equals(replacedString)) {
-                // we're just adding one character
-                start += before;
-                before = 0;
-                count = 1;
-            }
-        }
-        mPreChange = postChange;
-        // Find the last character being replaced.  If it can be represented by
-        // events, we will pass them to native so we can see javascript events.
-        // Otherwise, replace the text being changed in the textfield.
-        KeyEvent[] events = null;
-        if (count == 1) {
-            TextUtils.getChars(s, start + count - 1, start + count, mCharacter, 0);
-            KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
-            events = kmap.getEvents(mCharacter);
-        }
-        boolean useKeyEvents = (events != null);
-        if (useKeyEvents) {
-            // This corrects the selection which may have been affected by the
-            // trackball or auto-correct.
-            if (DebugFlags.WEB_TEXT_VIEW) {
-                Log.v(LOGTAG, "onTextChanged start=" + start
-                        + " start + before=" + (start + before));
-            }
-            if (!mInSetTextAndKeepSelection) {
-                mWebView.setSelection(start, start + before);
-            }
-            int length = events.length;
-            for (int i = 0; i < length; i++) {
-                // We never send modifier keys to native code so don't send them
-                // here either.
-                if (!KeyEvent.isModifierKey(events[i].getKeyCode())) {
-                    sendDomEvent(events[i]);
-                }
-            }
-        } else {
-            String replace = s.subSequence(start,
-                    start + count).toString();
-            mWebView.replaceTextfieldText(start, start + before, replace,
-                    start + count,
-                    start + count);
-        }
-        updateCachedTextfield();
-    }
-
-    @Override
-    public boolean onTouchEvent(MotionEvent event) {
-        switch (event.getAction()) {
-        case MotionEvent.ACTION_DOWN:
-            super.onTouchEvent(event);
-            // This event may be the start of a drag, so store it to pass to the
-            // WebView if it is.
-            mDragStartX = event.getX();
-            mDragStartY = event.getY();
-            mDragStartTime = event.getEventTime();
-            mDragSent = false;
-            mScrolled = false;
-            mGotTouchDown = true;
-            mHasPerformedLongClick = false;
-            break;
-        case MotionEvent.ACTION_MOVE:
-            if (mHasPerformedLongClick) {
-                mGotTouchDown = false;
-                return false;
-            }
-            int slop = ViewConfiguration.get(mContext).getScaledTouchSlop();
-            Spannable buffer = getText();
-            int initialScrollX = Touch.getInitialScrollX(this, buffer);
-            int initialScrollY = Touch.getInitialScrollY(this, buffer);
-            super.onTouchEvent(event);
-            int dx = Math.abs(mScrollX - initialScrollX);
-            int dy = Math.abs(mScrollY - initialScrollY);
-            // Use a smaller slop when checking to see if we've moved far enough
-            // to scroll the text, because experimentally, slop has shown to be
-            // to big for the case of a small textfield.
-            int smallerSlop = slop/2;
-            if (dx > smallerSlop || dy > smallerSlop) {
-                // Scrolling is handled in onScrollChanged.
-                mScrolled = true;
-                cancelLongPress();
-                return true;
-            }
-            if (Math.abs((int) event.getX() - mDragStartX) < slop
-                    && Math.abs((int) event.getY() - mDragStartY) < slop) {
-                // If the user has not scrolled further than slop, we should not
-                // send the drag.  Instead, do nothing, and when the user lifts
-                // their finger, we will change the selection.
-                return true;
-            }
-            if (mWebView != null) {
-                // Only want to set the initial state once.
-                if (!mDragSent) {
-                    mWebView.initiateTextFieldDrag(mDragStartX, mDragStartY,
-                            mDragStartTime);
-                    mDragSent = true;
-                }
-                boolean scrolled = mWebView.textFieldDrag(event);
-                if (scrolled) {
-                    mScrolled = true;
-                    cancelLongPress();
-                    return true;
-                }
-            }
-            return false;
-        case MotionEvent.ACTION_UP:
-        case MotionEvent.ACTION_CANCEL:
-            super.onTouchEvent(event);
-            if (mHasPerformedLongClick) {
-                mGotTouchDown = false;
-                return false;
-            }
-            if (!mScrolled) {
-                // If the page scrolled, or the TextView scrolled, we do not
-                // want to change the selection
-                cancelLongPress();
-                if (mGotTouchDown && mWebView != null) {
-                    mWebView.touchUpOnTextField(event);
-                }
-            }
-            // Necessary for the WebView to reset its state
-            if (mWebView != null && mDragSent) {
-                mWebView.onTouchEvent(event);
-            }
-            mGotTouchDown = false;
-            break;
-        default:
-            break;
-        }
-        return true;
-    }
-
-    @Override
-    public boolean onTrackballEvent(MotionEvent event) {
-        if (isPopupShowing()) {
-            return super.onTrackballEvent(event);
-        }
-        if (event.getAction() != MotionEvent.ACTION_MOVE) {
-            return false;
-        }
-        Spannable text = getText();
-        MovementMethod move = getMovementMethod();
-        if (move != null && getLayout() != null &&
-            move.onTrackballEvent(this, text, event)) {
-            // Selection is changed in onSelectionChanged
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public boolean performLongClick() {
-        mHasPerformedLongClick = true;
-        return super.performLongClick();
-    }
-
-    /**
-     * Remove this WebTextView from its host WebView, and return
-     * focus to the host.
-     */
-    /* package */ void remove() {
-        // hide the soft keyboard when the edit text is out of focus
-        InputMethodManager imm = InputMethodManager.getInstance(mContext);
-        if (imm.isActive(this)) {
-            imm.hideSoftInputFromWindow(getWindowToken(), 0);
-        }
-        mInsideRemove = true;
-        boolean isFocused = hasFocus();
-        mWebView.getWebView().removeView(this);
-        if (isFocused) {
-            mWebView.getWebView().requestFocus();
-        }
-        mInsideRemove = false;
-        mHandler.removeCallbacksAndMessages(null);
-    }
-
-    @Override
-    public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) {
-        // Do nothing, since webkit will put the textfield on screen.
-        return true;
-    }
-
-    /**
-     *  Send the DOM events for the specified event.
-     *  @param event    KeyEvent to be translated into a DOM event.
-     */
-    private void sendDomEvent(KeyEvent event) {
-        mWebView.passToJavaScript(getText().toString(), event);
-    }
-
-    /**
-     *  Always use this instead of setAdapter, as this has features specific to
-     *  the WebTextView.
-     */
-    public void setAdapterCustom(AutoCompleteAdapter adapter) {
-        if (adapter != null) {
-            setInputType(getInputType()
-                    | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
-            adapter.setTextView(this);
-            if (mAutoFillable) {
-                setOnItemClickListener(this);
-            } else {
-                setOnItemClickListener(null);
-            }
-            showDropDown();
-        } else {
-            dismissDropDown();
-        }
-        super.setAdapter(adapter);
-    }
-
-    /**
-     *  This is a special version of ArrayAdapter which changes its text size
-     *  to match the text size of its host TextView.
-     */
-    public static class AutoCompleteAdapter extends ArrayAdapter<String> {
-        private TextView mTextView;
-
-        public AutoCompleteAdapter(Context context, ArrayList<String> entries) {
-            super(context, com.android.internal.R.layout
-                    .web_text_view_dropdown, entries);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
-            TextView tv =
-                    (TextView) super.getView(position, convertView, parent);
-            if (tv != null && mTextView != null) {
-                tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextView.getTextSize());
-            }
-            return tv;
-        }
-
-        /**
-         * Set the TextView so we can match its text size.
-         */
-        private void setTextView(TextView tv) {
-            mTextView = tv;
-        }
-    }
-
-    /**
-     * Sets the selection when the user clicks on a textfield or textarea with
-     * the trackball or center key, or starts typing into it without clicking on
-     * it.
-     */
-    /* package */ void setDefaultSelection() {
-        Spannable text = (Spannable) getText();
-        int selection = mSingle ? text.length() : 0;
-        if (Selection.getSelectionStart(text) == selection
-                && Selection.getSelectionEnd(text) == selection) {
-            // The selection of the UI copy is set correctly, but the
-            // WebTextView still needs to inform the webkit thread to set the
-            // selection.  Normally that is done in onSelectionChanged, but
-            // onSelectionChanged will not be called because the UI copy is not
-            // changing.  (This can happen when the WebTextView takes focus.
-            // That onSelectionChanged was blocked because the selection set
-            // when focusing is not necessarily the desirable selection for
-            // WebTextView.)
-            if (mWebView != null) {
-                mWebView.setSelection(selection, selection);
-            }
-        } else {
-            Selection.setSelection(text, selection, selection);
-        }
-        if (mWebView != null) mWebView.incrementTextGeneration();
-    }
-
-    @Override
-    public void setInputType(int type) {
-        mFromSetInputType = true;
-        super.setInputType(type);
-        mFromSetInputType = false;
-    }
-
-    private void setMaxLength(int maxLength) {
-        mMaxLength = maxLength;
-        if (-1 == maxLength) {
-            setFilters(NO_FILTERS);
-        } else {
-            setFilters(new InputFilter[] {
-                new InputFilter.LengthFilter(maxLength) });
-        }
-    }
-
-    /**
-     *  Set the pointer for this node so it can be determined which node this
-     *  WebTextView represents.
-     *  @param  ptr Integer representing the pointer to the node which this
-     *          WebTextView represents.
-     */
-    /* package */ void setNodePointer(int ptr) {
-        if (ptr != mNodePointer) {
-            mNodePointer = ptr;
-            setAdapterCustom(null);
-        }
-    }
-
-    /**
-     * Determine the position and size of WebTextView, and add it to the
-     * WebView's view heirarchy.  All parameters are presumed to be in
-     * view coordinates.  Also requests Focus and sets the cursor to not
-     * request to be in view.
-     * @param x         x-position of the textfield.
-     * @param y         y-position of the textfield.
-     * @param width     width of the textfield.
-     * @param height    height of the textfield.
-     */
-    /* package */ void setRect(int x, int y, int width, int height) {
-        LayoutParams lp = (LayoutParams) getLayoutParams();
-        x -= mRingInset;
-        y -= mRingInset;
-        width += 2 * mRingInset;
-        height += 2 * mRingInset;
-        boolean needsUpdate = false;
-        if (null == lp) {
-            lp = new LayoutParams(width, height, x, y);
-        } else {
-            if ((lp.x != x) || (lp.y != y) || (lp.width != width)
-                    || (lp.height != height)) {
-                needsUpdate = true;
-                lp.x = x;
-                lp.y = y;
-                lp.width = width;
-                lp.height = height;
-            }
-        }
-        if (getParent() == null) {
-            // Insert the view so that it's drawn first (at index 0)
-            mWebView.getWebView().addView(this, 0, lp);
-        } else if (needsUpdate) {
-            setLayoutParams(lp);
-        }
-        // Set up a measure spec so a layout can always be recreated.
-        mWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
-        mHeightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
-    }
-
-    /**
-     * Set the selection, and disable our onSelectionChanged action.
-     */
-    /* package */ void setSelectionFromWebKit(int start, int end) {
-        if (start < 0 || end < 0) return;
-        Spannable text = (Spannable) getText();
-        int length = text.length();
-        if (start > length || end > length) return;
-        mFromWebKit = true;
-        Selection.setSelection(text, start, end);
-        mFromWebKit = false;
-    }
-
-    /**
-     * Update the text size according to the size of the focus candidate's text
-     * size in mWebView.  Should only be called from mWebView.
-     */
-    /* package */ void updateTextSize() {
-        Assert.assertNotNull("updateTextSize should only be called from "
-                + "mWebView, so mWebView should never be null!", mWebView);
-        // Note that this is approximately WebView.contentToViewDimension,
-        // without being rounded.
-        float size = mWebView.nativeFocusCandidateTextSize()
-                * mWebView.getScale();
-        setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
-    }
-
-    /**
-     * Set the text to the new string, but use the old selection, making sure
-     * to keep it within the new string.
-     * @param   text    The new text to place in the textfield.
-     */
-    /* package */ void setTextAndKeepSelection(String text) {
-        Editable edit = getText();
-        mPreChange = text;
-        if (edit.toString().equals(text)) {
-            return;
-        }
-        int selStart = Selection.getSelectionStart(edit);
-        int selEnd = Selection.getSelectionEnd(edit);
-        mInSetTextAndKeepSelection = true;
-        edit.replace(0, edit.length(), text);
-        int newLength = edit.length();
-        if (selStart > newLength) selStart = newLength;
-        if (selEnd > newLength) selEnd = newLength;
-        Selection.setSelection(edit, selStart, selEnd);
-        mInSetTextAndKeepSelection = false;
-        InputMethodManager imm = InputMethodManager.peekInstance();
-        if (imm != null && imm.isActive(this)) {
-            // Since the text has changed, do not allow the IME to replace the
-            // existing text as though it were a completion.
-            imm.restartInput(this);
-        }
-        updateCachedTextfield();
-    }
-
-    /**
-     * Called by WebView.rebuildWebTextView().  Based on the type of the <input>
-     * element, set up the WebTextView, its InputType, and IME Options properly.
-     * @param type int corresponding to enum "Type" defined in CachedInput.h.
-     *              Does not correspond to HTMLInputElement::InputType so this
-     *              is unaffected if that changes, and also because that has no
-     *              type corresponding to textarea (which is its own tag).
-     */
-    /* package */ void setType(int type) {
-        if (mWebView == null) return;
-        boolean single = true;
-        int maxLength = -1;
-        int inputType = InputType.TYPE_CLASS_TEXT
-                | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
-        int imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
-                | EditorInfo.IME_FLAG_NO_FULLSCREEN;
-        if (!mWebView.nativeFocusCandidateIsSpellcheck()) {
-            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
-        }
-        if (TEXT_AREA != type
-                && mWebView.nativeFocusCandidateHasNextTextfield()) {
-            imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;
-        }
-        switch (type) {
-            case NORMAL_TEXT_FIELD:
-                imeOptions |= EditorInfo.IME_ACTION_GO;
-                break;
-            case TEXT_AREA:
-                single = false;
-                inputType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE
-                        | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
-                        | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
-                imeOptions |= EditorInfo.IME_ACTION_NONE;
-                break;
-            case PASSWORD:
-                inputType |= EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD;
-                imeOptions |= EditorInfo.IME_ACTION_GO;
-                break;
-            case SEARCH:
-                imeOptions |= EditorInfo.IME_ACTION_SEARCH;
-                break;
-            case EMAIL:
-                // inputType needs to be overwritten because of the different text variation.
-                inputType = InputType.TYPE_CLASS_TEXT
-                        | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
-                imeOptions |= EditorInfo.IME_ACTION_GO;
-                break;
-            case NUMBER:
-                // inputType needs to be overwritten because of the different class.
-                inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL
-                        | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL;
-                // Number and telephone do not have both a Tab key and an
-                // action, so set the action to NEXT
-                imeOptions |= EditorInfo.IME_ACTION_NEXT;
-                break;
-            case TELEPHONE:
-                // inputType needs to be overwritten because of the different class.
-                inputType = InputType.TYPE_CLASS_PHONE;
-                imeOptions |= EditorInfo.IME_ACTION_NEXT;
-                break;
-            case URL:
-                // TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so
-                // exclude it for now.
-                imeOptions |= EditorInfo.IME_ACTION_GO;
-                break;
-            default:
-                imeOptions |= EditorInfo.IME_ACTION_GO;
-                break;
-        }
-        setHint(null);
-        setThreshold(1);
-        boolean autoComplete = false;
-        if (single) {
-            mWebView.requestLabel(mWebView.nativeFocusCandidateFramePointer(),
-                    mNodePointer);
-            maxLength = mWebView.nativeFocusCandidateMaxLength();
-            autoComplete = mWebView.nativeFocusCandidateIsAutoComplete();
-            if (type != PASSWORD && (mAutoFillable || autoComplete)) {
-                String name = mWebView.nativeFocusCandidateName();
-                if (name != null && name.length() > 0) {
-                    mWebView.requestFormData(name, mNodePointer, mAutoFillable,
-                            autoComplete);
-                }
-            }
-        }
-        mSingle = single;
-        setMaxLength(maxLength);
-        setHorizontallyScrolling(single);
-        setInputType(inputType);
-        clearComposingText();
-        setImeOptions(imeOptions);
-        setVisibility(VISIBLE);
-        if (!autoComplete) {
-            setAdapterCustom(null);
-        }
-    }
-
-    /**
-     *  Update the cache to reflect the current text.
-     */
-    /* package */ void updateCachedTextfield() {
-        mWebView.updateCachedTextfield(getText().toString());
-    }
-
-    /* package */ void setAutoFillProfileIsSet(boolean autoFillProfileIsSet) {
-        mAutoFillProfileIsSet = autoFillProfileIsSet;
-    }
+    static final int FORM_NOT_AUTOFILLABLE = -1;
 
     static String urlForAutoCompleteData(String urlString) {
         // Remove any fragment or query string.
@@ -1182,10 +50,4 @@
         return url != null ? url.getProtocol() + "://" + url.getHost() + url.getPath() : null;
     }
 
-    public void setGravityForRtl(boolean rtl) {
-        int gravity = rtl ? Gravity.RIGHT : Gravity.LEFT;
-        gravity |= mSingle ? Gravity.CENTER_VERTICAL : Gravity.TOP;
-        setGravity(gravity);
-    }
-
 }
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index 5f5e83c..c9a3ff1 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -67,7 +67,6 @@
 import android.text.InputType;
 import android.text.Selection;
 import android.text.TextUtils;
-import android.util.AttributeSet;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
 import android.util.Log;
@@ -97,8 +96,6 @@
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
 import android.view.inputmethod.InputMethodManager;
-import android.webkit.HTML5VideoInline;
-import android.webkit.WebTextView.AutoCompleteAdapter;
 import android.webkit.WebView.HitTestResult;
 import android.webkit.WebView.PictureListener;
 import android.webkit.WebViewCore.DrawData;
@@ -353,6 +350,7 @@
 // TODO: Check if any WebView published API methods are called from within here, and if so
 // we should bounce the call out via the proxy to enable any sub-class to override it.
 @Widget
+@SuppressWarnings("deprecation")
 public final class WebViewClassic implements WebViewProvider, WebViewProvider.ScrollDelegate,
         WebViewProvider.ViewDelegate {
     private class InnerGlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {
@@ -852,7 +850,6 @@
     private WebViewCore mWebViewCore;
     // Handler for dispatching UI messages.
     /* package */ final Handler mPrivateHandler = new PrivateHandler();
-    private WebTextView mWebTextView;
     // Used to ignore changes to webkit text that arrives to the UI side after
     // more key events.
     private int mTextGeneration;
@@ -964,10 +961,6 @@
     private float mLastDeferTouchX;
     private float mLastDeferTouchY;
 
-    // To keep track of whether the current drag was initiated by a WebTextView,
-    // so that we know not to hide the cursor
-    boolean mDragFromTextInput;
-
     // Whether or not to draw the cursor ring.
     private boolean mDrawCursorRing = true;
 
@@ -1079,8 +1072,6 @@
     static final int HANDLE_ID_BASE = 2;
     static final int HANDLE_ID_EXTENT = 3;
 
-    static boolean sDisableNavcache = false;
-    static boolean sEnableWebTextView = false;
     // the color used to highlight the touch rectangles
     static final int HIGHLIGHT_COLOR = 0x6633b5e5;
     // the region indicating where the user touched on the screen
@@ -1113,7 +1104,6 @@
     private static final int SWITCH_TO_SHORTPRESS       = 3;
     private static final int SWITCH_TO_LONGPRESS        = 4;
     private static final int RELEASE_SINGLE_TAP         = 5;
-    private static final int REQUEST_FORM_DATA          = 6;
     private static final int DRAG_HELD_MOTIONLESS       = 8;
     private static final int AWAKEN_SCROLL_BARS         = 9;
     private static final int PREVENT_DEFAULT_TIMEOUT    = 10;
@@ -1128,7 +1118,6 @@
      */
     static final int SCROLL_TO_MSG_ID                   = 101;
     static final int NEW_PICTURE_MSG_ID                 = 105;
-    static final int UPDATE_TEXT_ENTRY_MSG_ID           = 106;
     static final int WEBCORE_INITIALIZED_MSG_ID         = 107;
     static final int UPDATE_TEXTFIELD_TEXT_MSG_ID       = 108;
     static final int UPDATE_ZOOM_RANGE                  = 109;
@@ -1142,13 +1131,10 @@
     // obj=Rect in doc coordinates
     static final int INVAL_RECT_MSG_ID                  = 117;
     static final int REQUEST_KEYBOARD                   = 118;
-    static final int DO_MOTION_UP                       = 119;
     static final int SHOW_FULLSCREEN                    = 120;
     static final int HIDE_FULLSCREEN                    = 121;
-    static final int DOM_FOCUS_CHANGED                  = 122;
     static final int REPLACE_BASE_CONTENT               = 123;
     static final int FORM_DID_BLUR                      = 124;
-    static final int RETURN_LABEL                       = 125;
     static final int UPDATE_MATCH_COUNT                 = 126;
     static final int CENTER_FIT_RECT                    = 127;
     static final int REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID = 128;
@@ -1160,10 +1146,8 @@
     static final int SET_AUTOFILLABLE                   = 133;
     static final int AUTOFILL_COMPLETE                  = 134;
 
-    static final int SELECT_AT                          = 135;
     static final int SCREEN_ON                          = 136;
     static final int ENTER_FULLSCREEN_VIDEO             = 137;
-    static final int UPDATE_SELECTION                   = 138;
     static final int UPDATE_ZOOM_DENSITY                = 139;
     static final int EXIT_FULLSCREEN_VIDEO              = 140;
 
@@ -1695,7 +1679,6 @@
 
     private void init() {
         OnTrimMemoryListener.init(mContext);
-        sDisableNavcache = nativeDisableNavcache();
         mWebView.setWillNotDraw(false);
         mWebView.setFocusable(true);
         mWebView.setFocusableInTouchMode(true);
@@ -2082,10 +2065,10 @@
     /**
      * Called to clear state when moving from one page to another, or changing
      * in some other way that makes elements associated with the current page
-     * (such as WebTextView or ActionModes) no longer relevant.
+     * (such as ActionModes) no longer relevant.
      */
     private void clearHelpers() {
-        clearTextEntry();
+        hideSoftKeyboard();
         clearActionModes();
         dismissFullScreenMode();
         cancelSelectDialog();
@@ -2114,11 +2097,6 @@
             mListBoxDialog.dismiss();
             mListBoxDialog = null;
         }
-        // remove so that it doesn't cause events
-        if (mWebTextView != null) {
-            mWebTextView.remove();
-            mWebTextView = null;
-        }
         if (mNativeClass != 0) nativeStopGL();
         if (mWebViewCore != null) {
             // Tell WebViewCore to destroy itself
@@ -2833,7 +2811,6 @@
         if (mNativeClass == 0) {
             return false;
         }
-        nativeClearCursor(); // start next trackball movement from page edge
         if (top) {
             // go to the top of the document
             return pinScrollTo(getScrollX(), 0, true, 0);
@@ -2860,7 +2837,6 @@
         if (mNativeClass == 0) {
             return false;
         }
-        nativeClearCursor(); // start next trackball movement from page edge
         if (bottom) {
             return pinScrollTo(getScrollX(), computeRealVerticalScrollRange(), true, 0);
         }
@@ -2906,25 +2882,6 @@
     }
 
     /**
-     *  Return true if the browser is displaying a TextView for text input.
-     */
-    private boolean inEditingMode() {
-        return mWebTextView != null && mWebTextView.getParent() != null;
-    }
-
-    /**
-     * Remove the WebTextView.
-     */
-    private void clearTextEntry() {
-        if (inEditingMode()) {
-            mWebTextView.remove();
-        } else {
-            // The keyboard may be open with the WebView as the served view
-            hideSoftKeyboard();
-        }
-    }
-
-    /**
      * Return the current scale of the WebView
      * @return The current scale.
      */
@@ -2992,71 +2949,13 @@
      */
     public HitTestResult getHitTestResult() {
         checkThread();
-        return hitTestResult(mInitialHitTestResult);
+        return mInitialHitTestResult;
     }
 
-    private HitTestResult hitTestResult(HitTestResult fallback) {
-        if (mNativeClass == 0 || sDisableNavcache) {
-            return fallback;
-        }
-
-        HitTestResult result = new HitTestResult();
-        if (nativeHasCursorNode()) {
-            if (nativeCursorIsTextInput()) {
-                result.setType(HitTestResult.EDIT_TEXT_TYPE);
-            } else {
-                String text = nativeCursorText();
-                if (text != null) {
-                    if (text.startsWith(SCHEME_TEL)) {
-                        result.setType(HitTestResult.PHONE_TYPE);
-                        result.setExtra(URLDecoder.decode(text
-                                .substring(SCHEME_TEL.length())));
-                    } else if (text.startsWith(SCHEME_MAILTO)) {
-                        result.setType(HitTestResult.EMAIL_TYPE);
-                        result.setExtra(text.substring(SCHEME_MAILTO.length()));
-                    } else if (text.startsWith(SCHEME_GEO)) {
-                        result.setType(HitTestResult.GEO_TYPE);
-                        result.setExtra(URLDecoder.decode(text
-                                .substring(SCHEME_GEO.length())));
-                    } else if (nativeCursorIsAnchor()) {
-                        result.setType(HitTestResult.SRC_ANCHOR_TYPE);
-                        result.setExtra(text);
-                    }
-                }
-            }
-        } else if (fallback != null) {
-            /* If webkit causes a rebuild while the long press is in progress,
-             * the cursor node may be reset, even if it is still around. This
-             * uses the cursor node saved when the touch began. Since the
-             * nativeImageURI below only changes the result if it is successful,
-             * this uses the data beneath the touch if available or the original
-             * tap data otherwise.
-             */
-            Log.v(LOGTAG, "hitTestResult use fallback");
-            result = fallback;
-        }
-        int type = result.getType();
-        if (type == HitTestResult.UNKNOWN_TYPE
-                || type == HitTestResult.SRC_ANCHOR_TYPE) {
-            // Now check to see if it is an image.
-            int contentX = viewToContentX(mLastTouchX + getScrollX());
-            int contentY = viewToContentY(mLastTouchY + getScrollY());
-            String text = nativeImageURI(contentX, contentY);
-            if (text != null) {
-                result.setType(type == HitTestResult.UNKNOWN_TYPE ?
-                        HitTestResult.IMAGE_TYPE :
-                        HitTestResult.SRC_IMAGE_ANCHOR_TYPE);
-                result.setExtra(text);
-            }
-        }
-        return result;
-    }
+    // No left edge for double-tap zoom alignment
+    static final int NO_LEFTEDGE = -1;
 
     int getBlockLeftEdge(int x, int y, float readingScale) {
-        if (!sDisableNavcache) {
-            return nativeGetBlockLeftEdge(x, y, readingScale);
-        }
-
         float invReadingScale = 1.0f / readingScale;
         int readingWidth = (int) (getViewWidth() * invReadingScale);
         int left = NO_LEFTEDGE;
@@ -3080,13 +2979,6 @@
         return left;
     }
 
-    // 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 anchor or image element URL at the last tapped point.
      * If hrefMsg is null, this method returns immediately and does not
@@ -3116,17 +3008,6 @@
             hrefMsg.sendToTarget();
             return;
         }
-        if (nativeHasCursorNode()) {
-            Rect cursorBounds = cursorRingBounds();
-            if (!cursorBounds.contains(contentX, contentY)) {
-                int slop = viewToContentDimension(mNavSlop);
-                cursorBounds.inset(-slop, -slop);
-                if (cursorBounds.contains(contentX, contentY)) {
-                    contentX = cursorBounds.centerX();
-                    contentY = cursorBounds.centerY();
-                }
-            }
-        }
         mWebViewCore.sendMessage(EventHub.REQUEST_CURSOR_HREF,
                 contentX, contentY, hrefMsg);
     }
@@ -3141,11 +3022,9 @@
     public void requestImageRef(Message msg) {
         checkThread();
         if (0 == mNativeClass) return; // client isn't initialized
-        int contentX = viewToContentX(mLastTouchX + getScrollX());
-        int contentY = viewToContentY(mLastTouchY + getScrollY());
-        String ref = nativeImageURI(contentX, contentY);
+        String url = mFocusedNode != null ? mFocusedNode.mImageUrl : null;
         Bundle data = msg.getData();
-        data.putString("url", ref);
+        data.putString("url", url);
         msg.setData(data);
         msg.sendToTarget();
     }
@@ -3237,8 +3116,7 @@
 
     /**
      * Given an x coordinate in view space, convert it to content space.  Also
-     * may be used for absolute heights (such as for the WebTextView's
-     * textSize, which is unaffected by the height of the title bar).
+     * may be used for absolute heights.
      */
     /*package*/ int viewToContentX(int x) {
         return viewToContentDimension(x);
@@ -3395,7 +3273,7 @@
                 mScrollOffset.set(mVisibleRect.left, mVisibleRect.top);
                 mWebViewCore.removeMessages(EventHub.SET_SCROLL_OFFSET);
                 mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,
-                        nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, mScrollOffset);
+                        mSendScrollEvent ? 1 : 0, mScrollOffset);
             }
             mLastVisibleRectSent.set(mVisibleRect);
             mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
@@ -3857,9 +3735,7 @@
      */
     public void clearFormData() {
         checkThread();
-        if (inEditingMode()) {
-            mWebTextView.setAdapterCustom(null);
-        }
+        // TODO: Implement b/6083041
     }
 
     /**
@@ -3998,8 +3874,6 @@
      */
     private void setFindIsUp(boolean isUp) {
         mFindIsUp = isUp;
-        if (0 == mNativeClass) return; // client isn't initialized
-        nativeSetFindIsUp(isUp);
     }
 
     // Used to know whether the find dialog is open.  Affects whether
@@ -4741,9 +4615,103 @@
         return false;  // We never call invalidate(), so unconditionally returning false.
     }
 
-    private void drawContent(Canvas canvas, boolean drawRings) {
-        drawCoreAndCursorRing(canvas, mBackgroundColor,
-                mDrawCursorRing && drawRings);
+    private void drawContent(Canvas canvas) {
+        if (mDrawHistory) {
+            canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
+            canvas.drawPicture(mHistoryPicture);
+            return;
+        }
+        if (mNativeClass == 0) return;
+
+        boolean animateZoom = mZoomManager.isFixedLengthAnimationInProgress();
+        boolean animateScroll = ((!mScroller.isFinished()
+                || mVelocityTracker != null)
+                && (mTouchMode != TOUCH_DRAG_MODE ||
+                mHeldMotionless != MOTIONLESS_TRUE))
+                || mDeferTouchMode == TOUCH_DRAG_MODE;
+        if (mTouchMode == TOUCH_DRAG_MODE) {
+            if (mHeldMotionless == MOTIONLESS_PENDING) {
+                mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
+                mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
+                mHeldMotionless = MOTIONLESS_FALSE;
+            }
+            if (mHeldMotionless == MOTIONLESS_FALSE) {
+                mPrivateHandler.sendMessageDelayed(mPrivateHandler
+                        .obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
+                mPrivateHandler.sendMessageDelayed(mPrivateHandler
+                        .obtainMessage(AWAKEN_SCROLL_BARS),
+                            ViewConfiguration.getScrollDefaultDelay());
+                mHeldMotionless = MOTIONLESS_PENDING;
+            }
+        }
+        int saveCount = canvas.save();
+        if (animateZoom) {
+            mZoomManager.animateZoom(canvas);
+        } else if (!canvas.isHardwareAccelerated()) {
+            canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
+        }
+
+        boolean UIAnimationsRunning = false;
+        // Currently for each draw we compute the animation values;
+        // We may in the future decide to do that independently.
+        if (mNativeClass != 0 && !canvas.isHardwareAccelerated()
+                && nativeEvaluateLayersAnimations(mNativeClass)) {
+            UIAnimationsRunning = true;
+            // If we have unfinished (or unstarted) animations,
+            // we ask for a repaint. We only need to do this in software
+            // rendering (with hardware rendering we already have a different
+            // method of requesting a repaint)
+            mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
+            invalidate();
+        }
+
+        // decide which adornments to draw
+        int extras = DRAW_EXTRAS_NONE;
+        if (!mFindIsUp && mSelectingText) {
+            extras = DRAW_EXTRAS_SELECTION;
+        }
+
+        calcOurContentVisibleRectF(mVisibleContentRect);
+        if (canvas.isHardwareAccelerated()) {
+            Rect glRectViewport = mGLViewportEmpty ? null : mGLRectViewport;
+            Rect viewRectViewport = mGLViewportEmpty ? null : mViewRectViewport;
+
+            int functor = nativeGetDrawGLFunction(mNativeClass, glRectViewport,
+                    viewRectViewport, mVisibleContentRect, getScale(), extras);
+            ((HardwareCanvas) canvas).callDrawGLFunction(functor);
+            if (mHardwareAccelSkia != getSettings().getHardwareAccelSkiaEnabled()) {
+                mHardwareAccelSkia = getSettings().getHardwareAccelSkiaEnabled();
+                nativeUseHardwareAccelSkia(mHardwareAccelSkia);
+            }
+
+        } else {
+            DrawFilter df = null;
+            if (mZoomManager.isZoomAnimating() || UIAnimationsRunning) {
+                df = mZoomFilter;
+            } else if (animateScroll) {
+                df = mScrollFilter;
+            }
+            canvas.setDrawFilter(df);
+            // XXX: Revisit splitting content.  Right now it causes a
+            // synchronization problem with layers.
+            int content = nativeDraw(canvas, mVisibleContentRect, mBackgroundColor,
+                    extras, false);
+            canvas.setDrawFilter(null);
+            if (!mBlockWebkitViewMessages && content != 0) {
+                mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0);
+            }
+        }
+
+        canvas.restoreToCount(saveCount);
+        if (mSelectingText) {
+            drawTextSelectionHandles(canvas);
+        }
+
+        if (extras == DRAW_EXTRAS_CURSOR_RING) {
+            if (mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
+                mTouchMode = TOUCH_SHORTPRESS_MODE;
+            }
+        }
     }
 
     /**
@@ -4814,8 +4782,7 @@
         if (mTitleBar != null) {
             canvas.translate(0, getTitleHeight());
         }
-        boolean drawNativeRings = !sDisableNavcache;
-        drawContent(canvas, drawNativeRings);
+        drawContent(canvas);
         canvas.restoreToCount(saveCount);
 
         if (AUTO_REDRAW_HACK && mAutoRedraw) {
@@ -4885,28 +4852,6 @@
             return false;
         }
 
-        if (mNativeClass != 0 && nativeCursorIsTextInput()) {
-            // Send the click so that the textfield is in focus
-            centerKeyPressOnTextField();
-            rebuildWebTextView();
-        } else {
-            clearTextEntry();
-        }
-        if (inEditingMode()) {
-            // Since we just called rebuildWebTextView, the layout is not set
-            // properly.  Update it so it can correctly find the word to select.
-            mWebTextView.ensureLayout();
-            // Provide a touch down event to WebTextView, which will allow it
-            // to store the location to use in performLongClick.
-            AbsoluteLayout.LayoutParams params
-                    = (AbsoluteLayout.LayoutParams) mWebTextView.getLayoutParams();
-            MotionEvent fake = MotionEvent.obtain(mLastTouchTime,
-                    mLastTouchTime, MotionEvent.ACTION_DOWN,
-                    mLastTouchX - params.x + getScrollX(),
-                    mLastTouchY - params.y + getScrollY(), 0);
-            mWebTextView.dispatchTouchEvent(fake);
-            return mWebTextView.performLongClick();
-        }
         if (mSelectingText) return false; // long click does nothing on selection
         /* if long click brings up a context menu, the super function
          * returns true and we're done. Otherwise, nothing happened when
@@ -4969,69 +4914,6 @@
      */
     private SelectActionModeCallback mSelectCallback;
 
-    // These values are possible options for didUpdateWebTextViewDimensions.
-    private static final int FULLY_ON_SCREEN = 0;
-    private static final int INTERSECTS_SCREEN = 1;
-    private static final int ANYWHERE = 2;
-
-    /**
-     * Check to see if the focused textfield/textarea is still on screen.  If it
-     * is, update the the dimensions and location of WebTextView.  Otherwise,
-     * remove the WebTextView.  Should be called when the zoom level changes.
-     * @param intersection How to determine whether the textfield/textarea is
-     *        still on screen.
-     * @return boolean True if the textfield/textarea is still on screen and the
-     *         dimensions/location of WebTextView have been updated.
-     */
-    private boolean didUpdateWebTextViewDimensions(int intersection) {
-        Rect contentBounds = nativeFocusCandidateNodeBounds();
-        Rect vBox = contentToViewRect(contentBounds);
-        Rect visibleRect = new Rect();
-        calcOurVisibleRect(visibleRect);
-        offsetByLayerScrollPosition(vBox);
-        // If the textfield is on screen, place the WebTextView in
-        // its new place, accounting for our new scroll/zoom values,
-        // and adjust its textsize.
-        boolean onScreen;
-        switch (intersection) {
-            case FULLY_ON_SCREEN:
-                onScreen = visibleRect.contains(vBox);
-                break;
-            case INTERSECTS_SCREEN:
-                onScreen = Rect.intersects(visibleRect, vBox);
-                break;
-            case ANYWHERE:
-                onScreen = true;
-                break;
-            default:
-                throw new AssertionError(
-                        "invalid parameter passed to didUpdateWebTextViewDimensions");
-        }
-        if (onScreen) {
-            mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
-                    vBox.height());
-            mWebTextView.updateTextSize();
-            updateWebTextViewPadding();
-            return true;
-        } else {
-            // The textfield is now off screen.  The user probably
-            // was not zooming to see the textfield better.  Remove
-            // the WebTextView.  If the user types a key, and the
-            // textfield is still in focus, we will reconstruct
-            // the WebTextView and scroll it back on screen.
-            mWebTextView.remove();
-            return false;
-        }
-    }
-
-    private void offsetByLayerScrollPosition(Rect box) {
-        if ((mCurrentScrollingLayerId != 0)
-                && (mCurrentScrollingLayerId == nativeFocusCandidateLayerId())) {
-            box.offsetTo(box.left - mScrollingLayerRect.left,
-                    box.top - mScrollingLayerRect.top);
-        }
-    }
-
     void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator,
             boolean isPictureAfterFirstLayout) {
         if (mNativeClass == 0)
@@ -5061,20 +4943,9 @@
     }
 
     private void onZoomAnimationStart() {
-        // If it is in password mode, turn it off so it does not draw misplaced.
-        if (inEditingMode()) {
-            mWebTextView.setVisibility(View.INVISIBLE);
-        }
     }
 
     private void onZoomAnimationEnd() {
-        // adjust the edit text view if needed
-        if (inEditingMode()
-                && didUpdateWebTextViewDimensions(FULLY_ON_SCREEN)) {
-            // If it is a password field, start drawing the WebTextView once
-            // again.
-            mWebTextView.setVisibility(View.VISIBLE);
-        }
     }
 
     void onFixedLengthZoomAnimationStart() {
@@ -5101,128 +4972,6 @@
     private final DrawFilter mScrollFilter =
             new PaintFlagsDrawFilter(SCROLL_BITS, 0);
 
-    private void drawCoreAndCursorRing(Canvas canvas, int color,
-        boolean drawCursorRing) {
-        if (mDrawHistory) {
-            canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
-            canvas.drawPicture(mHistoryPicture);
-            return;
-        }
-        if (mNativeClass == 0) return;
-
-        boolean animateZoom = mZoomManager.isFixedLengthAnimationInProgress();
-        boolean animateScroll = ((!mScroller.isFinished()
-                || mVelocityTracker != null)
-                && (mTouchMode != TOUCH_DRAG_MODE ||
-                mHeldMotionless != MOTIONLESS_TRUE))
-                || mDeferTouchMode == TOUCH_DRAG_MODE;
-        if (mTouchMode == TOUCH_DRAG_MODE) {
-            if (mHeldMotionless == MOTIONLESS_PENDING) {
-                mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
-                mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
-                mHeldMotionless = MOTIONLESS_FALSE;
-            }
-            if (mHeldMotionless == MOTIONLESS_FALSE) {
-                mPrivateHandler.sendMessageDelayed(mPrivateHandler
-                        .obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
-                mPrivateHandler.sendMessageDelayed(mPrivateHandler
-                        .obtainMessage(AWAKEN_SCROLL_BARS),
-                            ViewConfiguration.getScrollDefaultDelay());
-                mHeldMotionless = MOTIONLESS_PENDING;
-            }
-        }
-        int saveCount = canvas.save();
-        if (animateZoom) {
-            mZoomManager.animateZoom(canvas);
-        } else if (!canvas.isHardwareAccelerated()) {
-            canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
-        }
-
-        boolean UIAnimationsRunning = false;
-        // Currently for each draw we compute the animation values;
-        // We may in the future decide to do that independently.
-        if (mNativeClass != 0 && !canvas.isHardwareAccelerated()
-                && nativeEvaluateLayersAnimations(mNativeClass)) {
-            UIAnimationsRunning = true;
-            // If we have unfinished (or unstarted) animations,
-            // we ask for a repaint. We only need to do this in software
-            // rendering (with hardware rendering we already have a different
-            // method of requesting a repaint)
-            mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
-            invalidate();
-        }
-
-        // decide which adornments to draw
-        int extras = DRAW_EXTRAS_NONE;
-        if (!mFindIsUp) {
-            if (mSelectingText) {
-                extras = DRAW_EXTRAS_SELECTION;
-            } else if (drawCursorRing) {
-                extras = DRAW_EXTRAS_CURSOR_RING;
-            }
-        }
-        if (DebugFlags.WEB_VIEW) {
-            Log.v(LOGTAG, "mFindIsUp=" + mFindIsUp
-                    + " mSelectingText=" + mSelectingText
-                    + " nativePageShouldHandleShiftAndArrows()="
-                    + nativePageShouldHandleShiftAndArrows()
-                    + " animateZoom=" + animateZoom
-                    + " extras=" + extras);
-        }
-
-        calcOurContentVisibleRectF(mVisibleContentRect);
-        if (canvas.isHardwareAccelerated()) {
-            Rect glRectViewport = mGLViewportEmpty ? null : mGLRectViewport;
-            Rect viewRectViewport = mGLViewportEmpty ? null : mViewRectViewport;
-
-            int functor = nativeGetDrawGLFunction(mNativeClass, glRectViewport,
-                    viewRectViewport, mVisibleContentRect, getScale(), extras);
-            ((HardwareCanvas) canvas).callDrawGLFunction(functor);
-            if (mHardwareAccelSkia != getSettings().getHardwareAccelSkiaEnabled()) {
-                mHardwareAccelSkia = getSettings().getHardwareAccelSkiaEnabled();
-                nativeUseHardwareAccelSkia(mHardwareAccelSkia);
-            }
-
-        } else {
-            DrawFilter df = null;
-            if (mZoomManager.isZoomAnimating() || UIAnimationsRunning) {
-                df = mZoomFilter;
-            } else if (animateScroll) {
-                df = mScrollFilter;
-            }
-            canvas.setDrawFilter(df);
-            // XXX: Revisit splitting content.  Right now it causes a
-            // synchronization problem with layers.
-            int content = nativeDraw(canvas, mVisibleContentRect, color,
-                    extras, false);
-            canvas.setDrawFilter(null);
-            if (!mBlockWebkitViewMessages && content != 0) {
-                mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0);
-            }
-        }
-
-        canvas.restoreToCount(saveCount);
-        if (mSelectingText) {
-            drawTextSelectionHandles(canvas);
-        }
-
-        if (extras == DRAW_EXTRAS_CURSOR_RING) {
-            if (mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
-                mTouchMode = TOUCH_SHORTPRESS_MODE;
-            }
-        }
-        if (mFocusSizeChanged) {
-            mFocusSizeChanged = false;
-            // If we are zooming, this will get handled above, when the zoom
-            // finishes.  We also do not need to do this unless the WebTextView
-            // is showing. With hardware acceleration, the pageSwapCallback()
-            // updates the WebTextView position in sync with page swapping
-            if (!canvas.isHardwareAccelerated() && !animateZoom && inEditingMode()) {
-                didUpdateWebTextViewDimensions(ANYWHERE);
-            }
-        }
-    }
-
     private void ensureSelectionHandles() {
         if (mSelectHandleCenter == null) {
             mSelectHandleCenter = mContext.getResources().getDrawable(
@@ -5320,25 +5069,6 @@
         }
     }
 
-    // TODO: Remove this
-    WebViewCore.CursorData cursorData() {
-        if (sDisableNavcache) {
-            return new WebViewCore.CursorData(0, 0, 0, 0);
-        }
-        WebViewCore.CursorData result = cursorDataNoPosition();
-        Point position = nativeCursorPosition();
-        result.mX = position.x;
-        result.mY = position.y;
-        return result;
-    }
-
-    WebViewCore.CursorData cursorDataNoPosition() {
-        WebViewCore.CursorData result = new WebViewCore.CursorData();
-        result.mMoveGeneration = nativeMoveGeneration();
-        result.mFrame = nativeCursorFramePointer();
-        return result;
-    }
-
     /**
      *  Delete text from start to end in the focused textfield. If there is no
      *  focus, or if start == end, silently fail.  If start and end are out of
@@ -5389,16 +5119,6 @@
             mZoomManager.setZoomCenter(mLastTouchX, mLastTouchY);
             mZoomManager.setZoomScale(mZoomManager.getDefaultScale(), false);
         }
-        if (isTextView) {
-            rebuildWebTextView();
-            if (inEditingMode()) {
-                imm.showSoftInput(mWebTextView, 0, mWebTextView.getResultReceiver());
-                if (zoom) {
-                    didUpdateWebTextViewDimensions(INTERSECTS_SCREEN);
-                }
-                return;
-            }
-        }
         // 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
@@ -5410,202 +5130,11 @@
     // Called by WebKit to instruct the UI to hide the keyboard
     private void hideSoftKeyboard() {
         InputMethodManager imm = InputMethodManager.peekInstance();
-        if (imm != null && (imm.isActive(mWebView)
-                || (inEditingMode() && imm.isActive(mWebTextView)))) {
+        if (imm != null && (imm.isActive(mWebView))) {
             imm.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
         }
     }
 
-    /*
-     * This method checks the current focus and cursor and potentially rebuilds
-     * mWebTextView to have the appropriate properties, such as password,
-     * multiline, and what text it contains.  It also removes it if necessary.
-     */
-    /* package */ void rebuildWebTextView() {
-        if (!sEnableWebTextView) {
-            return; // always use WebKit's text entry
-        }
-        // If the WebView does not have focus, do nothing until it gains focus.
-        if (!mWebView.hasFocus() && (null == mWebTextView || !mWebTextView.hasFocus())) {
-            return;
-        }
-        boolean alreadyThere = inEditingMode();
-        // inEditingMode can only return true if mWebTextView is non-null,
-        // so we can safely call remove() if (alreadyThere)
-        if (0 == mNativeClass || !nativeFocusCandidateIsTextInput()) {
-            if (alreadyThere) {
-                mWebTextView.remove();
-            }
-            return;
-        }
-        // At this point, we know we have found an input field, so go ahead
-        // and create the WebTextView if necessary.
-        if (mWebTextView == null) {
-            mWebTextView = new WebTextView(mContext, WebViewClassic.this, mAutoFillData.getQueryId());
-            // Initialize our generation number.
-            mTextGeneration = 0;
-        }
-        mWebTextView.updateTextSize();
-        updateWebTextViewPosition();
-        String text = nativeFocusCandidateText();
-        int nodePointer = nativeFocusCandidatePointer();
-        // This needs to be called before setType, which may call
-        // requestFormData, and it needs to have the correct nodePointer.
-        mWebTextView.setNodePointer(nodePointer);
-        mWebTextView.setType(nativeFocusCandidateType());
-        // Gravity needs to be set after setType
-        mWebTextView.setGravityForRtl(nativeFocusCandidateIsRtlText());
-        if (null == text) {
-            if (DebugFlags.WEB_VIEW) {
-                Log.v(LOGTAG, "rebuildWebTextView null == text");
-            }
-            text = "";
-        }
-        mWebTextView.setTextAndKeepSelection(text);
-        InputMethodManager imm = InputMethodManager.peekInstance();
-        if (imm != null && imm.isActive(mWebTextView)) {
-            imm.restartInput(mWebTextView);
-            mWebTextView.clearComposingText();
-        }
-        if (mWebView.isFocused()) {
-            mWebTextView.requestFocus();
-        }
-    }
-
-    private void updateWebTextViewPosition() {
-        Rect visibleRect = new Rect();
-        calcOurContentVisibleRect(visibleRect);
-        // Note that sendOurVisibleRect calls viewToContent, so the coordinates
-        // should be in content coordinates.
-        Rect bounds = nativeFocusCandidateNodeBounds();
-        Rect vBox = contentToViewRect(bounds);
-        offsetByLayerScrollPosition(vBox);
-        mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height());
-        if (!Rect.intersects(bounds, visibleRect)) {
-            revealSelection();
-        }
-        updateWebTextViewPadding();
-    }
-
-    /**
-     * Update the padding of mWebTextView based on the native textfield/textarea
-     */
-    void updateWebTextViewPadding() {
-        Rect paddingRect = nativeFocusCandidatePaddingRect();
-        if (paddingRect != null) {
-            // Use contentToViewDimension since these are the dimensions of
-            // the padding.
-            mWebTextView.setPadding(
-                    contentToViewDimension(paddingRect.left),
-                    contentToViewDimension(paddingRect.top),
-                    contentToViewDimension(paddingRect.right),
-                    contentToViewDimension(paddingRect.bottom));
-        }
-    }
-
-    /**
-     * 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
-     * @param name Name of the textfield.
-     * @param nodePointer Pointer to the node of the textfield, so it can be
-     *          compared to the currently focused textfield when the data is
-     *          retrieved.
-     * @param autoFillable true if WebKit has determined this field is part of
-     *          a form that can be auto filled.
-     * @param autoComplete true if the attribute "autocomplete" is set to true
-     *          on the textfield.
-     */
-    /* package */ void requestFormData(String name, int nodePointer,
-            boolean autoFillable, boolean autoComplete) {
-        if (mWebViewCore.getSettings().getSaveFormData()) {
-            Message update = mPrivateHandler.obtainMessage(REQUEST_FORM_DATA);
-            update.arg1 = nodePointer;
-            RequestFormData updater = new RequestFormData(name, getUrl(),
-                    update, autoFillable, autoComplete);
-            Thread t = new Thread(updater);
-            t.start();
-        }
-    }
-
-    /**
-     * Pass a message to find out the <label> associated with the <input>
-     * identified by nodePointer
-     * @param framePointer Pointer to the frame containing the <input> node
-     * @param nodePointer Pointer to the node for which a <label> is desired.
-     */
-    /* package */ void requestLabel(int framePointer, int nodePointer) {
-        mWebViewCore.sendMessage(EventHub.REQUEST_LABEL, framePointer,
-                nodePointer);
-    }
-
-    /*
-     * This class requests an Adapter for the WebTextView which shows past
-     * entries stored in the database.  It is a Runnable so that it can be done
-     * in its own thread, without slowing down the UI.
-     */
-    private class RequestFormData implements Runnable {
-        private String mName;
-        private String mUrl;
-        private Message mUpdateMessage;
-        private boolean mAutoFillable;
-        private boolean mAutoComplete;
-        private WebSettingsClassic mWebSettings;
-
-        public RequestFormData(String name, String url, Message msg,
-                boolean autoFillable, boolean autoComplete) {
-            mName = name;
-            mUrl = WebTextView.urlForAutoCompleteData(url);
-            mUpdateMessage = msg;
-            mAutoFillable = autoFillable;
-            mAutoComplete = autoComplete;
-            mWebSettings = getSettings();
-        }
-
-        @Override
-        public void run() {
-            ArrayList<String> pastEntries = new ArrayList<String>();
-
-            if (mAutoFillable) {
-                // Note that code inside the adapter click handler in WebTextView depends
-                // on the AutoFill item being at the top of the drop down list. If you change
-                // the order, make sure to do it there too!
-                if (mWebSettings != null && mWebSettings.getAutoFillProfile() != null) {
-                    pastEntries.add(mWebView.getResources().getText(
-                            com.android.internal.R.string.autofill_this_form).toString() +
-                            " " +
-                            mAutoFillData.getPreviewString());
-                    mWebTextView.setAutoFillProfileIsSet(true);
-                } else {
-                    // There is no autofill profile set up yet, so add an option that
-                    // will invite the user to set their profile up.
-                    pastEntries.add(mWebView.getResources().getText(
-                            com.android.internal.R.string.setup_autofill).toString());
-                    mWebTextView.setAutoFillProfileIsSet(false);
-                }
-            }
-
-            if (mAutoComplete) {
-                pastEntries.addAll(mDatabase.getFormData(mUrl, mName));
-            }
-
-            if (pastEntries.size() > 0) {
-                AutoCompleteAdapter adapter = new
-                        AutoCompleteAdapter(mContext, pastEntries);
-                mUpdateMessage.obj = adapter;
-                mUpdateMessage.sendToTarget();
-            }
-        }
-    }
-
     /**
      * Dump the display tree to "/sdcard/displayTree.txt"
      *
@@ -5780,38 +5309,12 @@
         if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
                 && keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
             switchOutDrawHistory();
-            if (nativePageShouldHandleShiftAndArrows()) {
-                letPageHandleNavKey(keyCode, event.getEventTime(), true, event.getMetaState());
-                return true;
-            }
-            if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
-                switch (keyCode) {
-                    case KeyEvent.KEYCODE_DPAD_UP:
-                        pageUp(true);
-                        return true;
-                    case KeyEvent.KEYCODE_DPAD_DOWN:
-                        pageDown(true);
-                        return true;
-                    case KeyEvent.KEYCODE_DPAD_LEFT:
-                        nativeClearCursor(); // start next trackball movement from page edge
-                        return pinScrollTo(0, getScrollY(), true, 0);
-                    case KeyEvent.KEYCODE_DPAD_RIGHT:
-                        nativeClearCursor(); // start next trackball movement from page edge
-                        return pinScrollTo(mContentWidth, getScrollY(), true, 0);
-                }
-            }
-            if (navHandledKey(keyCode, 1, false, event.getEventTime())) {
-                mWebView.playSoundEffect(keyCodeToSoundsEffect(keyCode));
-                return true;
-            }
-            // Bubble up the key event as WebView doesn't handle it
-            return false;
+            letPageHandleNavKey(keyCode, event.getEventTime(), true, event.getMetaState());
+            return true;
         }
 
         if (isEnterActionKey(keyCode)) {
             switchOutDrawHistory();
-            boolean wantsKeyEvents = nativeCursorNodePointer() == 0
-                || nativeCursorWantsKeyEvents();
             if (event.getRepeatCount() == 0) {
                 if (mSelectingText) {
                     return true; // discard press if copy in progress
@@ -5819,10 +5322,7 @@
                 mGotCenterDown = true;
                 mPrivateHandler.sendMessageDelayed(mPrivateHandler
                         .obtainMessage(LONG_PRESS_CENTER), LONG_PRESS_TIMEOUT);
-                if (!wantsKeyEvents) return true;
             }
-            // Bubble up the key event as WebView doesn't handle it
-            if (!wantsKeyEvents) return false;
         }
 
         if (getSettings().getNavDump()) {
@@ -5841,39 +5341,10 @@
             }
         }
 
-        if (nativeCursorIsTextInput()) {
-            // This message will put the node in focus, for the DOM's notion
-            // of focus.
-            mWebViewCore.sendMessage(EventHub.FAKE_CLICK, nativeCursorFramePointer(),
-                    nativeCursorNodePointer());
-            // This will bring up the WebTextView and put it in focus, for
-            // our view system's notion of focus
-            rebuildWebTextView();
-            // Now we need to pass the event to it
-            if (inEditingMode()) {
-                mWebTextView.setDefaultSelection();
-                return mWebTextView.dispatchKeyEvent(event);
-            }
-        } else if (nativeHasFocusNode()) {
-            // In this case, the cursor is not on a text input, but the focus
-            // might be.  Check it, and if so, hand over to the WebTextView.
-            rebuildWebTextView();
-            if (inEditingMode()) {
-                mWebTextView.setDefaultSelection();
-                return mWebTextView.dispatchKeyEvent(event);
-            }
-        }
-
-        // TODO: should we pass all the keys to DOM or check the meta tag
-        if (nativeCursorWantsKeyEvents() || true) {
-            // pass the key to DOM
-            mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
-            // return true as DOM handles the key
-            return true;
-        }
-
-        // Bubble up the key event as WebView doesn't handle it
-        return false;
+        // pass the key to DOM
+        mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
+        // return true as DOM handles the key
+        return true;
     }
 
     @Override
@@ -5891,14 +5362,13 @@
         }
 
         // special CALL handling when cursor node's href is "tel:XXX"
-        if (keyCode == KeyEvent.KEYCODE_CALL && nativeHasCursorNode()) {
-            String text = nativeCursorText();
-            if (!nativeCursorIsTextInput() && text != null
-                    && text.startsWith(SCHEME_TEL)) {
-                Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(text));
-                mContext.startActivity(intent);
-                return true;
-            }
+        if (keyCode == KeyEvent.KEYCODE_CALL
+                && mInitialHitTestResult != null
+                && mInitialHitTestResult.getType() == HitTestResult.PHONE_TYPE) {
+            String text = mInitialHitTestResult.getExtra();
+            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(text));
+            mContext.startActivity(intent);
+            return true;
         }
 
         // Bubble up the key event if
@@ -5937,13 +5407,8 @@
 
         if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
                 && keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
-            if (nativePageShouldHandleShiftAndArrows()) {
-                letPageHandleNavKey(keyCode, event.getEventTime(), false, event.getMetaState());
-                return true;
-            }
-            // always handle the navigation keys in the UI thread
-            // Bubble up the key event as WebView doesn't handle it
-            return false;
+            letPageHandleNavKey(keyCode, event.getEventTime(), false, event.getMetaState());
+            return true;
         }
 
         if (isEnterActionKey(keyCode)) {
@@ -5956,49 +5421,12 @@
                 selectionDone();
                 return true; // discard press if copy in progress
             }
-
-            if (!sDisableNavcache) {
-                // perform the single click
-                Rect visibleRect = sendOurVisibleRect();
-                // Note that sendOurVisibleRect calls viewToContent, so the
-                // coordinates should be in content coordinates.
-                if (!nativeCursorIntersects(visibleRect)) {
-                    return false;
-                }
-                WebViewCore.CursorData data = cursorData();
-                mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
-                mWebView.playSoundEffect(SoundEffectConstants.CLICK);
-                if (nativeCursorIsTextInput()) {
-                    rebuildWebTextView();
-                    centerKeyPressOnTextField();
-                    if (inEditingMode()) {
-                        mWebTextView.setDefaultSelection();
-                    }
-                    return true;
-                }
-                clearTextEntry();
-                nativeShowCursorTimed();
-                if (mCallbackProxy.uiOverrideUrlLoading(nativeCursorText())) {
-                    return true;
-                }
-                if (nativeCursorNodePointer() != 0 && !nativeCursorWantsKeyEvents()) {
-                    mWebViewCore.sendMessage(EventHub.CLICK, data.mFrame,
-                            nativeCursorNodePointer());
-                    return true;
-                }
-            }
         }
 
-        // TODO: should we pass all the keys to DOM or check the meta tag
-        if (nativeCursorWantsKeyEvents() || true) {
-            // pass the key to DOM
-            mWebViewCore.sendMessage(EventHub.KEY_UP, event);
-            // return true as DOM handles the key
-            return true;
-        }
-
-        // Bubble up the key event as WebView doesn't handle it
-        return false;
+        // pass the key to DOM
+        mWebViewCore.sendMessage(EventHub.KEY_UP, event);
+        // return true as DOM handles the key
+        return true;
     }
 
     private boolean startSelectActionMode() {
@@ -6252,18 +5680,11 @@
             if (mWebView.hasFocus()) {
                 // If our window regained focus, and we have focus, then begin
                 // drawing the cursor ring
-                mDrawCursorRing = !inEditingMode();
+                mDrawCursorRing = true;
                 setFocusControllerActive(true);
             } else {
                 mDrawCursorRing = false;
-                if (!inEditingMode()) {
-                    // If our window gained focus, but we do not have it, do not
-                    // draw the cursor ring.
-                    setFocusControllerActive(false);
-                }
-                // We do not call recordButtons here because we assume
-                // that when we lost focus, or window focus, it got called with
-                // false for the first parameter
+                setFocusControllerActive(false);
             }
         } else {
             if (!mZoomManager.isZoomPickerVisible()) {
@@ -6329,23 +5750,11 @@
             Log.v(LOGTAG, "MT focusChanged " + focused + ", " + direction);
         }
         if (focused) {
-            // When we regain focus, if we have window focus, resume drawing
-            // the cursor ring
-            if (mWebView.hasWindowFocus()) {
-                mDrawCursorRing = !inEditingMode();
-                setFocusControllerActive(true);
-            //} else {
-                // The WebView has gained focus while we do not have
-                // windowfocus.  When our window lost focus, we should have
-                // called recordButtons(false...)
-            }
+            mDrawCursorRing = true;
+            setFocusControllerActive(true);
         } else {
-            // When we lost focus, unless focus went to the TextView (which is
-            // true if we are in editing mode), stop drawing the cursor ring.
             mDrawCursorRing = false;
-            if (!inEditingMode()) {
-                setFocusControllerActive(false);
-            }
+            setFocusControllerActive(false);
             mKeysPressed.clear();
         }
     }
@@ -6451,13 +5860,7 @@
                 // action is added to KeyEvent.
                 break;
         }
-        if (inEditingMode() && mWebTextView.isFocused()) {
-            // Ensure that the WebTextView gets the event, even if it does
-            // not currently have a bounds.
-            return mWebTextView.dispatchKeyEvent(event);
-        } else {
-            return mWebViewPrivate.super_dispatchKeyEvent(event);
-        }
+        return mWebViewPrivate.super_dispatchKeyEvent(event);
     }
 
     /*
@@ -6487,14 +5890,8 @@
     private static final float MMA_WEIGHT_N = 5;
 
     private boolean hitFocusedPlugin(int contentX, int contentY) {
-        if (DebugFlags.WEB_VIEW) {
-            Log.v(LOGTAG, "nativeFocusIsPlugin()=" + nativeFocusIsPlugin());
-            Rect r = nativeFocusNodeBounds();
-            Log.v(LOGTAG, "nativeFocusNodeBounds()=(" + r.left + ", " + r.top
-                    + ", " + r.right + ", " + r.bottom + ")");
-        }
-        return nativeFocusIsPlugin()
-                && nativeFocusNodeBounds().contains(contentX, contentY);
+        // TODO: Figure out what to do with this (b/6111517)
+        return false;
     }
 
     private boolean shouldForwardTouchEvent() {
@@ -6559,10 +5956,9 @@
         if (mNativeClass == 0) {
             return false;
         }
-        WebViewCore.CursorData data = cursorDataNoPosition();
-        data.mX = viewToContentX((int) event.getX() + getScrollX());
-        data.mY = viewToContentY((int) event.getY() + getScrollY());
-        mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
+        int x = viewToContentX((int) event.getX() + getScrollX());
+        int y = viewToContentY((int) event.getY() + getScrollY());
+        mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, x, y);
         return true;
     }
 
@@ -6632,9 +6028,7 @@
                     nativeSetIsScrolling(false);
                 } else if (mPrivateHandler.hasMessages(RELEASE_SINGLE_TAP)) {
                     mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
-                    if (sDisableNavcache) {
-                        removeTouchHighlight();
-                    }
+                    removeTouchHighlight();
                     if (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare) {
                         mTouchMode = TOUCH_DOUBLE_TAP_MODE;
                     } else {
@@ -6652,36 +6046,30 @@
                             && (!inFullScreenMode() && mForwardTouchEvents)
                             ? hitFocusedPlugin(contentX, contentY)
                             : false;
+                    TouchHighlightData data = new TouchHighlightData();
+                    data.mX = contentX;
+                    data.mY = contentY;
+                    data.mNativeLayerRect = new Rect();
+                    data.mNativeLayer = nativeScrollableLayer(
+                            contentX, contentY, data.mNativeLayerRect, null);
+                    data.mSlop = viewToContentDimension(mNavSlop);
+                    mTouchHighlightRegion.setEmpty();
                     if (!mBlockWebkitViewMessages) {
-                        mWebViewCore.sendMessage(
-                                EventHub.UPDATE_FRAME_CACHE_IF_LOADING);
+                        mTouchHighlightRequested = System.currentTimeMillis();
+                        mWebViewCore.sendMessageAtFrontOfQueue(
+                                EventHub.HIT_TEST, data);
                     }
-                    if (sDisableNavcache) {
-                        TouchHighlightData data = new TouchHighlightData();
-                        data.mX = contentX;
-                        data.mY = contentY;
-                        data.mNativeLayerRect = new Rect();
-                        data.mNativeLayer = nativeScrollableLayer(
-                                contentX, contentY, data.mNativeLayerRect, null);
-                        data.mSlop = viewToContentDimension(mNavSlop);
-                        mTouchHighlightRegion.setEmpty();
-                        if (!mBlockWebkitViewMessages) {
-                            mTouchHighlightRequested = System.currentTimeMillis();
-                            mWebViewCore.sendMessageAtFrontOfQueue(
-                                    EventHub.HIT_TEST, data);
-                        }
-                        if (DEBUG_TOUCH_HIGHLIGHT) {
-                            if (getSettings().getNavDump()) {
-                                mTouchHighlightX = x + getScrollX();
-                                mTouchHighlightY = y + getScrollY();
-                                mPrivateHandler.postDelayed(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        mTouchHighlightX = mTouchHighlightY = 0;
-                                        invalidate();
-                                    }
-                                }, TOUCH_HIGHLIGHT_ELAPSE_TIME);
-                            }
+                    if (DEBUG_TOUCH_HIGHLIGHT) {
+                        if (getSettings().getNavDump()) {
+                            mTouchHighlightX = x + getScrollX();
+                            mTouchHighlightY = y + getScrollY();
+                            mPrivateHandler.postDelayed(new Runnable() {
+                                @Override
+                                public void run() {
+                                    mTouchHighlightX = mTouchHighlightY = 0;
+                                    invalidate();
+                                }
+                            }, TOUCH_HIGHLIGHT_ELAPSE_TIME);
                         }
                     }
                     if (mLogEvent && eventTime - mLastTouchUpTime < 1000) {
@@ -6780,9 +6168,7 @@
                     if (mTouchMode == TOUCH_DOUBLE_TAP_MODE) {
                         mTouchMode = TOUCH_INIT_MODE;
                     }
-                    if (sDisableNavcache) {
-                        removeTouchHighlight();
-                    }
+                    removeTouchHighlight();
                 }
                 if (mSelectingText && mSelectionStarted) {
                     if (DebugFlags.WEB_VIEW) {
@@ -7261,8 +6647,6 @@
         mLastTouchTime = eventTime;
         mVelocityTracker = VelocityTracker.obtain();
         mSnapScrollMode = SNAP_NONE;
-        mPrivateHandler.sendEmptyMessageDelayed(UPDATE_SELECTION,
-                ViewConfiguration.getTapTimeout());
     }
 
     private void startDrag() {
@@ -7271,10 +6655,6 @@
         WebViewCore.pauseUpdatePicture(mWebViewCore);
         nativeSetIsScrolling(true);
 
-        if (!mDragFromTextInput) {
-            nativeHideCursor();
-        }
-
         if (mHorizontalScrollBarMode != SCROLLBAR_ALWAYSOFF
                 || mVerticalScrollBarMode != SCROLLBAR_ALWAYSOFF) {
             mZoomManager.invokeZoomPicker();
@@ -7388,12 +6768,9 @@
         mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
         mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
         mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
-        if (sDisableNavcache) {
-            removeTouchHighlight();
-        }
+        removeTouchHighlight();
         mHeldMotionless = MOTIONLESS_TRUE;
         mTouchMode = TOUCH_DONE_MODE;
-        nativeHideCursor();
     }
 
     @Override
@@ -7444,7 +6821,6 @@
     private static final int SELECT_SCROLL = 5;
     private int mSelectX = 0;
     private int mSelectY = 0;
-    private boolean mFocusSizeChanged = false;
     private boolean mTrackballDown = false;
     private long mTrackballUpTime = 0;
     private long mLastCursorTime = 0;
@@ -7483,10 +6859,6 @@
             if (mNativeClass == 0) {
                 return false;
             }
-            if (time - mLastCursorTime <= TRACKBALL_TIMEOUT
-                    && !mLastCursorBounds.equals(cursorRingBounds())) {
-                nativeSelectBestAt(mLastCursorBounds);
-            }
             if (DebugFlags.WEB_VIEW) {
                 Log.v(LOGTAG, "onTrackballEvent down ev=" + ev
                         + " time=" + time
@@ -7630,13 +7002,11 @@
                         + " mTrackballRemainsX=" + mTrackballRemainsX
                         + " mTrackballRemainsY=" + mTrackballRemainsY);
             }
-            if (mNativeClass != 0 && nativePageShouldHandleShiftAndArrows()) {
+            if (mNativeClass != 0) {
                 for (int i = 0; i < count; i++) {
                     letPageHandleNavKey(selectKeyCode, time, true, metaState);
                 }
                 letPageHandleNavKey(selectKeyCode, time, false, metaState);
-            } else if (navHandledKey(selectKeyCode, count, false, time)) {
-                mWebView.playSoundEffect(keyCodeToSoundsEffect(selectKeyCode));
             }
             mTrackballRemainsX = mTrackballRemainsY = 0;
         }
@@ -7883,105 +7253,6 @@
         return mZoomManager.zoomOut();
     }
 
-    /**
-     * This selects the best clickable target at mLastTouchX and mLastTouchY
-     * and calls showCursorTimed on the native side
-     */
-    private void updateSelection() {
-        if (mNativeClass == 0 || sDisableNavcache) {
-            return;
-        }
-        mPrivateHandler.removeMessages(UPDATE_SELECTION);
-        // mLastTouchX and mLastTouchY are the point in the current viewport
-        int contentX = viewToContentX(mLastTouchX + getScrollX());
-        int contentY = viewToContentY(mLastTouchY + getScrollY());
-        int slop = viewToContentDimension(mNavSlop);
-        Rect rect = new Rect(contentX - slop, contentY - slop,
-                contentX + slop, contentY + slop);
-        nativeSelectBestAt(rect);
-        mInitialHitTestResult = hitTestResult(null);
-    }
-
-    /**
-     * Scroll the focused text field to match the WebTextView
-     * @param xPercent New x position of the WebTextView from 0 to 1.
-     */
-    /*package*/ void scrollFocusedTextInputX(float xPercent) {
-        if (!inEditingMode() || mWebViewCore == null) {
-            return;
-        }
-        mWebViewCore.sendMessage(EventHub.SCROLL_TEXT_INPUT, 0,
-                new Float(xPercent));
-    }
-
-    /**
-     * Scroll the focused textarea vertically to match the WebTextView
-     * @param y New y position of the WebTextView in view coordinates
-     */
-    /* package */ void scrollFocusedTextInputY(int y) {
-        if (!inEditingMode() || mWebViewCore == null) {
-            return;
-        }
-        mWebViewCore.sendMessage(EventHub.SCROLL_TEXT_INPUT, 0, viewToContentDimension(y));
-    }
-
-    /**
-     * Set our starting point and time for a drag from the WebTextView.
-     */
-    /*package*/ void initiateTextFieldDrag(float x, float y, long eventTime) {
-        if (!inEditingMode()) {
-            return;
-        }
-        mLastTouchX = Math.round(x + mWebTextView.getLeft() - getScrollX());
-        mLastTouchY = Math.round(y + mWebTextView.getTop() - getScrollY());
-        mLastTouchTime = eventTime;
-        if (!mScroller.isFinished()) {
-            abortAnimation();
-        }
-        mSnapScrollMode = SNAP_NONE;
-        mVelocityTracker = VelocityTracker.obtain();
-        mTouchMode = TOUCH_DRAG_START_MODE;
-    }
-
-    /**
-     * Given a motion event from the WebTextView, set its location to our
-     * coordinates, and handle the event.
-     */
-    /*package*/ boolean textFieldDrag(MotionEvent event) {
-        if (!inEditingMode()) {
-            return false;
-        }
-        mDragFromTextInput = true;
-        event.offsetLocation((mWebTextView.getLeft() - getScrollX()),
-                (mWebTextView.getTop() - getScrollY()));
-        boolean result = onTouchEvent(event);
-        mDragFromTextInput = false;
-        return result;
-    }
-
-    /**
-     * Due a touch up from a WebTextView.  This will be handled by webkit to
-     * change the selection.
-     * @param event MotionEvent in the WebTextView's coordinates.
-     */
-    /*package*/ void touchUpOnTextField(MotionEvent event) {
-        if (!inEditingMode()) {
-            return;
-        }
-        int x = viewToContentX((int) event.getX() + mWebTextView.getLeft());
-        int y = viewToContentY((int) event.getY() + mWebTextView.getTop());
-        int slop = viewToContentDimension(mNavSlop);
-        nativeMotionUp(x, y, slop);
-    }
-
-    /**
-     * Called when pressing the center key or trackball on a textfield.
-     */
-    /*package*/ void centerKeyPressOnTextField() {
-        mWebViewCore.sendMessage(EventHub.CLICK, nativeCursorFramePointer(),
-                    nativeCursorNodePointer());
-    }
-
     private void doShortPress() {
         if (mNativeClass == 0) {
             return;
@@ -7990,13 +7261,8 @@
             return;
         }
         mTouchMode = TOUCH_DONE_MODE;
-        updateSelection();
         switchOutDrawHistory();
-        // mLastTouchX and mLastTouchY are the point in the current viewport
-        int contentX = viewToContentX(mLastTouchX + getScrollX());
-        int contentY = viewToContentY(mLastTouchY + getScrollY());
-        int slop = viewToContentDimension(mNavSlop);
-        if (sDisableNavcache && !mTouchHighlightRegion.isEmpty()) {
+        if (!mTouchHighlightRegion.isEmpty()) {
             // set mTouchHighlightRequested to 0 to cause an immediate
             // drawing of the touch rings
             mTouchHighlightRequested = 0;
@@ -8011,34 +7277,12 @@
         if (mFocusedNode != null && mFocusedNode.mIntentUrl != null) {
             mWebView.playSoundEffect(SoundEffectConstants.CLICK);
             overrideLoading(mFocusedNode.mIntentUrl);
-        } else if (sDisableNavcache) {
+        } else {
             WebViewCore.TouchUpData touchUpData = new WebViewCore.TouchUpData();
             // use "0" as generation id to inform WebKit to use the same x/y as
             // it used when processing GET_TOUCH_HIGHLIGHT_RECTS
             touchUpData.mMoveGeneration = 0;
             mWebViewCore.sendMessage(EventHub.TOUCH_UP, touchUpData);
-        } else if (nativePointInNavCache(contentX, contentY, slop)) {
-            WebViewCore.MotionUpData motionUpData = new WebViewCore
-                    .MotionUpData();
-            motionUpData.mFrame = nativeCacheHitFramePointer();
-            motionUpData.mNode = nativeCacheHitNodePointer();
-            motionUpData.mBounds = nativeCacheHitNodeBounds();
-            motionUpData.mX = contentX;
-            motionUpData.mY = contentY;
-            mWebViewCore.sendMessageAtFrontOfQueue(EventHub.VALID_NODE_BOUNDS,
-                    motionUpData);
-        } else {
-            doMotionUp(contentX, contentY);
-        }
-    }
-
-    private void doMotionUp(int contentX, int contentY) {
-        int slop = viewToContentDimension(mNavSlop);
-        if (nativeMotionUp(contentX, contentY, slop) && mLogEvent) {
-            EventLog.writeEvent(EventLogTags.BROWSER_SNAP_CENTER);
-        }
-        if (nativeHasCursorNode() && !nativeCursorIsTextInput()) {
-            mWebView.playSoundEffect(SoundEffectConstants.CLICK);
         }
     }
 
@@ -8046,19 +7290,6 @@
         mWebViewCore.sendMessage(EventHub.PLUGIN_SURFACE_READY);
     }
 
-    /**
-     * Returns plugin bounds if x/y in content coordinates corresponds to a
-     * plugin. Otherwise a NULL rectangle is returned.
-     */
-    Rect getPluginBounds(int x, int y) {
-        int slop = viewToContentDimension(mNavSlop);
-        if (nativePointInNavCache(x, y, slop) && nativeCacheHitIsPlugin()) {
-            return nativeCacheHitNodeBounds();
-        } else {
-            return null;
-        }
-    }
-
     /*
      * Return true if the rect (e.g. plugin) is fully visible and maximized
      * inside the WebView.
@@ -8142,36 +7373,29 @@
         // background window, it can steal focus.
         if (mFindIsUp) return false;
         boolean result = false;
-        if (inEditingMode()) {
-            result = mWebTextView.requestFocus(direction,
-                    previouslyFocusedRect);
-        } else {
-            result = mWebViewPrivate.super_requestFocus(direction, previouslyFocusedRect);
-            if (mWebViewCore.getSettings().getNeedInitialFocus() && !mWebView.isInTouchMode()) {
-                // For cases such as GMail, where we gain focus from a direction,
-                // we want to move to the first available link.
-                // FIXME: If there are no visible links, we may not want to
-                int fakeKeyDirection = 0;
-                switch(direction) {
-                    case View.FOCUS_UP:
-                        fakeKeyDirection = KeyEvent.KEYCODE_DPAD_UP;
-                        break;
-                    case View.FOCUS_DOWN:
-                        fakeKeyDirection = KeyEvent.KEYCODE_DPAD_DOWN;
-                        break;
-                    case View.FOCUS_LEFT:
-                        fakeKeyDirection = KeyEvent.KEYCODE_DPAD_LEFT;
-                        break;
-                    case View.FOCUS_RIGHT:
-                        fakeKeyDirection = KeyEvent.KEYCODE_DPAD_RIGHT;
-                        break;
-                    default:
-                        return result;
-                }
-                if (mNativeClass != 0 && !nativeHasCursorNode()) {
-                    navHandledKey(fakeKeyDirection, 1, true, 0);
-                }
+        result = mWebViewPrivate.super_requestFocus(direction, previouslyFocusedRect);
+        if (mWebViewCore.getSettings().getNeedInitialFocus() && !mWebView.isInTouchMode()) {
+            // For cases such as GMail, where we gain focus from a direction,
+            // we want to move to the first available link.
+            // FIXME: If there are no visible links, we may not want to
+            int fakeKeyDirection = 0;
+            switch(direction) {
+                case View.FOCUS_UP:
+                    fakeKeyDirection = KeyEvent.KEYCODE_DPAD_UP;
+                    break;
+                case View.FOCUS_DOWN:
+                    fakeKeyDirection = KeyEvent.KEYCODE_DPAD_DOWN;
+                    break;
+                case View.FOCUS_LEFT:
+                    fakeKeyDirection = KeyEvent.KEYCODE_DPAD_LEFT;
+                    break;
+                case View.FOCUS_RIGHT:
+                    fakeKeyDirection = KeyEvent.KEYCODE_DPAD_RIGHT;
+                    break;
+                default:
+                    return result;
             }
+            // TODO: Send initial focus request to webkit (b/6108927)
         }
         return result;
     }
@@ -8234,7 +7458,7 @@
             return false;
         }
         // don't scroll while in zoom animation. When it is done, we will adjust
-        // the necessary components (e.g., WebTextView if it is in editing mode)
+        // the necessary components
         if (mZoomManager.isFixedLengthAnimationInProgress()) {
             return false;
         }
@@ -8317,8 +7541,7 @@
         // document state when it goes to background, we force to save the
         // document state.
         mWebViewCore.removeMessages(EventHub.SAVE_DOCUMENT_STATE);
-        mWebViewCore.sendMessageDelayed(EventHub.SAVE_DOCUMENT_STATE,
-                cursorData(), 1000);
+        mWebViewCore.sendMessageDelayed(EventHub.SAVE_DOCUMENT_STATE, null, 1000);
     }
 
     /**
@@ -8885,34 +8108,16 @@
                             SCROLL_SELECT_TEXT, SELECT_SCROLL_INTERVAL);
                     break;
                 }
-                case UPDATE_SELECTION: {
-                    if (mTouchMode == TOUCH_INIT_MODE
-                            || mTouchMode == TOUCH_SHORTPRESS_MODE
-                            || mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
-                        updateSelection();
-                    }
-                    break;
-                }
                 case SWITCH_TO_SHORTPRESS: {
                     if (mTouchMode == TOUCH_INIT_MODE) {
-                        if (!sDisableNavcache
-                                && mPreventDefault != PREVENT_DEFAULT_YES) {
-                            mTouchMode = TOUCH_SHORTPRESS_START_MODE;
-                            updateSelection();
-                        } else {
-                            // set to TOUCH_SHORTPRESS_MODE so that it won't
-                            // trigger double tap any more
-                            mTouchMode = TOUCH_SHORTPRESS_MODE;
-                        }
+                        mTouchMode = TOUCH_SHORTPRESS_MODE;
                     } else if (mTouchMode == TOUCH_DOUBLE_TAP_MODE) {
                         mTouchMode = TOUCH_DONE_MODE;
                     }
                     break;
                 }
                 case SWITCH_TO_LONGPRESS: {
-                    if (sDisableNavcache) {
-                        removeTouchHighlight();
-                    }
+                    removeTouchHighlight();
                     if (inFullScreenMode() || mDeferTouchProcess) {
                         TouchEventData ted = new TouchEventData();
                         ted.mAction = WebViewCore.ACTION_LONGPRESS;
@@ -8953,8 +8158,7 @@
                         // view, but is only necessary if the IME is showing
                         InputMethodManager imm = InputMethodManager.peekInstance();
                         if (imm == null || !imm.isAcceptingText()
-                                || (!imm.isActive(mWebView) && (!inEditingMode()
-                                || !imm.isActive(mWebTextView)))) {
+                                || !imm.isActive(mWebView)) {
                             break;
                         }
                     }
@@ -9012,10 +8216,7 @@
                         if (null == text) {
                             text = "";
                         }
-                        if (inEditingMode() &&
-                                mWebTextView.isSameTextField(msg.arg1)) {
-                            mWebTextView.setTextAndKeepSelection(text);
-                        } else if (mInputConnection != null &&
+                        if (mInputConnection != null &&
                                 mFieldPointer == msg.arg1) {
                             mInputConnection.setTextAndKeepSelection(text);
                         }
@@ -9029,37 +8230,13 @@
                             (WebViewCore.TextSelectionData) msg.obj);
                     break;
                 case FORM_DID_BLUR:
-                    if (inEditingMode()
-                            && mWebTextView.isSameTextField(msg.arg1)) {
-                        hideSoftKeyboard();
-                    }
-                    break;
-                case RETURN_LABEL:
-                    if (inEditingMode()
-                            && mWebTextView.isSameTextField(msg.arg1)) {
-                        mWebTextView.setHint((String) msg.obj);
-                        InputMethodManager imm
-                                = InputMethodManager.peekInstance();
-                        // The hint is propagated to the IME in
-                        // onCreateInputConnection.  If the IME is already
-                        // active, restart it so that its hint text is updated.
-                        if (imm != null && imm.isActive(mWebTextView)) {
-                            imm.restartInput(mWebTextView);
-                        }
-                    }
+                    // TODO: Figure out if this is needed for something (b/6111763)
                     break;
                 case UNHANDLED_NAV_KEY:
-                    navHandledKey(msg.arg1, 1, false, 0);
-                    break;
-                case UPDATE_TEXT_ENTRY_MSG_ID:
-                    // this is sent after finishing resize in WebViewCore. Make
-                    // sure the text edit box is still on the  screen.
-                    if (inEditingMode() && nativeCursorIsTextInput()) {
-                        updateWebTextViewPosition();
-                    }
+                    // TODO: Support this (b/6109044)
                     break;
                 case CLEAR_TEXT_ENTRY:
-                    clearTextEntry();
+                    hideSoftKeyboard();
                     break;
                 case INVAL_RECT_MSG_ID: {
                     Rect r = (Rect)msg.obj;
@@ -9072,12 +8249,6 @@
                     }
                     break;
                 }
-                case REQUEST_FORM_DATA:
-                    AutoCompleteAdapter adapter = (AutoCompleteAdapter) msg.obj;
-                    if (mWebTextView.isSameTextField(msg.arg1)) {
-                        mWebTextView.setAdapterCustom(adapter);
-                    }
-                    break;
 
                 case LONG_PRESS_CENTER:
                     // as this is shared by keydown and trackballdown, reset all
@@ -9128,10 +8299,6 @@
                     }
                     break;
 
-                case DO_MOTION_UP:
-                    doMotionUp(msg.arg1, msg.arg2);
-                    break;
-
                 case SCREEN_ON:
                     mWebView.setKeepScreenOn(msg.arg1 == 1);
                     break;
@@ -9171,13 +8338,6 @@
                     dismissFullScreenMode();
                     break;
 
-                case DOM_FOCUS_CHANGED:
-                    if (inEditingMode()) {
-                        nativeClearCursor();
-                        rebuildWebTextView();
-                    }
-                    break;
-
                 case SHOW_RECT_MSG_ID: {
                     WebViewCore.ShowRectData data = (WebViewCore.ShowRectData) msg.obj;
                     int x = getScrollX();
@@ -9259,22 +8419,11 @@
 
                 case SET_AUTOFILLABLE:
                     mAutoFillData = (WebViewCore.AutoFillData) msg.obj;
-                    if (mWebTextView != null) {
-                        mWebTextView.setAutoFillable(mAutoFillData.getQueryId());
-                        rebuildWebTextView();
-                    }
+                    // TODO: Support (b/6083041)
                     break;
 
                 case AUTOFILL_COMPLETE:
-                    if (mWebTextView != null) {
-                        // Clear the WebTextView adapter when AutoFill finishes
-                        // so that the drop down gets cleared.
-                        mWebTextView.setAdapterCustom(null);
-                    }
-                    break;
-
-                case SELECT_AT:
-                    nativeSelectAt(msg.arg1, msg.arg2);
+                    // TODO: Support (b/6083041)
                     break;
 
                 case COPY_TO_CLIPBOARD:
@@ -9524,9 +8673,6 @@
      * acceleration) */
     protected void pageSwapCallback(boolean notifyAnimationStarted) {
         mWebViewCore.resumeWebKitDraw();
-        if (inEditingMode()) {
-            didUpdateWebTextViewDimensions(ANYWHERE);
-        }
         if (notifyAnimationStarted) {
             mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
         }
@@ -9576,11 +8722,8 @@
             int scrollY = viewState.mScrollY;
             setContentScrollTo(scrollX, scrollY);
             if (!mDrawHistory) {
-                // As we are on a new page, remove the WebTextView. This
-                // is necessary for page loads driven by webkit, and in
-                // particular when the user was on a password field, so
-                // the WebTextView was visible.
-                clearTextEntry();
+                // As we are on a new page, hide the keyboard
+                hideSoftKeyboard();
             }
         }
         mSendScrollEvent = true;
@@ -9599,9 +8742,6 @@
         // update the zoom information based on the new picture
         mZoomManager.onNewPicture(draw);
 
-        if (draw.mFocusSizeChanged && inEditingMode()) {
-            mFocusSizeChanged = true;
-        }
         if (isPictureAfterFirstLayout) {
             mViewManager.postReadyToDrawAll();
         }
@@ -9609,15 +8749,12 @@
 
     /**
      * Used when receiving messages for REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID
-     * and UPDATE_TEXT_SELECTION_MSG_ID.  Update the selection of WebTextView.
+     * and UPDATE_TEXT_SELECTION_MSG_ID.
      */
     private void updateTextSelectionFromMessage(int nodePointer,
             int textGeneration, WebViewCore.TextSelectionData data) {
         if (textGeneration == mTextGeneration) {
-            if (inEditingMode()
-                    && mWebTextView.isSameTextField(nodePointer)) {
-                mWebTextView.setSelectionFromWebKit(data.mStart, data.mEnd);
-            } else if (mInputConnection != null && mFieldPointer == nodePointer) {
+            if (mInputConnection != null && mFieldPointer == nodePointer) {
                 mInputConnection.setSelection(data.mStart, data.mEnd);
             }
         }
@@ -9951,59 +9088,6 @@
                 new InvokeListBox(array, enabledArray, selection));
     }
 
-    // called by JNI
-    private void sendMoveFocus(int frame, int node) {
-        mWebViewCore.sendMessage(EventHub.SET_MOVE_FOCUS,
-                new WebViewCore.CursorData(frame, node, 0, 0));
-    }
-
-    // called by JNI
-    private void sendMoveMouse(int frame, int node, int x, int y) {
-        mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE,
-                new WebViewCore.CursorData(frame, node, x, y));
-    }
-
-    /*
-     * Send a mouse move event to the webcore thread.
-     *
-     * @param removeFocus Pass true to remove the WebTextView, if present.
-     * @param stopPaintingCaret Stop drawing the blinking caret if true.
-     * called by JNI
-     */
-    @SuppressWarnings("unused")
-    private void sendMoveMouseIfLatest(boolean removeFocus, boolean stopPaintingCaret) {
-        if (removeFocus) {
-            clearTextEntry();
-        }
-        mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE_IF_LATEST,
-                stopPaintingCaret ? 1 : 0, 0,
-                cursorData());
-    }
-
-    /**
-     * Called by JNI to send a message to the webcore thread that the user
-     * touched the webpage.
-     * @param touchGeneration Generation number of the touch, to ignore touches
-     *      after a new one has been generated.
-     * @param frame Pointer to the frame holding the node that was touched.
-     * @param node Pointer to the node touched.
-     * @param x x-position of the touch.
-     * @param y y-position of the touch.
-     */
-    private void sendMotionUp(int touchGeneration,
-            int frame, int node, int x, int y) {
-        WebViewCore.TouchUpData touchUpData = new WebViewCore.TouchUpData();
-        touchUpData.mMoveGeneration = touchGeneration;
-        touchUpData.mFrame = frame;
-        touchUpData.mNode = node;
-        touchUpData.mX = x;
-        touchUpData.mY = y;
-        touchUpData.mNativeLayer = nativeScrollableLayer(
-                x, y, touchUpData.mNativeLayerRect, null);
-        mWebViewCore.sendMessage(EventHub.TOUCH_UP, touchUpData);
-    }
-
-
     private int getScaledMaxXScroll() {
         int width;
         if (mHeightCanMeasure == false) {
@@ -10063,67 +9147,6 @@
         mWebViewCore.sendMessage(eventHubAction, event);
     }
 
-    // return true if the key was handled
-    private boolean navHandledKey(int keyCode, int count, boolean noScroll,
-            long time) {
-        if (mNativeClass == 0) {
-            return false;
-        }
-        mInitialHitTestResult = null;
-        mLastCursorTime = time;
-        mLastCursorBounds = cursorRingBounds();
-        boolean keyHandled
-                = nativeMoveCursor(keyCode, count, noScroll) == false;
-        if (DebugFlags.WEB_VIEW) {
-            Log.v(LOGTAG, "navHandledKey mLastCursorBounds=" + mLastCursorBounds
-                    + " mLastCursorTime=" + mLastCursorTime
-                    + " handled=" + keyHandled);
-        }
-        if (keyHandled == false) {
-            return keyHandled;
-        }
-        Rect contentCursorRingBounds = cursorRingBounds();
-        if (contentCursorRingBounds.isEmpty()) return keyHandled;
-        Rect viewCursorRingBounds = contentToViewRect(contentCursorRingBounds);
-        // set last touch so that context menu related functions will work
-        mLastTouchX = (viewCursorRingBounds.left + viewCursorRingBounds.right) / 2;
-        mLastTouchY = (viewCursorRingBounds.top + viewCursorRingBounds.bottom) / 2;
-        if (mHeightCanMeasure == false) {
-            return keyHandled;
-        }
-        Rect visRect = new Rect();
-        calcOurVisibleRect(visRect);
-        Rect outset = new Rect(visRect);
-        int maxXScroll = visRect.width() / 2;
-        int maxYScroll = visRect.height() / 2;
-        outset.inset(-maxXScroll, -maxYScroll);
-        if (Rect.intersects(outset, viewCursorRingBounds) == false) {
-            return keyHandled;
-        }
-        // FIXME: Necessary because ScrollView/ListView do not scroll left/right
-        int maxH = Math.min(viewCursorRingBounds.right - visRect.right,
-                maxXScroll);
-        if (maxH > 0) {
-            pinScrollBy(maxH, 0, true, 0);
-        } else {
-            maxH = Math.max(viewCursorRingBounds.left - visRect.left,
-                    -maxXScroll);
-            if (maxH < 0) {
-                pinScrollBy(maxH, 0, true, 0);
-            }
-        }
-        if (mLastCursorBounds.isEmpty()) return keyHandled;
-        if (mLastCursorBounds.equals(contentCursorRingBounds)) {
-            return keyHandled;
-        }
-        if (DebugFlags.WEB_VIEW) {
-            Log.v(LOGTAG, "navHandledKey contentCursorRingBounds="
-                    + contentCursorRingBounds);
-        }
-        mWebView.requestRectangleOnScreen(viewCursorRingBounds);
-        return keyHandled;
-    }
-
     /**
      * @return Whether accessibility script has been injected.
      */
@@ -10150,9 +9173,6 @@
      */
     @Deprecated
     public void debugDump() {
-        checkThread();
-        nativeDebugDump();
-        mWebViewCore.sendMessage(EventHub.DUMP_NAVTREE);
     }
 
     /**
@@ -10198,17 +9218,6 @@
         cm.setPrimaryClip(clip);
     }
 
-    /**
-     *  Update our cache with updatedText.
-     *  @param updatedText  The new text to put in our cache.
-     *  @hide
-     */
-    protected void updateCachedTextfield(String updatedText) {
-        // Also place our generation number so that when we look at the cache
-        // we recognize that it is up to date.
-        nativeUpdateCachedTextfield(updatedText, mTextGeneration);
-    }
-
     /*package*/ void autoFillForm(int autoFillQueryId) {
         mWebViewCore.sendMessage(EventHub.AUTOFILL_FORM, autoFillQueryId, /* unused */0);
     }
@@ -10285,23 +9294,10 @@
      * @return true if the focused item is an editable text field.
      */
     boolean focusCandidateIsEditableText() {
-        boolean isEditable = false;
-        // TODO: reverse sDisableNavcache so that its name is positive
-        boolean isNavcacheEnabled = !sDisableNavcache;
-        if (isNavcacheEnabled) {
-            isEditable = nativeFocusCandidateIsEditableText(mNativeClass);
-        } else if (mFocusedNode != null) {
-            isEditable = mFocusedNode.mEditable;
+        if (mFocusedNode != null) {
+            return mFocusedNode.mEditable;
         }
-        return isEditable;
-    }
-
-    // TODO: Remove this
-    Rect cursorRingBounds() {
-        if (sDisableNavcache) {
-            return new Rect();
-        }
-        return nativeGetCursorRingBounds();
+        return false;
     }
 
     // Called via JNI
@@ -10309,25 +9305,7 @@
         mWebView.postInvalidate();
     }
 
-    private native int nativeCacheHitFramePointer();
-    private native boolean  nativeCacheHitIsPlugin();
-    private native Rect nativeCacheHitNodeBounds();
-    private native int nativeCacheHitNodePointer();
-    /* package */ native void nativeClearCursor();
     private native void     nativeCreate(int ptr, String drawableDir, boolean isHighEndGfx);
-    private native int      nativeCursorFramePointer();
-    private native Rect     nativeCursorNodeBounds();
-    private native int nativeCursorNodePointer();
-    private native boolean  nativeCursorIntersects(Rect visibleRect);
-    private native boolean  nativeCursorIsAnchor();
-    private native boolean  nativeCursorIsTextInput();
-    private native Point    nativeCursorPosition();
-    private native String   nativeCursorText();
-    /**
-     * Returns true if the native cursor node says it wants to handle key events
-     * (ala plugins). This can only be called if mNativeClass is non-zero!
-     */
-    private native boolean  nativeCursorWantsKeyEvents();
     private native void     nativeDebugDump();
     private native void     nativeDestroy();
 
@@ -10345,81 +9323,18 @@
             Rect viewRect, RectF visibleRect, float scale, int extras);
     private native void     nativeUpdateDrawGLFunction(Rect rect, Rect viewRect,
             RectF visibleRect, float scale);
-    private native void     nativeExtendSelection(int x, int y);
-    /* package */ native int      nativeFocusCandidateFramePointer();
-    /* package */ native boolean  nativeFocusCandidateHasNextTextfield();
-    /* package */ native boolean  nativeFocusCandidateIsPassword();
-    private native boolean  nativeFocusCandidateIsRtlText();
-    private native boolean  nativeFocusCandidateIsTextInput();
-    private native boolean nativeFocusCandidateIsEditableText(int nativeClass);
-    /* package */ native int      nativeFocusCandidateMaxLength();
-    /* package */ native boolean  nativeFocusCandidateIsAutoComplete();
-    /* package */ native boolean  nativeFocusCandidateIsSpellcheck();
-    /* package */ native String   nativeFocusCandidateName();
-    private native Rect     nativeFocusCandidateNodeBounds();
-    /**
-     * @return A Rect with left, top, right, bottom set to the corresponding
-     * padding values in the focus candidate, if it is a textfield/textarea with
-     * a style.  Otherwise return null.  This is not actually a rectangle; Rect
-     * is being used to pass four integers.
-     */
-    private native Rect     nativeFocusCandidatePaddingRect();
-    /* package */ native int      nativeFocusCandidatePointer();
-    private native String   nativeFocusCandidateText();
-    /* package */ native float    nativeFocusCandidateTextSize();
-    /* package */ native int nativeFocusCandidateLineHeight();
-    /**
-     * Returns an integer corresponding to WebView.cpp::type.
-     * See WebTextView.setType()
-     */
-    private native int      nativeFocusCandidateType();
-    private native int      nativeFocusCandidateLayerId();
-    private native boolean  nativeFocusIsPlugin();
-    private native Rect     nativeFocusNodeBounds();
-    /* package */ native int nativeFocusNodePointer();
-    private native Rect     nativeGetCursorRingBounds();
     private native String   nativeGetSelection();
-    private native boolean  nativeHasCursorNode();
-    private native boolean  nativeHasFocusNode();
-    private native void     nativeHideCursor();
-    private native boolean  nativeHitSelection(int x, int y);
-    private native String   nativeImageURI(int x, int y);
     private native Rect     nativeLayerBounds(int layer);
-    /* package */ native boolean nativeMoveCursorToNextTextInput();
-    // return true if the page has been scrolled
-    private native boolean  nativeMotionUp(int x, int y, int slop);
-    // returns false if it handled the key
-    private native boolean  nativeMoveCursor(int keyCode, int count,
-            boolean noScroll);
-    private native int      nativeMoveGeneration();
-    /**
-     * @return true if the page should get the shift and arrow keys, rather
-     * than select text/navigation.
-     *
-     * If the focus is a plugin, or if the focus and cursor match and are
-     * a contentEditable element, then the page should handle these keys.
-     */
-    private native boolean  nativePageShouldHandleShiftAndArrows();
-    private native boolean  nativePointInNavCache(int x, int y, int slop);
-    private native void     nativeSelectBestAt(Rect rect);
-    private native void     nativeSelectAt(int x, int y);
-    private native void     nativeSetExtendSelection();
-    private native void     nativeSetFindIsUp(boolean isUp);
     private native void     nativeSetHeightCanMeasure(boolean measure);
     private native boolean  nativeSetBaseLayer(int nativeInstance,
             int layer, Region invalRegion,
             boolean showVisualIndicator, boolean isPictureAfterFirstLayout);
     private native int      nativeGetBaseLayer();
-    private native void     nativeShowCursorTimed();
     private native void     nativeReplaceBaseContent(int content);
     private native void     nativeCopyBaseContentToPicture(Picture pict);
     private native boolean  nativeHasContent();
-    private native void     nativeSetSelectionPointer(int nativeInstance,
-            boolean set, float scale, int x, int y);
-    private native boolean  nativeStartSelection(int x, int y);
     private native void     nativeStopGL();
     private native Rect     nativeSubtractLayers(Rect content);
-    private native int      nativeTextGeneration();
     private native void     nativeDiscardAllTextures();
     private native void     nativeTileProfilingStart();
     private native float    nativeTileProfilingStop();
@@ -10428,14 +9343,6 @@
     private native int      nativeTileProfilingNumTilesInFrame(int frame);
     private native int      nativeTileProfilingGetInt(int frame, int tile, String key);
     private native float    nativeTileProfilingGetFloat(int frame, int tile, String key);
-    // Never call this version except by updateCachedTextfield(String) -
-    // we always want to pass in our generation number.
-    private native void     nativeUpdateCachedTextfield(String updatedText,
-            int generation);
-    private native boolean  nativeWordSelection(int x, int y);
-    // return NO_LEFTEDGE means failure.
-    static final int NO_LEFTEDGE = -1;
-    native int nativeGetBlockLeftEdge(int x, int y, float scale);
 
     private native void     nativeUseHardwareAccelSkia(boolean enabled);
 
@@ -10459,7 +9366,6 @@
      */
     private static native void     nativeOnTrimMemory(int level);
     private static native void nativeSetPauseDrawing(int instance, boolean pause);
-    private static native boolean nativeDisableNavcache();
     private static native void nativeSetTextSelection(int instance, int selection);
     private static native int nativeGetHandleLayerId(int instance, int handle,
             Rect cursorLocation);
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index bcfa9e2..65356f5 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -610,15 +610,9 @@
     private native void nativeSetFocusControllerActive(int nativeClass,
             boolean active);
 
-    private native void nativeSaveDocumentState(int nativeClass, int frame);
+    private native void nativeSaveDocumentState(int nativeClass);
 
-    private native void nativeMoveFocus(int nativeClass, int framePtr,
-            int nodePointer);
-    private native void nativeMoveMouse(int nativeClass, int framePtr, int x,
-            int y);
-
-    private native void nativeMoveMouseIfLatest(int nativeClass,
-            int moveGeneration, int framePtr, int x, int y);
+    private native void nativeMoveMouse(int nativeClass, int x, int y);
 
     private native String nativeRetrieveHref(int nativeClass, int x, int y);
     private native String nativeRetrieveAnchorText(int nativeClass,
@@ -632,16 +626,12 @@
             int[] idArray, int[] xArray, int[] yArray, int count,
             int actionIndex, int metaState);
 
-    private native void nativeUpdateFrameCache(int nativeClass);
-
     private native void nativeSetBackgroundColor(int nativeClass, int color);
 
     private native void nativeDumpDomTree(int nativeClass, boolean useFile);
 
     private native void nativeDumpRenderTree(int nativeClass, boolean useFile);
 
-    private native void nativeDumpNavTree(int nativeClass);
-
     private native void nativeSetJsFlags(int nativeClass, String flags);
 
     /**
@@ -799,21 +789,6 @@
         String mHistoryUrl;
     }
 
-    static class CursorData {
-        CursorData() {}
-        CursorData(int frame, int node, int x, int y) {
-            mFrame = frame;
-            mNode = node;
-            mX = x;
-            mY = y;
-        }
-        int mMoveGeneration;
-        int mFrame;
-        int mNode;
-        int mX;
-        int mY;
-    }
-
     static class JSInterfaceData {
         Object mObject;
         String mInterfaceName;
@@ -970,8 +945,8 @@
 
         static final String[] HandlerDebugString = {
             "REVEAL_SELECTION", // 96
-            "REQUEST_LABEL", // 97
-            "UPDATE_FRAME_CACHE_IF_LOADING", // = 98
+            "", // 97
+            "", // = 98
             "SCROLL_TEXT_INPUT", // = 99
             "LOAD_URL", // = 100;
             "STOP_LOADING", // = 101;
@@ -990,7 +965,7 @@
             "REPLACE_TEXT", // = 114;
             "PASS_TO_JS", // = 115;
             "SET_GLOBAL_BOUNDS", // = 116;
-            "UPDATE_CACHE_AND_TEXT_ENTRY", // = 117;
+            "", // = 117;
             "CLICK", // = 118;
             "SET_NETWORK_STATE", // = 119;
             "DOC_HAS_IMAGES", // = 120;
@@ -1008,8 +983,8 @@
             "POST_URL", // = 132;
             "SPLIT_PICTURE_SET", // = 133;
             "CLEAR_CONTENT", // = 134;
-            "SET_MOVE_MOUSE", // = 135;
-            "SET_MOVE_MOUSE_IF_LATEST", // = 136;
+            "", // = 135;
+            "", // = 136;
             "REQUEST_CURSOR_HREF", // = 137;
             "ADD_JS_INTERFACE", // = 138;
             "LOAD_DATA", // = 139;
@@ -1040,8 +1015,6 @@
     public 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;
         static final int LOAD_URL = 100;
         static final int STOP_LOADING = 101;
@@ -1060,7 +1033,6 @@
         static final int REPLACE_TEXT = 114;
         static final int PASS_TO_JS = 115;
         static final int SET_GLOBAL_BOUNDS = 116;
-        static final int UPDATE_CACHE_AND_TEXT_ENTRY = 117;
         static final int CLICK = 118;
         static final int SET_NETWORK_STATE = 119;
         static final int DOC_HAS_IMAGES = 120;
@@ -1070,7 +1042,6 @@
         static final int SINGLE_LISTBOX_CHOICE = 124;
         public static final int MESSAGE_RELAY = 125;
         static final int SET_BACKGROUND_COLOR = 126;
-        static final int SET_MOVE_FOCUS = 127;
         static final int SAVE_DOCUMENT_STATE = 128;
         static final int DELETE_SURROUNDING_TEXT = 129;
 
@@ -1082,7 +1053,6 @@
 
         // UI nav messages
         static final int SET_MOVE_MOUSE = 135;
-        static final int SET_MOVE_MOUSE_IF_LATEST = 136;
         static final int REQUEST_CURSOR_HREF = 137;
         static final int ADD_JS_INTERFACE = 138;
         static final int LOAD_DATA = 139;
@@ -1102,7 +1072,6 @@
         static final int ON_PAUSE = 143;
         static final int ON_RESUME = 144;
         static final int FREE_MEMORY = 145;
-        static final int VALID_NODE_BOUNDS = 146;
 
         // Load and save web archives
         static final int SAVE_WEBARCHIVE = 147;
@@ -1122,7 +1091,6 @@
         // debugging
         static final int DUMP_DOMTREE = 170;
         static final int DUMP_RENDERTREE = 171;
-        static final int DUMP_NAVTREE = 172;
 
         static final int SET_JS_FLAGS = 174;
         static final int CONTENT_INVALIDATE_ALL = 175;
@@ -1201,7 +1169,7 @@
         private EventHub() {}
 
         private static final int FIRST_PACKAGE_MSG_ID = REVEAL_SELECTION;
-        private static final int LAST_PACKAGE_MSG_ID = VALID_NODE_BOUNDS;
+        private static final int LAST_PACKAGE_MSG_ID = REMOVE_JS_INTERFACE;
 
         /**
          * Transfer all messages to the newly created webcore thread handler.
@@ -1270,23 +1238,6 @@
                             nativeRevealSelection(mNativeClass);
                             break;
 
-                        case REQUEST_LABEL:
-                            if (mWebView != null) {
-                                int nodePointer = msg.arg2;
-                                String label = nativeRequestLabel(mNativeClass,
-                                        msg.arg1, nodePointer);
-                                if (label != null && label.length() > 0) {
-                                    Message.obtain(mWebView.mPrivateHandler,
-                                            WebViewClassic.RETURN_LABEL, nodePointer,
-                                            0, label).sendToTarget();
-                                }
-                            }
-                            break;
-
-                        case UPDATE_FRAME_CACHE_IF_LOADING:
-                            nativeUpdateFrameCacheIfLoading(mNativeClass);
-                            break;
-
                         case SCROLL_TEXT_INPUT:
                             float xPercent;
                             if (msg.obj == null) {
@@ -1387,8 +1338,8 @@
                             // note: these are in document coordinates
                             // (inv-zoom)
                             Point pt = (Point) msg.obj;
-                            nativeSetScrollOffset(mNativeClass, msg.arg1,
-                                    msg.arg2 == 1, pt.x, pt.y);
+                            nativeSetScrollOffset(mNativeClass,
+                                    msg.arg1 == 1, pt.x, pt.y);
                             break;
 
                         case SET_GLOBAL_BOUNDS:
@@ -1492,8 +1443,7 @@
                         }
 
                         case SAVE_DOCUMENT_STATE: {
-                            CursorData cDat = (CursorData) msg.obj;
-                            nativeSaveDocumentState(mNativeClass, cDat.mFrame);
+                            nativeSaveDocumentState(mNativeClass);
                             break;
                         }
 
@@ -1568,22 +1518,8 @@
                             mBrowserFrame.documentAsText((Message) msg.obj);
                             break;
 
-                        case SET_MOVE_FOCUS:
-                            CursorData focusData = (CursorData) msg.obj;
-                            nativeMoveFocus(mNativeClass, focusData.mFrame, focusData.mNode);
-                            break;
-
                         case SET_MOVE_MOUSE:
-                            CursorData cursorData = (CursorData) msg.obj;
-                            nativeMoveMouse(mNativeClass,
-                                     cursorData.mFrame, cursorData.mX, cursorData.mY);
-                            break;
-
-                        case SET_MOVE_MOUSE_IF_LATEST:
-                            CursorData cData = (CursorData) msg.obj;
-                            nativeMoveMouseIfLatest(mNativeClass,
-                                    cData.mMoveGeneration,
-                                    cData.mFrame, cData.mX, cData.mY);
+                            nativeMoveMouse(mNativeClass, msg.arg1, msg.arg2);
                             break;
 
                         case REQUEST_CURSOR_HREF: {
@@ -1597,15 +1533,6 @@
                             break;
                         }
 
-                        case UPDATE_CACHE_AND_TEXT_ENTRY:
-                            nativeUpdateFrameCache(mNativeClass);
-                            // FIXME: this should provide a minimal rectangle
-                            if (mWebView != null) {
-                                mWebView.getWebView().postInvalidate();
-                            }
-                            sendUpdateTextEntry();
-                            break;
-
                         case DOC_HAS_IMAGES:
                             Message imageResult = (Message) msg.obj;
                             imageResult.arg1 =
@@ -1661,10 +1588,6 @@
                             nativeDumpRenderTree(mNativeClass, msg.arg1 == 1);
                             break;
 
-                        case DUMP_NAVTREE:
-                            nativeDumpNavTree(mNativeClass);
-                            break;
-
                         case SET_JS_FLAGS:
                             nativeSetJsFlags(mNativeClass, (String)msg.obj);
                             break;
@@ -1711,21 +1634,6 @@
                             nativeProvideVisitedHistory(mNativeClass, (String[])msg.obj);
                             break;
 
-                        case VALID_NODE_BOUNDS: {
-                            MotionUpData motionUpData = (MotionUpData) msg.obj;
-                            if (!nativeValidNodeAndBounds(
-                                    mNativeClass, motionUpData.mFrame,
-                                    motionUpData.mNode, motionUpData.mBounds)) {
-                                nativeUpdateFrameCache(mNativeClass);
-                            }
-                            Message message = mWebView.mPrivateHandler
-                                    .obtainMessage(WebViewClassic.DO_MOTION_UP,
-                                    motionUpData.mX, motionUpData.mY);
-                            mWebView.mPrivateHandler.sendMessageAtFrontOfQueue(
-                                    message);
-                            break;
-                        }
-
                         case HIDE_FULLSCREEN:
                             nativeFullScreenPluginHidden(mNativeClass, msg.arg1);
                             break;
@@ -2123,8 +2031,6 @@
             if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "viewSizeChanged");
             contentDraw();
         }
-        mEventHub.sendMessage(Message.obtain(null,
-                EventHub.UPDATE_CACHE_AND_TEXT_ENTRY));
     }
 
     // Calculate width to be used in webkit window.
@@ -2145,13 +2051,6 @@
         return width;
     }
 
-    private void sendUpdateTextEntry() {
-        if (mWebView != null) {
-            Message.obtain(mWebView.mPrivateHandler,
-                    WebViewClassic.UPDATE_TEXT_ENTRY_MSG_ID).sendToTarget();
-        }
-    }
-
     // Utility method for exceededDatabaseQuota and reachedMaxAppCacheSize
     // callbacks. Computes the sum of database quota for all origins.
     private long getUsedQuota() {
@@ -2454,7 +2353,6 @@
 
     // called by JNI
     private void sendNotifyProgressFinished() {
-        sendUpdateTextEntry();
         contentDraw();
     }
 
@@ -2507,10 +2405,8 @@
         }
 
         // remove the touch highlight when moving to a new page
-        if (WebViewClassic.sDisableNavcache) {
-            mWebView.mPrivateHandler.sendEmptyMessage(
-                    WebViewClassic.HIT_TEST_RESULT);
-        }
+        mWebView.mPrivateHandler.sendEmptyMessage(
+                WebViewClassic.HIT_TEST_RESULT);
 
         // reset the scroll position, the restored offset and scales
         mRestoredX = mRestoredY = 0;
@@ -2862,7 +2758,6 @@
                 findText).sendToTarget();
     }
 
-    private native void nativeUpdateFrameCacheIfLoading(int nativeClass);
     private native void nativeRevealSelection(int nativeClass);
     private native String nativeRequestLabel(int nativeClass, int framePtr,
             int nodePtr);
@@ -2873,7 +2768,7 @@
             float xPercent, int y);
 
     // these must be in document space (i.e. not scaled/zoomed).
-    private native void nativeSetScrollOffset(int nativeClass, int gen,
+    private native void nativeSetScrollOffset(int nativeClass,
             boolean sendScrollEvent, int dx, int dy);
 
     private native void nativeSetGlobalBounds(int nativeClass, int x, int y,
@@ -3068,11 +2963,8 @@
     }
 
     // called by JNI
-    @SuppressWarnings("unused")
     private void selectAt(int x, int y) {
-        if (mWebView != null) {
-            mWebView.mPrivateHandler.obtainMessage(WebViewClassic.SELECT_AT, x, y).sendToTarget();
-        }
+        // TODO: Figure out what to do with this (b/6111818)
     }
 
     private void useMockDeviceOrientation() {
@@ -3107,8 +2999,6 @@
     private native void nativeFreeMemory(int nativeClass);
     private native void nativeFullScreenPluginHidden(int nativeClass, int npp);
     private native void nativePluginSurfaceReady(int nativeClass);
-    private native boolean nativeValidNodeAndBounds(int nativeClass, int frame,
-            int node, Rect bounds);
 
     private native WebKitHitTest nativeHitTest(int nativeClass, int x, int y,
             int slop, boolean moveMouse);
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index e7b049e..2247678 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -643,20 +643,6 @@
         // remove the zoom control after double tap
         dismissZoomPicker();
 
-        /*
-         * If the double tap was on a plugin then either zoom to maximize the
-         * plugin on the screen or scale to overview mode.
-         */
-        Rect pluginBounds = mWebView.getPluginBounds(mAnchorX, mAnchorY);
-        if (pluginBounds != null) {
-            if (mWebView.isRectFitOnScreen(pluginBounds)) {
-                zoomToOverview();
-            } else {
-                mWebView.centerFitRect(pluginBounds);
-            }
-            return;
-        }
-
         final float newTextWrapScale;
         if (settings.getUseFixedViewport()) {
             newTextWrapScale = Math.max(mActualScale, getReadingLevelScale());