Merge "Turn autofill on by default at compile time and make it a browser setting."
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index d5cadad..2688d69 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -198,6 +198,11 @@
android::WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view())->addMessageToConsole(message, lineNumber, sourceID, msgLevel);
}
+void ChromeClientAndroid::formDidBlur(const WebCore::Node* node)
+{
+ android::WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view())->formDidBlur(node);
+}
+
bool ChromeClientAndroid::canRunBeforeUnloadConfirmPanel() { return true; }
bool ChromeClientAndroid::runBeforeUnloadConfirmPanel(const String& message, Frame* frame) {
String url = frame->document()->documentURI();
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index d25747f..b7d423d 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -65,7 +65,7 @@
virtual void focus();
virtual void unfocus();
-
+ virtual void formDidBlur(const WebCore::Node*);
virtual bool canTakeFocus(FocusDirection);
virtual void takeFocus(FocusDirection);
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 8353b98..619ac10 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -252,6 +252,7 @@
jmethodID m_geolocationPermissionsHidePrompt;
jmethodID m_getDeviceOrientationService;
jmethodID m_addMessageToConsole;
+ jmethodID m_formDidBlur;
jmethodID m_getPluginClass;
jmethodID m_showFullScreenPlugin;
jmethodID m_hideFullScreenPlugin;
@@ -343,6 +344,7 @@
m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V");
m_javaGlue->m_getDeviceOrientationService = GetJMethod(env, clazz, "getDeviceOrientationService", "()Landroid/webkit/DeviceOrientationService;");
m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;I)V");
+ m_javaGlue->m_formDidBlur = GetJMethod(env, clazz, "formDidBlur", "(I)V");
m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;");
m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/ViewManager$ChildView;I)V");
m_javaGlue->m_hideFullScreenPlugin = GetJMethod(env, clazz, "hideFullScreenPlugin", "()V");
@@ -2765,6 +2767,7 @@
// Common code for both clicking with the trackball and touchUp
bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr)
{
+ m_lastClickWasOnTextInput = false;
bool valid = framePtr == NULL
|| CacheBuilder::validNode(m_mainFrame, framePtr, nodePtr);
WebFrame* webFrame = WebFrame::getWebFrame(m_mainFrame);
@@ -2821,8 +2824,15 @@
}
if (!valid || !framePtr)
framePtr = m_mainFrame;
- if (nodePtr && valid)
+ if (nodePtr && valid) {
scrollLayer(nodePtr->renderer(), &m_mousePos);
+ if (nodePtr->isContentEditable() || (nodePtr->renderer()
+ && (nodePtr->renderer()-> isTextArea() || nodePtr->renderer()->isTextField()))) {
+ // The user clicked on a text input field. If this causes a blur event
+ // on a different text input, do not hide the keyboard in formDidBlur
+ m_lastClickWasOnTextInput = true;
+ }
+ }
webFrame->setUserInitiatedAction(true);
WebCore::PlatformMouseEvent mouseDown(m_mousePos, m_mousePos, WebCore::LeftButton,
WebCore::MouseEventPressed, 1, false, false, false, false,
@@ -2835,6 +2845,8 @@
bool handled = framePtr->eventHandler()->handleMouseReleaseEvent(mouseUp);
webFrame->setUserInitiatedAction(false);
+ m_lastClickWasOnTextInput = false;
+
// If the user clicked on a textfield, make the focusController active
// so we show the blinking cursor.
WebCore::Node* focusNode = currentFocus();
@@ -2890,6 +2902,18 @@
}
}
+void WebViewCore::formDidBlur(const WebCore::Node* node)
+{
+ // This blur is the result of clicking on a different input. Do not hide
+ // the keyboard, since it will just be opened again.
+ if (m_lastClickWasOnTextInput) return;
+
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(),
+ m_javaGlue->m_formDidBlur, reinterpret_cast<int>(node));
+ checkException(env);
+}
+
void WebViewCore::addMessageToConsole(const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceID, int msgLevel) {
JNIEnv* env = JSC::Bindings::getJNIEnv();
jstring jMessageStr = env->NewString((unsigned short *)message.characters(), message.length());
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 0078fd9..f898406 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -126,6 +126,13 @@
// Followings are called from native WebCore to Java
/**
+ * Notification that a form was blurred. Pass a message to hide the
+ * keyboard if it was showing for that Node.
+ * @param Node The Node that blurred.
+ */
+ void formDidBlur(const WebCore::Node*);
+
+ /**
* Scroll to an absolute position.
* @param x The x coordinate.
* @param y The y coordinate.
@@ -540,6 +547,7 @@
WebCoreReply* m_popupReply;
WebCore::Node* m_lastFocused;
WebCore::IntRect m_lastFocusedBounds;
+ bool m_lastClickWasOnTextInput;
int m_lastFocusedSelStart;
int m_lastFocusedSelEnd;
PictureSet m_content; // the set of pictures to draw