diff options
author | Chris Craik <ccraik@google.com> | 2011-07-25 14:55:39 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2011-07-25 14:55:39 -0700 |
commit | 040d9e4815004690561231442e069cc67cba600f (patch) | |
tree | 9d0a350dc67bcedf10362fc38ce68ed622cc188a /Source/WebKit | |
parent | 47bd03b6265feaa5a369f177e630c6dd16539abc (diff) | |
download | external_webkit-040d9e4815004690561231442e069cc67cba600f.zip external_webkit-040d9e4815004690561231442e069cc67cba600f.tar.gz external_webkit-040d9e4815004690561231442e069cc67cba600f.tar.bz2 |
Draw WebTextView inset in the textfield/area's border
bug:5008210
Also reduced some duplication of code for returning java rects.
Change-Id: I614e0cdaea7a30dc0b647b8290a8d66464c0b87c
Diffstat (limited to 'Source/WebKit')
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 7057a54..6a95d33 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -1587,6 +1587,15 @@ class GLDrawFunctor : Functor { jint extras; }; +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, "<init>", "(IIII)V"); + jobject rect = env->NewObject(rectClass, init, x, y, right, bottom); + env->DeleteLocalRef(rectClass); + return rect; +} + /* * Native JNI methods */ @@ -1600,12 +1609,8 @@ static jobject nativeCacheHitNodeBounds(JNIEnv *env, jobject obj) { WebCore::IntRect bounds = GET_NATIVE_VIEW(env, obj) ->m_cacheHitNode->originalAbsoluteBounds(); - jclass rectClass = env->FindClass("android/graphics/Rect"); - jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); - jobject rect = env->NewObject(rectClass, init, bounds.x(), - bounds.y(), bounds.maxX(), bounds.maxY()); - env->DeleteLocalRef(rectClass); - return rect; + return createJavaRect(env, bounds.x(), bounds.y(), + bounds.maxX(), bounds.maxY()); } static int nativeCacheHitNodePointer(JNIEnv *env, jobject obj) @@ -1735,12 +1740,8 @@ static jobject nativeCursorNodeBounds(JNIEnv *env, jobject obj) const CachedNode* node = getCursorNode(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, "<init>", "(IIII)V"); - jobject rect = env->NewObject(rectClass, init, bounds.x(), - bounds.y(), bounds.maxX(), bounds.maxY()); - env->DeleteLocalRef(rectClass); - return rect; + return createJavaRect(env, bounds.x(), bounds.y(), + bounds.maxX(), bounds.maxY()); } static jint nativeCursorNodePointer(JNIEnv *env, jobject obj) @@ -1966,22 +1967,16 @@ static jobject nativeFocusCandidateName(JNIEnv *env, jobject obj) return wtfStringToJstring(env, name); } -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, "<init>", "(IIII)V"); - jobject rect = env->NewObject(rectClass, init, x, y, right, bottom); - env->DeleteLocalRef(rectClass); - 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); - return createJavaRect(env, bounds.x(), bounds.y(), bounds.maxX(), bounds.maxY()); + // Inset the rect by 1 unit, so that the focus candidate's border can still + // be seen behind it. + return createJavaRect(env, bounds.x() + 1, bounds.y() + 1, + bounds.maxX() - 1, bounds.maxY() - 1); } static jobject nativeFocusCandidatePaddingRect(JNIEnv *env, jobject obj) @@ -2046,12 +2041,8 @@ static jobject nativeFocusNodeBounds(JNIEnv *env, jobject obj) const CachedNode* node = getFocusNode(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, "<init>", "(IIII)V"); - jobject rect = env->NewObject(rectClass, init, bounds.x(), - bounds.y(), bounds.maxX(), bounds.maxY()); - env->DeleteLocalRef(rectClass); - return rect; + return createJavaRect(env, bounds.x(), bounds.y(), + bounds.maxX(), bounds.maxY()); } static jint nativeFocusNodePointer(JNIEnv *env, jobject obj) |