From 390c2b5702d131f0875199fdca1c3ba5010d7659 Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Tue, 12 Oct 2010 14:01:13 -0400 Subject: Provide padding + border values for textfields. Bug:3085564 They are used by WebView.java to align the WebTextView's text positioning with the page below. This allows the selection and insertion arrow handlers to line up better with the actual selection on the page. Requires a change in frameworks/base: https://android-git.corp.google.com/g/#change,73565 Change-Id: Ia100286016a780abd5f30e32975f8ad566a6ed74 --- WebKit/android/nav/WebView.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'WebKit/android/nav/WebView.cpp') diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 3dafaff..913c4ba 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1501,17 +1501,32 @@ static jobject nativeFocusCandidateName(JNIEnv *env, jobject obj) return env->NewString((jchar*)name.characters(), name.length()); } +static jobject createJavaRect(JNIEnv* env, int x, int y, int right, int bottom) +{ + jclass rectClass = env->FindClass("android/graphics/Rect"); + jmethodID init = env->GetMethodID(rectClass, "", "(IIII)V"); + jobject rect = env->NewObject(rectClass, init, x, y, right, bottom); + return rect; +} + static jobject nativeFocusCandidateNodeBounds(JNIEnv *env, jobject obj) { const CachedFrame* frame; const CachedNode* node = getFocusCandidate(env, obj, &frame); WebCore::IntRect bounds = node ? node->bounds(frame) : WebCore::IntRect(0, 0, 0, 0); - jclass rectClass = env->FindClass("android/graphics/Rect"); - jmethodID init = env->GetMethodID(rectClass, "", "(IIII)V"); - jobject rect = env->NewObject(rectClass, init, bounds.x(), - bounds.y(), bounds.right(), bounds.bottom()); - return rect; + return createJavaRect(env, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); +} + +static jobject nativeFocusCandidatePaddingRect(JNIEnv *env, jobject obj) +{ + const CachedInput* input = getInputCandidate(env, obj); + if (!input) + return 0; + // Note that the Java Rect is being used to pass four integers, rather than + // being used as an actual rectangle. + return createJavaRect(env, input->paddingLeft(), input->paddingTop(), + input->paddingRight(), input->paddingBottom()); } static jint nativeFocusCandidatePointer(JNIEnv *env, jobject obj) @@ -2064,6 +2079,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFocusCandidateName }, { "nativeFocusCandidateNodeBounds", "()Landroid/graphics/Rect;", (void*) nativeFocusCandidateNodeBounds }, + { "nativeFocusCandidatePaddingRect", "()Landroid/graphics/Rect;", + (void*) nativeFocusCandidatePaddingRect }, { "nativeFocusCandidatePointer", "()I", (void*) nativeFocusCandidatePointer }, { "nativeFocusCandidateText", "()Ljava/lang/String;", -- cgit v1.1