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.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 6370021..4d92ce8 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -971,15 +971,38 @@ bool motionUp(int x, int y, int slop)
return pageScrolled;
}
+#if USE(ACCELERATED_COMPOSITING)
+static const LayerAndroid* findScrollableLayer(const LayerAndroid* parent, int x, int y) {
+ SkRect bounds;
+ parent->bounds(&bounds);
+ // Check the parent bounds first; this will clip to within a masking layer's
+ // bounds.
+ if (!bounds.contains(x, y))
+ return 0;
+ // Move the hit test local to parent.
+ x -= bounds.fLeft;
+ y -= bounds.fTop;
+ int count = parent->countChildren();
+ for (int i = 0; i < count; i++) {
+ const LayerAndroid* child = parent->getChild(i);
+ const LayerAndroid* result = findScrollableLayer(child, x, y);
+ if (result)
+ return result;
+ }
+ if (parent->contentIsScrollable())
+ return parent;
+ return 0;
+}
+#endif
+
const LayerAndroid* scrollableLayer(int x, int y)
{
-#if ENABLE(ANDROID_OVERFLOW_SCROLL) && USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING)
const LayerAndroid* layerRoot = compositeRoot();
if (!layerRoot)
return 0;
- const LayerAndroid* result = layerRoot->find(x, y, 0);
- if (result != 0 && result->contentIsScrollable())
- return result;
+ const LayerAndroid* result = findScrollableLayer(layerRoot, x, y);
+ return result;
#endif
return 0;
}
@@ -1269,6 +1292,7 @@ LayerAndroid* compositeRoot() const
return 0;
}
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
static void copyScrollPositionRecursive(const LayerAndroid* from,
LayerAndroid* root)
{
@@ -1277,14 +1301,15 @@ static void copyScrollPositionRecursive(const LayerAndroid* from,
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());
+ const SkPoint& pos = l->getPosition();
+ LayerAndroid* match = root->findById(l->uniqueId());
+ if (match && match->contentIsScrollable())
+ match->setPosition(pos.fX, pos.fY);
}
copyScrollPositionRecursive(l, root);
}
}
+#endif
void setBaseLayer(BaseLayerAndroid* layer, WebCore::IntRect& rect)
{
@@ -1293,10 +1318,12 @@ void setBaseLayer(BaseLayerAndroid* layer, WebCore::IntRect& rect)
m_glWebViewState->setBaseLayer(layer, rect);
#endif
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
if (layer) {
- copyScrollPositionRecursive(compositeRoot(),
- static_cast<LayerAndroid*>(layer->getChild(0)));
+ LayerAndroid* newCompositeRoot = static_cast<LayerAndroid*>(layer->getChild(0));
+ copyScrollPositionRecursive(compositeRoot(), newCompositeRoot);
}
+#endif
delete m_baseLayer;
m_baseLayer = layer;
CachedRoot* root = getFrameCache(DontAllowNewer);