summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav/WebView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/nav/WebView.cpp')
-rw-r--r--WebKit/android/nav/WebView.cpp52
1 files changed, 42 insertions, 10 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 4b0f21d..a7a48cb 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -113,6 +113,7 @@ struct JavaGlue {
jmethodID m_sendMoveFocus;
jmethodID m_sendMoveMouse;
jmethodID m_sendMoveMouseIfLatest;
+ jmethodID m_sendMoveSelection;
jmethodID m_sendMotionUp;
jmethodID m_domChangedFocus;
jmethodID m_getScaledMaxXScroll;
@@ -147,6 +148,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
m_javaGlue.m_sendMoveFocus = GetJMethod(env, clazz, "sendMoveFocus", "(II)V");
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_domChangedFocus = GetJMethod(env, clazz, "domChangedFocus", "()V");
m_javaGlue.m_getScaledMaxXScroll = GetJMethod(env, clazz, "getScaledMaxXScroll", "()I");
@@ -841,6 +843,8 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll)
bool disableFocusController = cachedNode != root->currentFocus()
&& cachedNode->wantsKeyEvents();
sendMoveMouseIfLatest(disableFocusController);
+ sendMoveSelection((WebCore::Frame*) cachedFrame->framePointer(),
+ (WebCore::Node*) cachedNode->nodePointer());
} else {
int docHeight = root->documentHeight();
int docWidth = root->documentWidth();
@@ -899,6 +903,8 @@ void selectBestAt(const WebCore::IntRect& rect)
const CachedFrame* frame;
int rx, ry;
CachedRoot* root = getFrameCache(AllowNewer);
+ if (!root)
+ return;
const CachedNode* node = findAt(root, rect, &frame, &rx, &ry);
if (!node) {
@@ -917,6 +923,8 @@ void selectBestAt(const WebCore::IntRect& rect)
const_cast<CachedNode*>(node));
}
sendMoveMouseIfLatest(false);
+ sendMoveSelection((WebCore::Frame*) frame->framePointer(),
+ (WebCore::Node*) node->nodePointer());
}
const CachedNode* m_cacheHitNode;
@@ -984,7 +992,8 @@ bool motionUp(int x, int y, int slop)
}
#if USE(ACCELERATED_COMPOSITING)
-static const ScrollableLayerAndroid* findScrollableLayer(const LayerAndroid* parent, int x, int y) {
+static const ScrollableLayerAndroid* findScrollableLayer(
+ const LayerAndroid* parent, int x, int y, SkIRect* foundBounds) {
SkRect bounds;
parent->bounds(&bounds);
// Check the parent bounds first; this will clip to within a masking layer's
@@ -997,23 +1006,35 @@ static const ScrollableLayerAndroid* findScrollableLayer(const LayerAndroid* par
int count = parent->countChildren();
for (int i = 0; i < count; i++) {
const LayerAndroid* child = parent->getChild(i);
- const ScrollableLayerAndroid* result = findScrollableLayer(child, x, y);
- if (result)
+ const ScrollableLayerAndroid* result = findScrollableLayer(child, x, y,
+ foundBounds);
+ if (result) {
+ foundBounds->offset(bounds.fLeft, bounds.fTop);
+ if (parent->masksToBounds()) {
+ if (bounds.width() < foundBounds->width())
+ foundBounds->fRight = foundBounds->fLeft + bounds.width();
+ if (bounds.height() < foundBounds->height())
+ foundBounds->fBottom = foundBounds->fTop + bounds.height();
+ }
return result;
+ }
}
- if (parent->contentIsScrollable())
+ if (parent->contentIsScrollable()) {
+ foundBounds->set(0, 0, bounds.width(), bounds.height());
return static_cast<const ScrollableLayerAndroid*>(parent);
+ }
return 0;
}
#endif
-int scrollableLayer(int x, int y, SkIRect* layerRect)
+int scrollableLayer(int x, int y, SkIRect* layerRect, SkIRect* bounds)
{
#if USE(ACCELERATED_COMPOSITING)
const LayerAndroid* layerRoot = compositeRoot();
if (!layerRoot)
return 0;
- const ScrollableLayerAndroid* result = findScrollableLayer(layerRoot, x, y);
+ const ScrollableLayerAndroid* result = findScrollableLayer(layerRoot, x, y,
+ bounds);
if (result) {
result->getScrollRect(layerRect);
return result->uniqueId();
@@ -1178,6 +1199,15 @@ void sendMoveMouseIfLatest(bool disableFocusController)
checkException(env);
}
+void sendMoveSelection(WebCore::Frame* frame, WebCore::Node* node)
+{
+ DBG_NAV_LOGD("framePtr=%p nodePtr=%p x=%d y=%d", frame, node);
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue.object(env).get(),
+ m_javaGlue.m_sendMoveSelection, (jint) frame, (jint) node);
+ checkException(env);
+}
+
void sendMotionUp(
WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y)
{
@@ -2238,13 +2268,15 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
#endif
}
-static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y, jobject rect)
+static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y,
+ jobject rect, jobject bounds)
{
WebView* view = GET_NATIVE_VIEW(env, jwebview);
LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
- SkIRect nativeRect;
- int id = view->scrollableLayer(x, y, &nativeRect);
+ 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);
return id;
}
@@ -2432,7 +2464,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeWordSelection },
{ "nativeGetBlockLeftEdge", "(IIF)I",
(void*) nativeGetBlockLeftEdge },
- { "nativeScrollableLayer", "(IILandroid/graphics/Rect;)I",
+ { "nativeScrollableLayer", "(IILandroid/graphics/Rect;Landroid/graphics/Rect;)I",
(void*) nativeScrollableLayer },
{ "nativeScrollLayer", "(III)Z",
(void*) nativeScrollLayer },