diff options
author | Leon Scroggins <scroggo@google.com> | 2011-01-24 15:02:40 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-24 15:02:40 -0800 |
commit | 1ce076ca4ba4164d5a583d26af05c0030f01afe8 (patch) | |
tree | 03f42cb73c7d0bb4d4fab3b6a8939df57330f12b /WebKit/android/jni/WebViewCore.cpp | |
parent | 2efa69dd571da1a0f2cbeaeba29685c8ed412416 (diff) | |
parent | ba01ca1ef2bfe8916fafb72fee4a594a0cb2e302 (diff) | |
download | external_webkit-1ce076ca4ba4164d5a583d26af05c0030f01afe8.zip external_webkit-1ce076ca4ba4164d5a583d26af05c0030f01afe8.tar.gz external_webkit-1ce076ca4ba4164d5a583d26af05c0030f01afe8.tar.bz2 |
Merge "Wait until the focus changes to hide keyboard." into honeycomb
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 84e1da5..52cdfed 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -457,6 +457,7 @@ void WebViewCore::reset(bool fromConstructor) } m_lastFocused = 0; + m_blurringNode = 0; m_lastFocusedBounds = WebCore::IntRect(0,0,0,0); m_focusBoundsChanged = false; m_lastFocusedSelStart = 0; @@ -1432,20 +1433,29 @@ WTF::String WebViewCore::requestLabel(WebCore::Frame* frame, return WTF::String(); } -static bool isContentEditable(WebCore::Node* node) +static bool isContentEditable(const WebCore::Node* node) { if (!node) return false; return node->document()->frame()->selection()->isContentEditable(); } +// Returns true if the node is a textfield, textarea, or contentEditable +static bool isTextInput(const WebCore::Node* node) +{ + if (isContentEditable(node)) + return true; + if (!node) + return false; + WebCore::RenderObject* renderer = node->renderer(); + return renderer && (renderer->isTextField() || renderer->isTextArea()); +} + void WebViewCore::revealSelection() { WebCore::Node* focus = currentFocus(); if (!focus) return; - WebCore::RenderObject* renderer = focus->renderer(); - if ((!renderer || (!renderer->isTextField() && !renderer->isTextArea())) - && !isContentEditable(focus)) + if (!isTextInput(focus)) return; WebCore::Frame* focusedFrame = focus->document()->frame(); if (!focusedFrame->page()->focusController()->isActive()) @@ -3031,8 +3041,7 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node static_cast<RenderTextControl*>(renderer)->setScrollTop(scrollY); else scrollLayer(renderer, &m_mousePos); - if (isContentEditable(nodePtr) || (renderer - && (renderer->isTextArea() || renderer->isTextField()))) { + if (isTextInput(nodePtr)) { // 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; @@ -3121,11 +3130,20 @@ 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; + m_blurringNode = node; +} - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(m_javaGlue->object(env).get(), - m_javaGlue->m_formDidBlur, reinterpret_cast<int>(node)); - checkException(env); +void WebViewCore::focusNodeChanged(const WebCore::Node* newFocus) +{ + if (!m_blurringNode) + return; + if (isTextInput(m_blurringNode) && !isTextInput(newFocus)) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_formDidBlur, reinterpret_cast<int>(m_blurringNode)); + checkException(env); + } + m_blurringNode = 0; } void WebViewCore::addMessageToConsole(const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceID, int msgLevel) { |