From: Leon Scroggins Date: Thu, 23 Jul 2009 20:03:42 +0000 (-0400) Subject: Improve dragging on WebTextView. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=cff94c91f1bb3dfbb5ca3ca2c454ad8aad0c5af3;p=android-x86%2Fexternal-webkit.git Improve dragging on WebTextView. When the WebTextView scrolls, scroll the corresponding RenderTextControl in webkit. Requires a change in frameworks/base. --- diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 9f457f45c..51293b8dc 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -1517,6 +1517,26 @@ void WebViewCore::passToJs(int generation, const WebCore::String& current, updateTextfield(focus, false, test); } +void WebViewCore::scrollFocusedTextInput(int x, int y) +{ + WebCore::Node* focus = currentFocus(); + if (!focus) { + DBG_NAV_LOG("!focus"); + clearTextEntry(); + return; + } + WebCore::RenderObject* renderer = focus->renderer(); + if (!renderer || (!renderer->isTextField() && !renderer->isTextArea())) { + DBG_NAV_LOGD("renderer==%p || not text", renderer); + clearTextEntry(); + return; + } + WebCore::RenderTextControl* renderText = + static_cast(renderer); + renderText->setScrollLeft(x); + renderText->setScrollTop(y); +} + void WebViewCore::setFocusControllerActive(bool active) { m_mainFrame->page()->focusController()->setActive(active); @@ -2180,6 +2200,15 @@ static void PassToJs(JNIEnv *env, jobject obj, PlatformKeyboardEvent(keyCode, keyValue, 0, down, cap, fn, sym)); } +static void ScrollFocusedTextInput(JNIEnv *env, jobject obj, jint x, jint y) +{ +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); +#endif + WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); + viewImpl->scrollFocusedTextInput(x, y); +} + static void SetFocusControllerActive(JNIEnv *env, jobject obj, jboolean active) { #ifdef ANDROID_INSTRUMENT @@ -2630,7 +2659,9 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { { "nativeMoveMouseIfLatest", "(IIII)V", (void*) MoveMouseIfLatest }, { "passToJs", "(ILjava/lang/String;IIZZZZ)V", - (void*) PassToJs } , + (void*) PassToJs }, + { "nativeScrollFocusedTextInput", "(II)V", + (void*) ScrollFocusedTextInput }, { "nativeSetFocusControllerActive", "(Z)V", (void*) SetFocusControllerActive }, { "nativeSaveDocumentState", "(I)V", diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 66ef470cd..be088306d 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -266,6 +266,10 @@ namespace android { int textGeneration); void passToJs(int generation, const WebCore::String& , const WebCore::PlatformKeyboardEvent& ); + /** + * Scroll the focused textfield to (x, y) in document space + */ + void scrollFocusedTextInput(int x, int y); void setFocusControllerActive(bool active); void saveDocumentState(WebCore::Frame* frame);