diff options
author | George Mount <mount@google.com> | 2012-02-28 13:17:34 -0800 |
---|---|---|
committer | George Mount <mount@google.com> | 2012-02-28 15:25:05 -0800 |
commit | 51a13477370a2da7ad6ed5015762a4928543ecdc (patch) | |
tree | 4ad2469f98a641586b2d6329e554f154f69405f3 /Source/WebKit | |
parent | 5015ffe477809860e6a9e05779afb1855aa994f2 (diff) | |
download | external_webkit-51a13477370a2da7ad6ed5015762a4928543ecdc.zip external_webkit-51a13477370a2da7ad6ed5015762a4928543ecdc.tar.gz external_webkit-51a13477370a2da7ad6ed5015762a4928543ecdc.tar.bz2 |
Add support for maxlength text fields to WebViewInputConnection.
Bug 6083776
Sends the maximum length from WebKit to WebViewInputConnection
so that it can limit the number of characters entered and remain
in sync with WebKit.
Framework Change: I135871db7809e8dc28a3ad8d3aa852976a274555
Change-Id: Ie02f82a3f5b3527c378938d93bac2dece802af26
Diffstat (limited to 'Source/WebKit')
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 15 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 31e8506..e60a71a 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -507,7 +507,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m #endif m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(ILjava/lang/String;)V"); m_javaGlue->m_selectAt = GetJMethod(env, clazz, "selectAt", "(II)V"); - m_javaGlue->m_initEditField = GetJMethod(env, clazz, "initEditField", "(ILjava/lang/String;IZZLjava/lang/String;III)V"); + m_javaGlue->m_initEditField = GetJMethod(env, clazz, "initEditField", "(ILjava/lang/String;IZZLjava/lang/String;IIII)V"); m_javaGlue->m_updateMatchCount = GetJMethod(env, clazz, "updateMatchCount", "(IILjava/lang/String;)V"); env->DeleteLocalRef(clazz); @@ -3442,6 +3442,16 @@ WebViewCore::InputType WebViewCore::getInputType(Node* node) return WebViewCore::NONE; } +int WebViewCore::getMaxLength(Node* node) +{ + int maxLength = -1; + if (node->hasTagName(WebCore::HTMLNames::inputTag)) { + HTMLInputElement* htmlInput = static_cast<HTMLInputElement*>(node); + maxLength = htmlInput->maxLength(); + } + return maxLength; +} + bool WebViewCore::isSpellCheckEnabled(Node* node) { bool isEnabled = true; @@ -3471,6 +3481,7 @@ void WebViewCore::initEditField(Node* node) Node* nextFocus = document->nextFocusableNode(node, tabEvent.get()); bool isNextText = isTextInput(nextFocus); bool spellCheckEnabled = isSpellCheckEnabled(node); + int maxLength = getMaxLength(node); String label = requestLabel(document->frame(), node); jstring fieldText = wtfStringToJstring(env, text, true); jstring labelText = wtfStringToJstring(env, text, false); @@ -3478,7 +3489,7 @@ void WebViewCore::initEditField(Node* node) env->CallVoidMethod(javaObject.get(), m_javaGlue->m_initEditField, reinterpret_cast<int>(node), fieldText, inputType, spellCheckEnabled, isNextText, labelText, start, end, - reinterpret_cast<int>(selectText)); + reinterpret_cast<int>(selectText), maxLength); checkException(env); } diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index bf7c36b..f6d03fd 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -729,6 +729,7 @@ namespace android { VisiblePosition visiblePositionForContentPoint(const IntPoint& point); void selectWordAroundPosition(Frame* frame, VisiblePosition pos); SelectText* createSelectText(const VisibleSelection&); + static int getMaxLength(Node* node); // called from constructor, to add this to a global list static void addInstance(WebViewCore*); |