Store InputType information for <input> fields, return SEARCH action for SEARCH <input>

Fixes http://b/issue?id=2299660 and http://b/issue?id=2299650
Also remove isPassword, which is redundant.
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index c9adb53..620e059 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -1097,26 +1097,30 @@
         }
         if (node->hasTagName(WebCore::HTMLNames::inputTag)) {
             HTMLInputElement* input = (HTMLInputElement*) node;
+            HTMLInputElement::InputType inputType = input->inputType();
             if (input->isTextField()) {
                 type = TEXT_INPUT_CACHEDNODETYPE;
                 cachedInput.init();
                 cachedInput.setIsTextField(true);
                 cachedInput.setIsReadOnly(input->readOnly());
                 exported = input->value().threadsafeCopy();
-                cachedInput.setIsPassword(input->inputType() ==
-                    HTMLInputElement::PASSWORD);
                 cachedInput.setMaxLength(input->maxLength());
+                cachedInput.setInputType(inputType);
     // If this does not need to be threadsafe, we can use crossThreadString().
     // See http://trac.webkit.org/changeset/49160.
                 cachedInput.setName(input->name().string().threadsafeCopy());
     // can't detect if this is drawn on top (example: deviant.com login parts)
                 isUnclipped = isTransparent;
-            }
+            } else if (inputType == HTMLInputElement::HIDDEN)
+                continue;
         } else if (node->hasTagName(HTMLNames::textareaTag)) {
             cachedInput.init();
             type = TEXT_INPUT_CACHEDNODETYPE;
             HTMLTextAreaElement* area = static_cast<HTMLTextAreaElement*>(node);
             cachedInput.setIsReadOnly(area->readOnly());
+            // Although technically it is not an HTMLInputElement, and therefore
+            // has no InputType, this one is the most appropriate.
+            cachedInput.setInputType(HTMLInputElement::TEXT);
             exported = area->value().threadsafeCopy();
         } else if (node->hasTagName(HTMLNames::aTag)) {
             const HTMLAnchorElement* anchorNode = 
diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h
index 3b00b52..f4f0e95 100644
--- a/WebKit/android/nav/CachedInput.h
+++ b/WebKit/android/nav/CachedInput.h
@@ -27,6 +27,7 @@
 #define CachedInput_H
 
 #include "CachedDebug.h"
+#include "HTMLInputElement.h"
 #include "PlatformString.h"
 
 namespace android {
@@ -41,13 +42,13 @@
         bzero(this, sizeof(CachedInput));
         mName = WebCore::String();
     }
-    bool isPassword() const { return mIsPassword; }
+    WebCore::HTMLInputElement::InputType inputType() const { return mInputType; }
     bool isReadOnly() const { return mIsReadOnly; }
     bool isRtlText() const { return mIsRtlText; }
     bool isTextField() const { return mIsTextField; }
     int maxLength() const { return mMaxLength; };
     const WebCore::String& name() const { return mName; }
-    void setIsPassword(bool isPassword) { mIsPassword = isPassword; }
+    void setInputType(WebCore::HTMLInputElement::InputType type) { mInputType = type; }
     void setIsReadOnly(bool isReadOnly) { mIsReadOnly = isReadOnly; }
     void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; }
     void setIsTextField(bool isTextField) { mIsTextField = isTextField; }
@@ -59,7 +60,7 @@
     WebCore::String mName;
     int mMaxLength;
     int mTextSize;
-    bool mIsPassword : 1;
+    WebCore::HTMLInputElement::InputType mInputType;
     bool mIsReadOnly : 1;
     bool mIsRtlText : 1;
     bool mIsTextField : 1;
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index 83e2ab6..77fb5b8 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -26,7 +26,9 @@
 #include "CachedPrefix.h"
 #include "android_graphics.h"
 #include "CachedHistory.h"
+#include "CachedInput.h"
 #include "CachedNode.h"
+#include "HTMLInputElement.h"
 #include "SkBitmap.h"
 #include "SkBounder.h"
 #include "SkCanvas.h"
@@ -764,6 +766,10 @@
         // the cursor
         return FAILURE;
     }
+    const CachedInput* textInput = cursorFrame->textInput(cursor);
+    if (!textInput) return FAILURE;
+    if (textInput->inputType() == WebCore::HTMLInputElement::SEARCH)
+        return SEARCH;
     const CachedNode* firstTextfield = nextTextField(0, 0, false);
     if (!firstTextfield) {
         // Error case.  There are no textfields in this tree.
diff --git a/WebKit/android/nav/CachedRoot.h b/WebKit/android/nav/CachedRoot.h
index 435937a..f93927c 100644
--- a/WebKit/android/nav/CachedRoot.h
+++ b/WebKit/android/nav/CachedRoot.h
@@ -44,7 +44,8 @@
         FAILURE = -1,
         NEXT    = 0,
         GO      = 1,
-        DONE    = 2
+        DONE    = 2,
+        SEARCH  = 3
     };
     bool adjustForScroll(BestData* , Direction , WebCore::IntPoint* scrollPtr,
         bool findClosest);
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index f47b7f0..d59fdeb 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -36,6 +36,7 @@
 #include "FindCanvas.h"
 #include "Frame.h"
 #include "GraphicsJNI.h"
+#include "HTMLInputElement.h"
 #include "IntPoint.h"
 #include "IntRect.h"
 #include "Node.h"
@@ -1613,7 +1614,7 @@
 static bool nativeFocusCandidateIsPassword(JNIEnv *env, jobject obj)
 {
     const CachedInput* input = getInputCandidate(env, obj);
-    return input ? input->isPassword() : false;
+    return input && input->inputType() == WebCore::HTMLInputElement::PASSWORD;
 }
 
 static bool nativeFocusCandidateIsRtlText(JNIEnv *env, jobject obj)