Allow touches to change the selection.

Fixes http://b/issue?id=1650395  Lets touches change the selection
while ignoring changes from trackball events.  When a touch puts
a textfield in focus, tell the WebTextView to set mOkayForFocusNotToMatch.

Requires a change in frameworks/base.
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index d31d936..c574d5a 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -2023,35 +2023,16 @@
             " x=%d y=%d", m_touchGeneration, touchGeneration, x, y);
         return; // short circuit if a newer touch has been generated
     }
+    // This moves m_mousePos to the correct place, and handleMouseClick uses
+    // m_mousePos to determine where the click happens.
     moveMouse(frame, x, y);
     m_lastGeneration = touchGeneration;
     if (frame && CacheBuilder::validNode(m_mainFrame, frame, 0)) {
         frame->loader()->resetMultipleFormSubmissionProtection();
     }
-    // If the click is on an unselected textfield/area we do not want to allow
-    // the click to change the selection, because we will set it ourselves
-    // elsewhere - beginning for textareas, end for textfields
-    bool needToIgnoreChangesToSelectedRange = true;
-    WebCore::Node* focusNode = currentFocus();
-    if (focusNode) {
-        WebCore::RenderObject* renderer = focusNode->renderer();
-        if (renderer && (renderer->isTextField() || renderer->isTextArea())) {
-            // Now check to see if the click is inside the focused textfield
-            if (focusNode->getRect().contains(x, y))
-                needToIgnoreChangesToSelectedRange = false;
-        }
-    }
-    EditorClientAndroid* client = 0;
-    if (needToIgnoreChangesToSelectedRange) {
-        client = static_cast<EditorClientAndroid*>(
-                m_mainFrame->editor()->client());
-        client->setShouldChangeSelectedRange(false);
-    }
     DBG_NAV_LOGD("touchGeneration=%d handleMouseClick frame=%p node=%p"
         " x=%d y=%d", touchGeneration, frame, node, x, y);
     handleMouseClick(frame, node);
-    if (needToIgnoreChangesToSelectedRange)
-        client->setShouldChangeSelectedRange(true);
 }
 
 // Common code for both clicking with the trackball and touchUp
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 4b32516..cc90396 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -106,6 +106,7 @@
     jmethodID   m_getScaledMaxYScroll;
     jmethodID   m_getVisibleRect;
     jmethodID   m_rebuildWebTextView;
+    jmethodID   m_setOkayToNotMatch;
     jmethodID   m_displaySoftKeyboard;
     jmethodID   m_viewInvalidate;
     jmethodID   m_viewInvalidateRect;
@@ -134,6 +135,7 @@
     m_javaGlue.m_getScaledMaxYScroll = GetJMethod(env, clazz, "getScaledMaxYScroll", "()I");
     m_javaGlue.m_getVisibleRect = GetJMethod(env, clazz, "sendOurVisibleRect", "()Landroid/graphics/Rect;");
     m_javaGlue.m_rebuildWebTextView = GetJMethod(env, clazz, "rebuildWebTextView", "()V");
+    m_javaGlue.m_setOkayToNotMatch = GetJMethod(env, clazz, "setOkayNotToMatch", "()V");
     m_javaGlue.m_displaySoftKeyboard = GetJMethod(env, clazz, "displaySoftKeyboard", "(Z)V");
     m_javaGlue.m_viewInvalidate = GetJMethod(env, clazz, "viewInvalidate", "()V");
     m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V");
@@ -835,7 +837,7 @@
 void notifyProgressFinished()
 {
     DBG_NAV_LOGD("cursorIsTextInput=%d", cursorIsTextInput(DontAllowNewer));
-    rebuildWebTextView();
+    rebuildWebTextView(false);
 #if DEBUG_NAV_UI
     if (m_frameCacheUI) {
         const CachedNode* focus = m_frameCacheUI->currentFocus();
@@ -967,7 +969,7 @@
     }
     viewInvalidate();
     if (result->isTextField() || result->isTextArea()) {
-        rebuildWebTextView();
+        rebuildWebTextView(true);
         if (!result->isReadOnly()) {
             displaySoftKeyboard(true);
         }
@@ -1267,7 +1269,7 @@
     return focusNode;
 }
 
-void rebuildWebTextView()
+void rebuildWebTextView(bool needNotMatchFocus)
 {
     JNIEnv* env = JSC::Bindings::getJNIEnv();
     AutoJObject obj = m_javaGlue.object(env);
@@ -1277,6 +1279,10 @@
         return;
     env->CallVoidMethod(obj.get(), m_javaGlue.m_rebuildWebTextView);
     checkException(env);
+    if (needNotMatchFocus) {
+        env->CallVoidMethod(obj.get(), m_javaGlue.m_setOkayToNotMatch);
+        checkException(env);
+    }
 }
 
 void displaySoftKeyboard(bool isTextView)
@@ -1927,6 +1933,7 @@
             static_cast<WebCore::Node*>(next->nodePointer()), pos.x(), pos.y());
     view->scrollRectOnScreen(bounds.x(), bounds.y(), bounds.right(),
             bounds.bottom());
+    view->getWebViewCore()->m_moveGeneration++;
 }
 
 static jint nativeTextFieldAction(JNIEnv *env, jobject obj)