summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-03-17 15:55:24 -0400
committerCary Clark <cary@android.com>2010-03-18 08:46:08 -0400
commit8026280044128436d8e89736519a0b32b6540201 (patch)
tree83f95a2c28e8568445730ef40ee1c85e4e18728f /WebKit
parentb6e3318e19370031db4c20159f84a519bf7f63b9 (diff)
downloadexternal_webkit-8026280044128436d8e89736519a0b32b6540201.zip
external_webkit-8026280044128436d8e89736519a0b32b6540201.tar.gz
external_webkit-8026280044128436d8e89736519a0b32b6540201.tar.bz2
get bounds of focused node
companion fix in framework/base Change-Id: I7d9191ea9c95dafac7f7e91a70d02c7d055c6967 http://b/2521087
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/nav/WebView.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 8344cf7..1155ea2 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -1223,6 +1223,14 @@ static const CachedNode* getFocusNode(JNIEnv *env, jobject obj)
return root ? root->currentFocus() : 0;
}
+static const CachedNode* getFocusNode(JNIEnv *env, jobject obj,
+ const CachedFrame** frame)
+{
+ WebView* view = GET_NATIVE_VIEW(env, obj);
+ CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer);
+ return root ? root->currentFocus(frame) : 0;
+}
+
static const CachedInput* getInputCandidate(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
@@ -1481,6 +1489,19 @@ static bool nativeFocusIsPlugin(JNIEnv *env, jobject obj)
return node ? node->isPlugin() : false;
}
+static jobject nativeFocusNodeBounds(JNIEnv *env, jobject obj)
+{
+ const CachedFrame* frame;
+ 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.right(), bounds.bottom());
+ return rect;
+}
+
static jint nativeFocusNodePointer(JNIEnv *env, jobject obj)
{
const CachedNode* node = getFocusNode(env, obj);
@@ -1909,6 +1930,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeFocusCandidateType },
{ "nativeFocusIsPlugin", "()Z",
(void*) nativeFocusIsPlugin },
+ { "nativeFocusNodeBounds", "()Landroid/graphics/Rect;",
+ (void*) nativeFocusNodeBounds },
{ "nativeFocusNodePointer", "()I",
(void*) nativeFocusNodePointer },
{ "nativeGetCursorRingBounds", "()Landroid/graphics/Rect;",