summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2010-11-04 10:11:34 -0400
committerPatrick Scott <phanna@android.com>2010-12-03 09:15:36 -0500
commit82f247bdbb98dd80c44209d87692c650c3704617 (patch)
treed8e9cb36f483b1e50d099563759d868aa6fef175 /WebKit/android/nav
parent50114931eb31b3ee57480bf3d0068891aa62571f (diff)
downloadexternal_webkit-82f247bdbb98dd80c44209d87692c650c3704617.zip
external_webkit-82f247bdbb98dd80c44209d87692c650c3704617.tar.gz
external_webkit-82f247bdbb98dd80c44209d87692c650c3704617.tar.bz2
Rewrite scrollable layers using multiple layers.
Remove PlatformBridge::updateLayers and instead call layersDraw from ChromeClientAndroid during a requested sync. Instead of LayerAndroid having knowledge of scrolling pictures, use multiple layers (background, mask, foreground). Update navigation to use the new structure. Always record nodes in absolute, unscrolled coordinates. Do not track layers unless the node has a composited layer and a last child. Check for composited parents when adding to tracked layers as well. TODO: * developer.android.com doesn't completely work with navigation due to some nodes being clipped out. * BaseLayerAndroid needs to be able to operate with a matrix other than identity. * nested fixed position elements do not draw correctly. * nested overflow layers haven't been tested. Change-Id: I0e2bd37612341e8884d68153ab36194cb2dc1eeb
Diffstat (limited to 'WebKit/android/nav')
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp77
-rw-r--r--WebKit/android/nav/CacheBuilder.h2
-rw-r--r--WebKit/android/nav/CachedFrame.cpp16
-rw-r--r--WebKit/android/nav/CachedLayer.cpp85
-rw-r--r--WebKit/android/nav/CachedLayer.h12
-rw-r--r--WebKit/android/nav/WebView.cpp47
6 files changed, 106 insertions, 133 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 449b9e2..f0333f2 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -93,6 +93,12 @@ Frame* CacheBuilder::FrameAnd(const CacheBuilder* cacheBuilder) {
return loader->getFrame();
}
+CacheBuilder::LayerTracker::~LayerTracker() {
+ if (mRenderLayer)
+ // Restore the scroll position of the layer. Does not affect layers
+ // without overflow scroll as the layer will not be scrolled.
+ mRenderLayer->scrollToOffset(mScroll.x(), mScroll.y(), false, false);
+}
#if DUMP_NAV_CACHE
@@ -919,8 +925,7 @@ static bool checkForPluginViewThatWantsFocus(RenderObject* renderer) {
}
#if USE(ACCELERATED_COMPOSITING)
-static void AddLayer(CachedFrame* frame, size_t index, const IntPoint& location,
- const IntPoint& scroll, int id)
+static void AddLayer(CachedFrame* frame, size_t index, const IntPoint& location, int id)
{
DBG_NAV_LOGD("frame=%p index=%d loc=(%d,%d) id=%d", frame, index,
location.x(), location.y(), id);
@@ -928,7 +933,6 @@ static void AddLayer(CachedFrame* frame, size_t index, const IntPoint& location,
cachedLayer.reset();
cachedLayer.setCachedNodeIndex(index);
cachedLayer.setOffset(location);
- cachedLayer.setScrollOffset(scroll);
cachedLayer.setUniqueId(id);
frame->add(cachedLayer);
}
@@ -1099,7 +1103,9 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
hasCursorRing = style->tapHighlightColor().alpha() > 0;
#endif
#if USE(ACCELERATED_COMPOSITING)
- if (nodeRenderer->hasLayer()) {
+ // If this renderer has its own layer and the layer is composited,
+ // start tracking it.
+ if (lastChild && nodeRenderer->hasLayer() && toRenderBox(nodeRenderer)->layer()->backing()) {
TrackLayer(layerTracker, nodeRenderer, lastChild,
globalOffsetX, globalOffsetY);
size_t size = tracker.size();
@@ -1108,11 +1114,9 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
int id = layer->uniqueId();
const RenderLayer* renderLayer =
layerTracker.last().mRenderLayer;
- IntPoint loc(SkScalarRound(layer->getPosition().fX),
- SkScalarRound(layer->getPosition().fY));
+ // Global location
+ IntPoint loc = renderLayer->absoluteBoundingBox().location();
loc.move(globalOffsetX, globalOffsetY);
- IntPoint scroll(renderLayer->scrollXOffset(),
- renderLayer->scrollYOffset());
// if this is a child of a CachedNode, add a layer
size_t limit = cachedFrame->layerCount() == 0 ? 0 :
cachedFrame->lastLayer()->cachedNodeIndex();
@@ -1128,7 +1132,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
CachedNode* trackedNode = cachedFrame->getIndex(index);
trackedNode->setIsInLayer(true);
trackedNode->setIsUnclipped(true);
- AddLayer(cachedFrame, index, loc, scroll, id);
+ AddLayer(cachedFrame, index, loc, id);
}
}
}
@@ -1174,11 +1178,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
absBounds.move(globalOffsetX, globalOffsetY);
hasClip = nodeRenderer->hasOverflowClip();
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
- if (nodeRenderer->hasLayer()) {
- const LayerAndroid* layer = layerTracker.last().mLayer;
- if (layer && layer->contentIsScrollable())
- hasClip = false;
- }
+ if (nodeRenderer->enclosingLayer() && nodeRenderer->enclosingLayer()->hasOverflowParent())
+ hasClip = false;
#endif
if (node->hasTagName(HTMLNames::canvasTag))
@@ -1399,22 +1400,23 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
}
bool isInLayer = false;
#if USE(ACCELERATED_COMPOSITING)
+ // If this renderer has a composited parent layer (including itself),
+ // add the node to the cached layer.
// FIXME: does not work for area rects
- LayerAndroid* layer = layerTracker.last().mLayer;
- if (layer) {
- const IntRect& layerClip = layerTracker.last().mBounds;
- const RenderLayer* renderLayer = layerTracker.last().mRenderLayer;
- if (!layer->contentIsScrollable() && !layerClip.isEmpty() &&
- !cachedNode.clip(layerClip)) {
- DBG_NAV_LOGD("skipped on layer clip %d", cacheIndex);
- continue; // skip this node if outside of the clip
+ RenderLayer* enclosingLayer = nodeRenderer->enclosingLayer();
+ if (enclosingLayer && enclosingLayer->enclosingCompositingLayer()) {
+ LayerAndroid* layer = layerTracker.last().mLayer;
+ if (layer) {
+ const IntRect& layerClip = layerTracker.last().mBounds;
+ if (!layerClip.isEmpty() && !cachedNode.clip(layerClip)) {
+ DBG_NAV_LOGD("skipped on layer clip %d", cacheIndex);
+ continue; // skip this node if outside of the clip
+ }
+ isInLayer = true;
+ isUnclipped = true; // assume that layers do not have occluded nodes
+ AddLayer(cachedFrame, cachedFrame->size(), layerClip.location(),
+ layer->uniqueId());
}
- isInLayer = true;
- isUnclipped = true; // assume that layers do not have occluded nodes
- IntPoint scroll(renderLayer->scrollXOffset(),
- renderLayer->scrollYOffset());
- AddLayer(cachedFrame, cachedFrame->size(), layerClip.location(),
- scroll, layer->uniqueId());
}
#endif
cachedNode.setNavableRects();
@@ -2919,7 +2921,7 @@ bool CacheBuilder::setData(CachedFrame* cachedFrame)
void CacheBuilder::TrackLayer(WTF::Vector<LayerTracker>& layerTracker,
RenderObject* nodeRenderer, Node* lastChild, int offsetX, int offsetY)
{
- RenderLayer* layer = toRenderBoxModelObject(nodeRenderer)->layer();
+ RenderLayer* layer = nodeRenderer->enclosingLayer();
RenderLayerBacking* back = layer->backing();
if (!back)
return;
@@ -2930,13 +2932,28 @@ void CacheBuilder::TrackLayer(WTF::Vector<LayerTracker>& layerTracker,
LayerAndroid* aLayer = grLayer->contentLayer();
if (!aLayer)
return;
+ IntPoint scroll(layer->scrollXOffset(), layer->scrollYOffset());
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+ // If this is an overflow element, track the content layer.
+ if (layer->hasOverflowParent() && aLayer->getChild(0))
+ aLayer = aLayer->getChild(0)->getChild(0);
+ if (!aLayer)
+ return;
+ layer->scrollToOffset(0, 0, false, false);
+#endif
layerTracker.grow(layerTracker.size() + 1);
LayerTracker& indexTracker = layerTracker.last();
indexTracker.mLayer = aLayer;
indexTracker.mRenderLayer = layer;
indexTracker.mBounds = IntRect(FloatRect(aLayer->bounds()));
+ // Use the absolute location of the layer as the bounds location. This
+ // provides the original offset of nodes in the layer so that we can
+ // translate nodes between their original location and the layer's new
+ // location.
+ indexTracker.mBounds.setLocation(layer->absoluteBoundingBox().location());
indexTracker.mBounds.move(offsetX, offsetY);
- indexTracker.mLastChild = lastChild ? OneAfter(lastChild) : 0;
+ indexTracker.mScroll = scroll;
+ indexTracker.mLastChild = OneAfter(lastChild);
DBG_NAV_LOGD("layer=%p [%d] bounds=(%d,%d,w=%d,h=%d)", aLayer,
aLayer->uniqueId(), indexTracker.mBounds.x(), indexTracker.mBounds.y(),
indexTracker.mBounds.width(), indexTracker.mBounds.height());
diff --git a/WebKit/android/nav/CacheBuilder.h b/WebKit/android/nav/CacheBuilder.h
index 9832865..d229df0 100644
--- a/WebKit/android/nav/CacheBuilder.h
+++ b/WebKit/android/nav/CacheBuilder.h
@@ -202,6 +202,8 @@ private:
LayerAndroid* mLayer;
RenderLayer* mRenderLayer;
IntRect mBounds;
+ IntPoint mScroll;
+ ~LayerTracker();
};
struct TabIndexTracker : Tracker {
int mTabIndex;
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index 4f9ec06..55a7c0e 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -53,12 +53,8 @@ WebCore::IntRect CachedFrame::adjustBounds(const CachedNode* node,
const CachedLayer* cachedLayer = layer(node);
const WebCore::LayerAndroid* rootLayer = mRoot->rootLayer();
const LayerAndroid* aLayer = cachedLayer->layer(rootLayer);
- if (aLayer) {
- IntRect rrect = cachedLayer->adjustBounds(rootLayer, rect);
- if (!aLayer->contentIsScrollable())
- rrect.move(-mViewBounds.x(), -mViewBounds.y());
- return rrect;
- }
+ if (aLayer)
+ return cachedLayer->adjustBounds(rootLayer, rect);
#endif
return rect;
}
@@ -74,12 +70,8 @@ WebCore::IntRect CachedFrame::unadjustBounds(const CachedNode* node,
const CachedLayer* cachedLayer = layer(node);
const WebCore::LayerAndroid* rootLayer = mRoot->rootLayer();
const LayerAndroid* aLayer = cachedLayer->layer(rootLayer);
- if (aLayer) {
- IntRect rrect = cachedLayer->unadjustBounds(rootLayer, rect);
- if (!aLayer->contentIsScrollable())
- rrect.move(mViewBounds.x(), mViewBounds.y());
- return rrect;
- }
+ if (aLayer)
+ return cachedLayer->unadjustBounds(rootLayer, rect);
}
#endif
return rect;
diff --git a/WebKit/android/nav/CachedLayer.cpp b/WebKit/android/nav/CachedLayer.cpp
index 5ad5c8b..0c53da2 100644
--- a/WebKit/android/nav/CachedLayer.cpp
+++ b/WebKit/android/nav/CachedLayer.cpp
@@ -49,10 +49,6 @@ IntRect CachedLayer::adjustBounds(const LayerAndroid* root,
// First, remove the original offset from the bounds.
temp.move(-mOffset.x(), -mOffset.y());
- // Now, add in the original scroll position. This moves the node to the
- // original location within the layer.
- temp.move(mScrollOffset.x(), mScrollOffset.y());
-
// Next, add in the new position of the layer (could be different due to a
// fixed position layer).
FloatPoint position = getGlobalPosition(aLayer);
@@ -62,32 +58,16 @@ IntRect CachedLayer::adjustBounds(const LayerAndroid* root,
const FloatPoint& translation = aLayer->translation();
temp.move(translation.x(), translation.y());
- // Move the bounds by the layer's internal scroll position.
- const SkPoint& scroll = aLayer->scrollPosition();
- temp.move(SkScalarToFloat(-scroll.fX), SkScalarToFloat(-scroll.fY));
-
IntRect result = enclosingIntRect(temp);
- // Finally, clip the result to the foreground (this includes the object's
- // border which does not scroll).
- IntRect clip(aLayer->foregroundClip());
- if (!clip.isEmpty()) {
- clip.move(position.x(), position.y());
- result.intersect(clip);
- }
-
DBG_NAV_LOGV("root=%p aLayer=%p [%d]"
" bounds=(%d,%d,w=%d,h=%d) trans=(%g,%g) pos=(%f,%f)"
- " offset=(%d,%d) clip=(%d,%d,w=%d,h=%d)"
- " scroll=(%d,%d) origScroll=(%d,%d)"
+ " offset=(%d,%d)"
" result=(%d,%d,w=%d,h=%d)",
root, aLayer, aLayer->uniqueId(),
bounds.x(), bounds.y(), bounds.width(), bounds.height(),
translation.x(), translation.y(), position.x(), position.y(),
mOffset.x(), mOffset.y(),
- clip.x(), clip.y(), clip.width(), clip.height(),
- SkScalarRound(scroll.fX), SkScalarRound(scroll.fY),
- mScrollOffset.x(), mScrollOffset.y(),
result.x(), result.y(), result.width(), result.height());
return result;
}
@@ -109,26 +89,17 @@ IntRect CachedLayer::unadjustBounds(const LayerAndroid* root,
const FloatPoint& translation = aLayer->translation();
temp.move(-translation.x(), -translation.y());
- // Move the bounds by the internal scroll position.
- const SkPoint& scroll = aLayer->scrollPosition();
- temp.move(SkScalarRound(scroll.fX), SkScalarRound(scroll.fY));
-
// Move it back to the original offset.
temp.move(mOffset.x(), mOffset.y());
- // Move the bounds by the original scroll.
- temp.move(-mScrollOffset.x(), -mScrollOffset.y());
DBG_NAV_LOGD("root=%p aLayer=%p [%d]"
" bounds=(%d,%d,w=%d,h=%d) trans=(%g,%g) pos=(%f,%f)"
" offset=(%d,%d)"
- " scroll=(%d,%d) origScroll=(%d,%d)"
" result=(%d,%d,w=%d,h=%d)",
root, aLayer, aLayer->uniqueId(),
bounds.x(), bounds.y(), bounds.width(), bounds.height(),
translation.x(), translation.y(), position.x(), position.y(),
mOffset.x(), mOffset.y(),
- SkScalarRound(scroll.fX), SkScalarRound(scroll.fY),
- mScrollOffset.x(), mScrollOffset.y(),
temp.x(), temp.y(), temp.width(), temp.height());
return temp;
}
@@ -153,7 +124,7 @@ const LayerAndroid* CachedLayer::layer(const LayerAndroid* root) const
return mLayer = root->findById(mUniqueId);
}
-// return bounds relative to enclosing layer as recorded when walking the dom
+// return bounds relative to the layer as recorded when walking the dom
IntRect CachedLayer::localBounds(const LayerAndroid* root,
const IntRect& bounds) const
{
@@ -161,45 +132,14 @@ IntRect CachedLayer::localBounds(const LayerAndroid* root,
// Remove the original offset from the bounds.
temp.move(-mOffset.x(), -mOffset.y());
- // We add in the original scroll position in order to position the node
- // relative to the current internal scroll position.
- temp.move(mScrollOffset.x(), mScrollOffset.y());
-
- const LayerAndroid* aLayer = layer(root);
- FloatPoint position;
- if (aLayer) {
- const LayerAndroid* parent = static_cast<const LayerAndroid*>
- (aLayer->getParent());
- if (parent) {
- position = getGlobalPosition(parent);
- temp.move(-position.x(), -position.y());
- }
- // Move the bounds by the scroll position of the layer.
- const SkPoint& scroll = aLayer->scrollPosition();
- temp.move(SkScalarToFloat(-scroll.fX), SkScalarToFloat(-scroll.fY));
-
- // Clip by the layer's foreground bounds. Since the bounds have
- // already be moved local to the layer, no need to move the foreground
- // clip.
- IntRect foregroundClip(aLayer->foregroundClip());
- if (!foregroundClip.isEmpty())
- temp.intersect(foregroundClip);
- }
-
#if DEBUG_NAV_UI
- const FloatPoint& translation = aLayer->translation();
- SkPoint scroll = SkPoint::Make(0,0);
- if (aLayer) scroll = aLayer->scrollPosition();
+ const LayerAndroid* aLayer = layer(root);
DBG_NAV_LOGD("aLayer=%p [%d] bounds=(%d,%d,w=%d,h=%d) offset=(%d,%d)"
- " scrollOffset=(%d,%d) position=(%g,%g) result=(%d,%d,w=%d,h=%d)"
- " scroll=(%d,%d) trans=(%g,%g)",
+ " result=(%d,%d,w=%d,h=%d)",
aLayer, aLayer ? aLayer->uniqueId() : 0,
bounds.x(), bounds.y(), bounds.width(), bounds.height(),
mOffset.x(), mOffset.y(),
- mScrollOffset.x(), mScrollOffset.y(), position.x(), position.y(),
- temp.x(), temp.y(), temp.width(), temp.height(),
- scroll.fX, scroll.fY,
- translation.x(), translation.y());
+ temp.x(), temp.y(), temp.width(), temp.height());
#endif
return temp;
@@ -240,8 +180,6 @@ void CachedLayer::Debug::print() const
DUMP_NAV_LOGD(" // LayerAndroid* mLayer=%p;\n", b->mLayer);
DUMP_NAV_LOGD(" // int mOffset=(%d, %d);\n",
b->mOffset.x(), b->mOffset.y());
- DUMP_NAV_LOGD(" // int mScrollOffset=(%d, %d);\n",
- b->mScrollOffset.x(), b->mScrollOffset.y());
DUMP_NAV_LOGD(" // int mUniqueId=%p;\n", b->mUniqueId);
DUMP_NAV_LOGD("%s\n", "");
}
@@ -257,11 +195,10 @@ void CachedLayer::Debug::printLayerAndroid(const LayerAndroid* layer)
++spaces;
SkRect bounds;
layer->bounds(&bounds);
- DUMP_NAV_LOGD("%.*s layer=%p [%d] (%g,%g,%g,%g)"
- " position=(%g,%g) translation=(%g,%g) anchor=(%g,%g)"
- " matrix=(%g,%g) childMatrix=(%g,%g)"
- " foregroundLocation=(%g,%g)"
- " picture=%p clipped=%s\n",
+ DBG_NAV_LOGD("%.*s layer=%p [%d] (%g,%g,%g,%g)"
+ " position=(%g,%g) translation=(%g,%g) anchor=(%g,%g)"
+ " matrix=(%g,%g) childMatrix=(%g,%g) picture=%p clipped=%s"
+ " scrollable=%s\n",
spaces, " ", layer, layer->uniqueId(),
bounds.fLeft, bounds.fTop, bounds.width(), bounds.height(),
layer->getPosition().fX, layer->getPosition().fY,
@@ -270,8 +207,8 @@ void CachedLayer::Debug::printLayerAndroid(const LayerAndroid* layer)
layer->getMatrix().getTranslateX(), layer->getMatrix().getTranslateY(),
layer->getChildrenMatrix().getTranslateX(),
layer->getChildrenMatrix().getTranslateY(),
- layer->scrollPosition().fX, layer->scrollPosition().fY,
- layer->picture(), layer->m_haveClip ? "true" : "false");
+ layer->picture(), layer->m_haveClip ? "true" : "false",
+ layer->contentIsScrollable() ? "true" : "false");
for (int i = 0; i < layer->countChildren(); i++)
printLayerAndroid(layer->getChild(i));
--spaces;
diff --git a/WebKit/android/nav/CachedLayer.h b/WebKit/android/nav/CachedLayer.h
index fd5f4a0..db7bfb1 100644
--- a/WebKit/android/nav/CachedLayer.h
+++ b/WebKit/android/nav/CachedLayer.h
@@ -48,7 +48,7 @@ public:
}
// FIXME: adjustBounds should be renamed globalBounds or toGlobal
IntRect adjustBounds(const LayerAndroid* root, const IntRect& bounds) const;
- // Moves the bounds by the layer's scroll position. Assumes the incoming
+ // Moves the bounds by the layer's position. Assumes the incoming
// bounds have been adjusted by adjustBounds.
IntRect unadjustBounds(const LayerAndroid* root,
const IntRect& bounds) const;
@@ -60,19 +60,17 @@ public:
void toLocal(const LayerAndroid* root, int* xPtr, int* yPtr) const;
void reset() { mLayer = 0; }
void setCachedNodeIndex(int index) { mCachedNodeIndex = index; }
+ // Set the global position of the layer. This is recorded by the nav cache
+ // and corresponds to RenderLayer::absoluteBoundingBox() which is in
+ // document coordinates. This can be different from the global position of
+ // the layer if the layer is fixed positioned or scrollable.
void setOffset(const IntPoint& offset) { mOffset = offset; }
- void setScrollOffset(const IntPoint& scrollOffset) {
- mScrollOffset = scrollOffset;
- }
void setUniqueId(int uniqueId) { mUniqueId = uniqueId; }
int uniqueId() const { return mUniqueId; }
private:
int mCachedNodeIndex;
mutable const LayerAndroid* mLayer;
- // mOffset and mScrollOffset are the position and scroll offset of the
- // layer when recorded by the nav cache.
IntPoint mOffset;
- IntPoint mScrollOffset;
int mUniqueId;
#if DUMP_NAV_CACHE
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);