summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2010-07-16 12:43:07 -0400
committerPatrick Scott <phanna@android.com>2010-07-22 08:16:26 -0400
commita8d0e5a36718ee59b84a577053458bded49e369a (patch)
tree510917186d198758676037c96296405d0a1b83f1 /WebKit
parent0286594a8b68c879fc5c11deb6f14c4ccadeef2a (diff)
downloadexternal_webkit-a8d0e5a36718ee59b84a577053458bded49e369a.zip
external_webkit-a8d0e5a36718ee59b84a577053458bded49e369a.tar.gz
external_webkit-a8d0e5a36718ee59b84a577053458bded49e369a.tar.bz2
Enable scrollable divs.
Force a composite layer when the style says the content is scrollable. Record the border and background in the main content picture. When the contents of the layer are bigger than the size, record the foreground contents in a separate picture which is clipped by the border and size. When updating the base layer, remember the scroll position of each layer and update the new layer with the same position. Bug: 1566791 Change-Id: If440e4f215db6bda9df32a781d754d1f5a238162
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/nav/WebView.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 5154b42..aad3501 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -920,6 +920,19 @@ bool motionUp(int x, int y, int slop)
return pageScrolled;
}
+const LayerAndroid* scrollableLayer(int x, int y)
+{
+#if ENABLE(ANDROID_OVERFLOW_SCROLL) && USE(ACCELERATED_COMPOSITING)
+ const LayerAndroid* root = compositeRoot();
+ if (!root)
+ return 0;
+ const LayerAndroid* result = root->find(x, y);
+ if (result != 0 && result->contentIsScrollable())
+ return result;
+#endif
+ return 0;
+}
+
int getBlockLeftEdge(int x, int y, float scale)
{
CachedRoot* root = getFrameCache(AllowNewer);
@@ -1200,8 +1213,27 @@ LayerAndroid* compositeRoot() const
return 0;
}
+static void copyScrollPositionRecursive(const LayerAndroid* from,
+ LayerAndroid* root)
+{
+ if (!from || !root)
+ return;
+ for (int i = 0; i < from->countChildren(); i++) {
+ const LayerAndroid* l = from->getChild(i);
+ if (l->contentIsScrollable()) {
+ LayerAndroid* match =
+ const_cast<LayerAndroid*>(root->findById(l->uniqueId()));
+ if (match != 0)
+ match->setScrollPosition(l->scrollPosition());
+ }
+ copyScrollPositionRecursive(l, root);
+ }
+}
+
void setBaseLayer(BaseLayerAndroid* layer)
{
+ copyScrollPositionRecursive(compositeRoot(),
+ static_cast<LayerAndroid*>(layer->getChild(0)));
delete m_baseLayer;
m_baseLayer = layer;
CachedRoot* root = getFrameCache(DontAllowNewer);
@@ -2064,6 +2096,40 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
#endif
}
+static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y)
+{
+ WebView* view = GET_NATIVE_VIEW(env, jwebview);
+ LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ return (int) view->scrollableLayer(x, y);
+}
+
+static bool validLayer(const LayerAndroid* root, const LayerAndroid* layer) {
+ if (root == layer)
+ return true;
+ for (int i = 0; i < root->countChildren(); i++) {
+ const LayerAndroid* l = root->getChild(i);
+ if (validLayer(l, layer))
+ return true;
+ }
+ return false;
+}
+
+static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint pLayer, jint dx,
+ jint dy)
+{
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+ WebView* view = GET_NATIVE_VIEW(env, obj);
+ const LayerAndroid* root = view->compositeRoot();
+ LayerAndroid* layer = (LayerAndroid*) pLayer;
+ if (!validLayer(root, layer)) {
+ return false;
+ }
+ LOG_ASSERT(layer, "layer not set in %s", __FUNCTION__);
+ return layer->scrollBy(dx, dy);
+#endif
+ return false;
+}
+
/*
* JNI registration
*/
@@ -2220,6 +2286,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeWordSelection },
{ "nativeGetBlockLeftEdge", "(IIF)I",
(void*) nativeGetBlockLeftEdge },
+ { "nativeScrollableLayer", "(II)I",
+ (void*) nativeScrollableLayer },
+ { "nativeScrollLayer", "(III)Z",
+ (void*) nativeScrollLayer },
};
int register_webview(JNIEnv* env)