summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2011-02-22 11:06:12 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-02-22 11:06:12 -0800
commit5fc48bced27265c28fa2eb1f6334028100e2e9a4 (patch)
tree44a71a404c29e2274865b26ba2f2f65d9ee179b4 /WebKit/android/jni
parentbc76a7143c7508b3e3ccbe1ea5ec8720046c858d (diff)
parentb0c9a2b4033eca931163e8223d7eaa8889337144 (diff)
downloadexternal_webkit-5fc48bced27265c28fa2eb1f6334028100e2e9a4.zip
external_webkit-5fc48bced27265c28fa2eb1f6334028100e2e9a4.tar.gz
external_webkit-5fc48bced27265c28fa2eb1f6334028100e2e9a4.tar.bz2
Merge "Scroll the RenderLayer during touch events."
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp77
-rw-r--r--WebKit/android/jni/WebViewCore.h5
2 files changed, 35 insertions, 47 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 66c78b5..00e4be7 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -3113,51 +3113,6 @@ void WebViewCore::touchUp(int touchGeneration,
handleMouseClick(frame, node, false);
}
-// Return the RenderLayer for the given RenderObject only if the layer is
-// composited and it contains a scrollable content layer.
-static WebCore::RenderLayer* getScrollingLayerFromRenderer(
- WebCore::RenderObject* renderer)
-{
-#if ENABLE(ANDROID_OVERFLOW_SCROLL)
- if (!renderer)
- return 0;
- WebCore::RenderLayer* layer = renderer->enclosingSelfPaintingLayer();
- if (!layer)
- return 0;
- // Find the layer that actually has overflow scroll in case this renderer is
- // inside a child layer.
- while (layer && !layer->hasOverflowScroll())
- layer = layer->parent();
- return layer;
-#endif
- return 0;
-}
-
-// Scroll the RenderLayer associated with a scrollable div element. This is
-// done so that the node is visible when it is clicked.
-static void scrollLayer(WebCore::RenderObject* renderer, WebCore::IntPoint* pos)
-{
- WebCore::RenderLayer* layer = getScrollingLayerFromRenderer(renderer);
- if (!layer)
- return;
- // The cache uses absolute coordinates when clicking on nodes and it assumes
- // the layer is not scrolled.
- layer->scrollToOffset(0, 0, true, false);
-
- WebCore::IntRect absBounds = renderer->absoluteBoundingBoxRect();
- // Do not include the outline when moving the node's bounds.
- WebCore::IntRect layerBounds = layer->renderer()->absoluteBoundingBoxRect();
-
- // Move the node's bounds into the layer's coordinates.
- absBounds.move(-layerBounds.x(), -layerBounds.y());
-
- // Scroll the layer to the node's position.
- layer->scrollToOffset(absBounds.x(), absBounds.y(), true, true);
-
- // Update the mouse position to the layer offset.
- pos->move(-layer->scrollXOffset(), -layer->scrollYOffset());
-}
-
// 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
@@ -3176,8 +3131,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
DBG_NAV_LOG("area");
return true;
}
-
- scrollLayer(nodePtr->renderer(), &m_mousePos);
}
if (!valid || !framePtr)
framePtr = m_mainFrame;
@@ -3689,6 +3642,27 @@ WebRequestContext* WebViewCore::webRequestContext()
}
#endif
+void WebViewCore::scrollRenderLayer(int layer, const SkRect& rect)
+{
+#if USE(ACCELERATED_COMPOSITING)
+ GraphicsLayerAndroid* root = graphicsRootLayer();
+ if (!root)
+ return;
+
+ LayerAndroid* layerAndroid = root->platformLayer();
+ if (!layerAndroid)
+ return;
+
+ LayerAndroid* target = layerAndroid->findById(layer);
+ if (!target)
+ return;
+
+ RenderLayer* owner = target->owningLayer();
+ if (owner)
+ owner->scrollToOffset(rect.fLeft, rect.fTop, true, false);
+#endif
+}
+
//----------------------------------------------------------------------
// Native JNI methods
//----------------------------------------------------------------------
@@ -4370,6 +4344,13 @@ static void AutoFillForm(JNIEnv* env, jobject obj, jint queryId)
#endif
}
+static void ScrollRenderLayer(JNIEnv* env, jobject obj, jint layer, jobject jRect)
+{
+ SkRect rect;
+ GraphicsJNI::jrect_to_rect(env, jRect, &rect);
+ GET_NATIVE_VIEW(env, obj)->scrollRenderLayer(layer, rect);
+}
+
// ----------------------------------------------------------------------------
/*
@@ -4477,6 +4458,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) GetTouchHighlightRects },
{ "nativeAutoFillForm", "(I)V",
(void*) AutoFillForm },
+ { "nativeScrollLayer", "(ILandroid/graphics/Rect;)V",
+ (void*) ScrollRenderLayer },
};
int registerWebViewCore(JNIEnv* env)
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 411be1c..4ebe848 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -579,6 +579,11 @@ namespace android {
void setWebRequestContextCacheMode(int mode);
WebRequestContext* webRequestContext();
#endif
+
+ // Attempts to scroll the layer to the x,y coordinates of rect. The
+ // layer is the id of the LayerAndroid.
+ void scrollRenderLayer(int layer, const SkRect& rect);
+
// end of shared members
// internal functions