diff options
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 29 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 21 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 29 |
3 files changed, 56 insertions, 23 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 51565bb..6fd7b9c 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -2811,7 +2811,7 @@ void WebViewCore::click(WebCore::Frame* frame, WebCore::Node* node, bool fake) { = static_cast<EditorClientAndroid*>( m_mainFrame->editor()->client()); client->setShouldChangeSelectedRange(false); - handleMouseClick(frame, node, fake); + handleMouseClick(frame, node, fake, -1); client->setShouldChangeSelectedRange(true); } } @@ -2890,7 +2890,7 @@ bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint } void WebViewCore::touchUp(int touchGeneration, - WebCore::Frame* frame, WebCore::Node* node, int x, int y) + WebCore::Frame* frame, WebCore::Node* node, int x, int y, int scrollY) { if (touchGeneration == 0) { // m_mousePos should be set in getTouchHighlightRects() @@ -2917,7 +2917,7 @@ void WebViewCore::touchUp(int touchGeneration, } DBG_NAV_LOGD("touchGeneration=%d handleMouseClick frame=%p node=%p" " x=%d y=%d", touchGeneration, frame, node, x, y); - handleMouseClick(frame, node, false); + handleMouseClick(frame, node, false, scrollY); } // Return the RenderLayer for the given RenderObject only if the layer is @@ -2968,7 +2968,7 @@ static void scrollLayer(WebCore::RenderObject* renderer, WebCore::IntPoint* pos) // Common code for both clicking with the trackball and touchUp // Also used when typing into a non-focused textfield to give the textfield focus, // in which case, 'fake' is set to true -bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr, bool fake) +bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr, bool fake, int scrollY) { m_lastClickWasOnTextInput = false; bool valid = framePtr == NULL @@ -3024,18 +3024,19 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node DBG_NAV_LOG("list box"); return true; } - } - if (!valid || !framePtr) - framePtr = m_mainFrame; - if (nodePtr && valid) { - scrollLayer(nodePtr->renderer(), &m_mousePos); - if (isContentEditable(nodePtr) || (nodePtr->renderer() - && (nodePtr->renderer()-> isTextArea() || nodePtr->renderer()->isTextField()))) { + if (scrollY != -1 && renderer && renderer->isTextArea()) + static_cast<RenderTextControl*>(renderer)->setScrollTop(scrollY); + else + scrollLayer(renderer, &m_mousePos); + if (isContentEditable(nodePtr) || (renderer + && (renderer->isTextArea() || 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; } } + if (!valid || !framePtr) + framePtr = m_mainFrame; webFrame->setUserInitiatedAction(true); WebCore::PlatformMouseEvent mouseDown(m_mousePos, m_mousePos, WebCore::LeftButton, WebCore::MouseEventPressed, 1, false, false, false, false, @@ -3832,7 +3833,7 @@ static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jintArra } static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration, - jint frame, jint node, jint x, jint y) + jint frame, jint node, jint x, jint y, jint scrollY) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -3840,7 +3841,7 @@ static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration, WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); viewImpl->touchUp(touchGeneration, - (WebCore::Frame*) frame, (WebCore::Node*) node, x, y); + (WebCore::Frame*) frame, (WebCore::Node*) node, x, y, scrollY); } static jstring RetrieveHref(JNIEnv *env, jobject obj, jint x, jint y) @@ -4256,7 +4257,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) FindAddress }, { "nativeHandleTouchEvent", "(I[I[I[III)Z", (void*) HandleTouchEvent }, - { "nativeTouchUp", "(IIIII)V", + { "nativeTouchUp", "(IIIIII)V", (void*) TouchUp }, { "nativeRetrieveHref", "(II)Ljava/lang/String;", (void*) RetrieveHref }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 161b046..0338104 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -339,9 +339,17 @@ namespace android { /** * Handle motionUp event from the UI thread (called touchUp in the * WebCore thread). + * @param touchGeneration Generation number for touches so we can ignore + * touches when a newer one has been generated. + * @param frame Pointer to Frame containing the node that was touched. + * @param node Pointer to Node that was touched. + * @param x x-position of the touch. + * @param y y-position of the touch. + * @param scrollY Only used for <textarea>s (otherwise -1). Scroll position + * of the <textarea> so the touch point is used properly. */ void touchUp(int touchGeneration, WebCore::Frame* frame, - WebCore::Node* node, int x, int y); + WebCore::Node* node, int x, int y, int scrollY); /** * Sets the index of the label from a popup @@ -638,7 +646,16 @@ namespace android { SkPicture* rebuildPicture(const SkIRect& inval); void rebuildPictureSet(PictureSet* ); void sendNotifyProgressFinished(); - bool handleMouseClick(WebCore::Frame*, WebCore::Node*, bool); + /* + * Handle a mouse click, either from a touch or trackball press. + * @param frame Pointer to the Frame containing the node that was clicked on. + * @param node Pointer to the Node that was clicked on. + * @param fake This is a fake mouse click, used to put a textfield into focus. Do not + * open the IME. + * @param scrollY Used only when the node clicked on is a <textarea> (otherwise use + * -1). Scroll the <textarea> before handling the click. + */ + bool handleMouseClick(WebCore::Frame*, WebCore::Node*, bool fake, int scrollY); WebCore::HTMLAnchorElement* retrieveAnchorElement(int x, int y); WebCore::HTMLElement* retrieveElement(int x, int y, const WebCore::QualifiedName& ); diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 8c7a016..0e84675 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -149,7 +149,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) : m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V"); m_javaGlue.m_sendMoveMouseIfLatest = GetJMethod(env, clazz, "sendMoveMouseIfLatest", "(Z)V"); m_javaGlue.m_sendMoveSelection = GetJMethod(env, clazz, "sendMoveSelection", "(II)V"); - m_javaGlue.m_sendMotionUp = GetJMethod(env, clazz, "sendMotionUp", "(IIIII)V"); + m_javaGlue.m_sendMotionUp = GetJMethod(env, clazz, "sendMotionUp", "(IIIIII)V"); m_javaGlue.m_domChangedFocus = GetJMethod(env, clazz, "domChangedFocus", "()V"); m_javaGlue.m_getScaledMaxXScroll = GetJMethod(env, clazz, "getScaledMaxXScroll", "()I"); m_javaGlue.m_getScaledMaxYScroll = GetJMethod(env, clazz, "getScaledMaxYScroll", "()I"); @@ -964,7 +964,7 @@ bool motionUp(int x, int y, int slop) pageScrolled = true; } sendMotionUp(frame ? (WebCore::Frame*) frame->framePointer() : 0, - 0, x, y); + 0, x, y, -1); viewInvalidate(); return pageScrolled; } @@ -981,9 +981,22 @@ bool motionUp(int x, int y, int slop) if (result->isSyntheticLink()) overrideUrlLoading(result->getExport()); else { + int scrollY = -1; +#if USE(ACCELERATED_COMPOSITING) + if (result->isTextInput()) { + const CachedInput* input = frame->textInput(result); + if (input && input->isTextArea()) { + // Need to find out by how much this was scrolled + SkIRect layerRect, bounds; + int layerId = scrollableLayer(rx, ry, &layerRect, &bounds); + if (layerId != 0) + scrollY = layerRect.fTop; + } + } +#endif // ACCELERATED_COMPOSITING sendMotionUp( (WebCore::Frame*) frame->framePointer(), - (WebCore::Node*) result->nodePointer(), rx, ry); + (WebCore::Node*) result->nodePointer(), rx, ry, scrollY); } if (result->isTextInput() || result->isSelect() || result->isContentEditable()) { @@ -1211,7 +1224,7 @@ void sendMoveSelection(WebCore::Frame* frame, WebCore::Node* node) } void sendMotionUp( - WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y) + WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y, int scrollY) { m_viewImpl->m_touchGeneration = ++m_generation; DBG_NAV_LOGD("m_generation=%d framePtr=%p nodePtr=%p x=%d y=%d", @@ -1219,7 +1232,7 @@ void sendMotionUp( LOG_ASSERT(m_javaGlue.m_obj, "A WebView was not associated with this WebViewNative!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_sendMotionUp, - m_generation, (jint) framePtr, (jint) nodePtr, x, y); + m_generation, (jint) framePtr, (jint) nodePtr, x, y, scrollY); checkException(env); } @@ -2275,8 +2288,10 @@ static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y, LOG_ASSERT(view, "view not set in %s", __FUNCTION__); SkIRect nativeRect, nativeBounds; int id = view->scrollableLayer(x, y, &nativeRect, &nativeBounds); - GraphicsJNI::irect_to_jrect(nativeRect, env, rect); - GraphicsJNI::irect_to_jrect(nativeBounds, env, bounds); + if (rect) + GraphicsJNI::irect_to_jrect(nativeRect, env, rect); + if (bounds) + GraphicsJNI::irect_to_jrect(nativeBounds, env, bounds); return id; } |