diff options
| -rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 27 | ||||
| -rw-r--r-- | WebKit/android/jni/WebViewCore.h | 1 | ||||
| -rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 22 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedInput.cpp | 1 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedInput.h | 4 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 11 |
6 files changed, 28 insertions, 38 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 7e35229..d121c4c 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -57,6 +57,7 @@ #include "HTMLElement.h" #include "HTMLImageElement.h" #include "HTMLInputElement.h" +#include "HTMLLabelElement.h" #include "HTMLMapElement.h" #include "HTMLNames.h" #include "HTMLOptGroupElement.h" @@ -68,6 +69,7 @@ #include "KeyboardCodes.h" #include "Navigator.h" #include "Node.h" +#include "NodeList.h" #include "Page.h" #include "PageGroup.h" #include "PlatformKeyboardEvent.h" @@ -1215,6 +1217,22 @@ WebCore::String WebViewCore::retrieveAnchorText(WebCore::Frame* frame, WebCore:: return anchor ? anchor->text() : WebCore::String(); } +WebCore::String WebViewCore::requestLabel(WebCore::Frame* frame, + WebCore::Node* node) +{ + if (CacheBuilder::validNode(m_mainFrame, frame, node)) { + RefPtr<WebCore::NodeList> list = node->document()->getElementsByTagName("label"); + unsigned length = list->length(); + for (unsigned i = 0; i < length; i++) { + WebCore::HTMLLabelElement* label = static_cast<WebCore::HTMLLabelElement*>( + list->item(i)); + if (label->correspondingControl() == node) + return label->innerHTML(); + } + } + return WebCore::String(); +} + void WebViewCore::updateCacheOnNodeChange() { gCursorBoundsMutex.lock(); @@ -2353,6 +2371,13 @@ static jstring WebCoreStringToJString(JNIEnv *env, WebCore::String string) return ret; } +static jstring RequestLabel(JNIEnv *env, jobject obj, int framePointer, + int nodePointer) +{ + return WebCoreStringToJString(env, GET_NATIVE_VIEW(env, obj)->requestLabel( + (WebCore::Frame*) framePointer, (WebCore::Node*) nodePointer)); +} + static void UpdateFrameCacheIfLoading(JNIEnv *env, jobject obj) { GET_NATIVE_VIEW(env, obj)->updateFrameCacheIfLoading(); @@ -3016,6 +3041,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { { "nativeResume", "()V", (void*) Resume }, { "nativeFreeMemory", "()V", (void*) FreeMemory }, { "nativeSetJsFlags", "(Ljava/lang/String;)V", (void*) SetJsFlags }, + { "nativeRequestLabel", "(II)Ljava/lang/String;", + (void*) RequestLabel }, { "nativeUpdateFrameCacheIfLoading", "()V", (void*) UpdateFrameCacheIfLoading }, { "nativeProvideVisitedHistory", "([Ljava/lang/String;)V", diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 6535d60..af19371 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -246,6 +246,7 @@ namespace android { WebCore::String retrieveHref(WebCore::Frame* frame, WebCore::Node* node); WebCore::String retrieveAnchorText(WebCore::Frame* frame, WebCore::Node* node); + WebCore::String requestLabel(WebCore::Frame* , WebCore::Node* ); // Create a single picture to represent the drawn DOM (used by navcache) void recordPicture(SkPicture* picture); diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 729296d..c4c25db 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -38,7 +38,6 @@ #include "HTMLAreaElement.h" #include "HTMLImageElement.h" #include "HTMLInputElement.h" -#include "HTMLLabelElement.h" #include "HTMLMapElement.h" #include "HTMLNames.h" #include "HTMLOptionElement.h" @@ -46,7 +45,6 @@ #include "HTMLTextAreaElement.h" #include "InlineTextBox.h" #include "KURL.h" -#include "NodeList.h" #include "PluginView.h" #include "RegisteredEventListener.h" #include "RenderImage.h" @@ -862,23 +860,6 @@ static bool checkForPluginViewThatWantsFocus(RenderObject* renderer) { return false; } -// Code copied from AccessibilityRenderObject.cpp. If/when Webkit makes this -// function public, we can use their version. -static HTMLLabelElement* labelForElement(Element* element) -{ - RefPtr<NodeList> list = element->document()->getElementsByTagName("label"); - unsigned len = list->length(); - for (unsigned i = 0; i < len; i++) { - if (list->item(i)->hasTagName(HTMLNames::labelTag)) { - HTMLLabelElement* label = static_cast<HTMLLabelElement*>(list->item(i)); - if (label->correspondingControl() == element) - return label; - } - } - - return 0; -} - // when new focus is found, push it's parent on a stack // as long as more focii are found with the same (grand) parent, note it // (which only requires retrieving the last parent on the stack) @@ -1126,9 +1107,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, cachedInput.setFormPointer(input->form()); cachedInput.setIsTextField(true); cachedInput.setIsReadOnly(input->readOnly()); - HTMLLabelElement* label = labelForElement(input); - if (label) - cachedInput.setLabel(label->innerHTML()); exported = input->value().threadsafeCopy(); cachedInput.setMaxLength(input->maxLength()); cachedInput.setInputType(inputType); diff --git a/WebKit/android/nav/CachedInput.cpp b/WebKit/android/nav/CachedInput.cpp index b145591..d7b96e3 100644 --- a/WebKit/android/nav/CachedInput.cpp +++ b/WebKit/android/nav/CachedInput.cpp @@ -54,7 +54,6 @@ static void printWebCoreString(const char* label, void CachedInput::Debug::print() const { CachedInput* b = base(); - printWebCoreString("// char* mLabel=\"", b->mLabel); printWebCoreString("// char* mName=\"", b->mName); DUMP_NAV_LOGD("// void* mForm=%p;", b->mForm); DUMP_NAV_LOGD("// int mMaxLength=%d;\n", b->mMaxLength); diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h index a75efe4..f3cf1fe 100644 --- a/WebKit/android/nav/CachedInput.h +++ b/WebKit/android/nav/CachedInput.h @@ -41,14 +41,12 @@ public: void* formPointer() const { return mForm; } void init() { bzero(this, sizeof(CachedInput)); - mLabel = WebCore::String(); mName = WebCore::String(); } WebCore::HTMLInputElement::InputType inputType() const { return mInputType; } bool isReadOnly() const { return mIsReadOnly; } bool isRtlText() const { return mIsRtlText; } bool isTextField() const { return mIsTextField; } - const WebCore::String& label() const { return mLabel; } int maxLength() const { return mMaxLength; }; const WebCore::String& name() const { return mName; } void setFormPointer(void* form) { mForm = form; } @@ -56,14 +54,12 @@ public: void setIsReadOnly(bool isReadOnly) { mIsReadOnly = isReadOnly; } void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; } void setIsTextField(bool isTextField) { mIsTextField = isTextField; } - void setLabel(const WebCore::String& label) { mLabel = label; } void setMaxLength(int maxLength) { mMaxLength = maxLength; } void setName(const WebCore::String& name) { mName = name; } void setTextSize(int textSize) { mTextSize = textSize; } int textSize() const { return mTextSize; } private: void* mForm; - WebCore::String mLabel; WebCore::String mName; int mMaxLength; int mTextSize; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index cd767e2..6ba37ba 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1710,15 +1710,6 @@ static bool nativeFocusCandidateIsTextInput(JNIEnv *env, jobject obj) return node ? node->isTextInput() : false; } -static jobject nativeFocusCandidateLabel(JNIEnv *env, jobject obj) -{ - const CachedInput* input = getInputCandidate(env, obj); - if (!input) - return 0; - const WebCore::String& label = input->label(); - return env->NewString((jchar*)label.characters(), label.length()); -} - static jint nativeFocusCandidateMaxLength(JNIEnv *env, jobject obj) { const CachedInput* input = getInputCandidate(env, obj); @@ -2202,8 +2193,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFocusCandidateIsRtlText }, { "nativeFocusCandidateIsTextInput", "()Z", (void*) nativeFocusCandidateIsTextInput }, - { "nativeFocusCandidateLabel", "()Ljava/lang/String;", - (void*) nativeFocusCandidateLabel }, { "nativeFocusCandidateMaxLength", "()I", (void*) nativeFocusCandidateMaxLength }, { "nativeFocusCandidateName", "()Ljava/lang/String;", |
