summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp7
-rw-r--r--WebKit/android/WebCoreSupport/PlatformBridge.cpp6
-rw-r--r--WebKit/android/jni/WebViewCore.cpp69
-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
9 files changed, 152 insertions, 169 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index f1e6279..80a90fe 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -71,7 +71,12 @@ WebCore::GraphicsLayer* ChromeClientAndroid::layersSync()
void ChromeClientAndroid::scheduleCompositingLayerSync()
{
- m_needsLayerSync = true;
+ if (m_needsLayerSync)
+ return;
+ m_needsLayerSync = true;
+ WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view());
+ if (webViewCore)
+ webViewCore->layersDraw();
}
void ChromeClientAndroid::setNeedsOneShotDrawingSynchronization()
diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
index 89af00a..2c238b2 100644
--- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp
+++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
@@ -184,12 +184,6 @@ void PlatformBridge::updateTextfield(FrameView* frameView, Node* nodePtr, bool c
webViewCore->updateTextfield(nodePtr, changeToPassword, text);
}
-void PlatformBridge::updateLayers(FrameView* frameView)
-{
- android::WebViewCore* webViewCore = android::WebViewCore::getWebViewCore(frameView);
- webViewCore->layersDraw();
-}
-
int PlatformBridge::lowMemoryUsageMB()
{
return MemoryUsage::lowMemoryUsageMb();
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 1fdc3d5..5f5bb53 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1176,14 +1176,6 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
WebCoreViewBridge* window = m_mainFrame->view()->platformWidget();
int ow = window->width();
int oh = window->height();
- window->setSize(width, height);
- window->setVisibleSize(screenWidth, screenHeight);
- if (width != screenWidth) {
- m_mainFrame->view()->setUseFixedLayout(true);
- m_mainFrame->view()->setFixedLayoutSize(IntSize(width, height));
- } else {
- m_mainFrame->view()->setUseFixedLayout(false);
- }
int osw = m_screenWidth;
int osh = m_screenHeight;
int otw = m_textWrapWidth;
@@ -1210,7 +1202,7 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
// orientation change. Try to keep the anchor at the same place.
if (otw && textWrapWidth && otw != textWrapWidth) {
WebCore::HitTestResult hitTestResult =
- m_mainFrame->eventHandler()-> hitTestResultAtPoint(
+ m_mainFrame->eventHandler()->hitTestResultAtPoint(
anchorPoint, false);
node = hitTestResult.innerNode();
}
@@ -1230,8 +1222,20 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
}
}
}
+
+ // Set the size after finding the old anchor point as
+ // hitTestResultAtPoint causes a layout.
+ window->setSize(width, height);
+ window->setVisibleSize(screenWidth, screenHeight);
+ if (width != screenWidth) {
+ m_mainFrame->view()->setUseFixedLayout(true);
+ m_mainFrame->view()->setFixedLayoutSize(IntSize(width, height));
+ } else {
+ m_mainFrame->view()->setUseFixedLayout(false);
+ }
r->setNeedsLayoutAndPrefWidthsRecalc();
m_mainFrame->view()->forceLayout();
+
// scroll to restore current screen center
if (node) {
const WebCore::IntRect& newBounds = node->getRect();
@@ -1261,6 +1265,16 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
}
}
}
+ } else {
+ window->setSize(width, height);
+ window->setVisibleSize(screenWidth, screenHeight);
+ m_mainFrame->view()->resize(width, height);
+ if (width != screenWidth) {
+ m_mainFrame->view()->setUseFixedLayout(true);
+ m_mainFrame->view()->setFixedLayoutSize(IntSize(width, height));
+ } else {
+ m_mainFrame->view()->setUseFixedLayout(false);
+ }
}
// update the currently visible screen as perceived by the plugin
@@ -2792,33 +2806,35 @@ void WebViewCore::touchUp(int touchGeneration,
// Return the RenderLayer for the given RenderObject only if the layer is
// composited and it contains a scrollable content layer.
-static WebCore::RenderLayer* getLayerFromRenderer(
- WebCore::RenderObject* renderer, LayerAndroid** aLayer)
+static WebCore::RenderLayer* getScrollingLayerFromRenderer(
+ WebCore::RenderObject* renderer)
{
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
if (!renderer)
return 0;
WebCore::RenderLayer* layer = renderer->enclosingSelfPaintingLayer();
- if (!layer || !layer->backing())
- return 0;
- GraphicsLayerAndroid* graphicsLayer =
- static_cast<GraphicsLayerAndroid*>(layer->backing()->graphicsLayer());
- if (!graphicsLayer)
- return 0;
- LayerAndroid* layerAndroid = graphicsLayer->contentLayer();
- if (!layerAndroid || !layerAndroid->contentIsScrollable())
+ if (!layer)
return 0;
- *aLayer = layerAndroid;
+ // 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)
{
- LayerAndroid* aLayer;
- WebCore::RenderLayer* layer = getLayerFromRenderer(renderer, &aLayer);
+ 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, false, false);
+
WebCore::IntRect absBounds = renderer->absoluteBoundingBoxRect();
// Do not include the outline when moving the node's bounds.
WebCore::IntRect layerBounds = layer->renderer()->absoluteBoundingBoxRect();
@@ -2826,16 +2842,11 @@ static void scrollLayer(WebCore::RenderObject* renderer, WebCore::IntPoint* pos)
// Move the node's bounds into the layer's coordinates.
absBounds.move(-layerBounds.x(), -layerBounds.y());
- int diffX = layer->scrollXOffset();
- int diffY = layer->scrollYOffset();
- // Scroll the layer to the node's position. The false parameters tell the
- // layer not to invalidate.
+ // Scroll the layer to the node's position.
layer->scrollToOffset(absBounds.x(), absBounds.y(), false, true);
- diffX = layer->scrollXOffset() - diffX;
- diffY = layer->scrollYOffset() - diffY;
// Update the mouse position to the layer offset.
- pos->move(-diffX, -diffY);
+ pos->move(-layer->scrollXOffset(), -layer->scrollYOffset());
}
// Common code for both clicking with the trackball and touchUp
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);