diff options
3 files changed, 31 insertions, 17 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 5207ace..e34125c 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -670,6 +670,14 @@ void GraphicsLayerAndroid::updateScrollOffset() { askForSync(); } +static void setScrollLimits(ScrollableLayerAndroid* scrollableLayer, RenderLayer* renderLayer) +{ + RenderBox* box = renderLayer->renderBox(); + scrollableLayer->setScrollLimits(0, 0, + renderLayer->scrollWidth() - box->clientWidth(), + renderLayer->scrollHeight() - box->clientHeight()); +} + bool GraphicsLayerAndroid::repaint() { ALOGV("(%x) repaint(), gPaused(%d) m_needsRepaint(%d) m_haveContents(%d) ", @@ -730,7 +738,7 @@ bool GraphicsLayerAndroid::repaint() // for the contents to be in the correct position. m_foregroundLayer->setPosition(-x, -y); // Set the scrollable bounds of the layer. - static_cast<ScrollableLayerAndroid*>(m_foregroundLayer)->setScrollLimits(-x, -y, m_size.width(), m_size.height()); + setScrollLimits(static_cast<ScrollableLayerAndroid*>(m_foregroundLayer), layer); // Invalidate the entire layer for now, as webkit will only send the // setNeedsDisplayInRect() for the visible (clipped) scrollable area, @@ -788,8 +796,7 @@ bool GraphicsLayerAndroid::repaint() // limits based on the view size. if (m_contentLayer->isIFrameContent()) { FrameView* view = layer->renderer()->frame()->view(); - static_cast<IFrameContentLayerAndroid*>(m_contentLayer)->setScrollLimits( - m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight()); + setScrollLimits(static_cast<ScrollableLayerAndroid*>(m_contentLayer), layer); ALOGV("setScrollLimits(%.2f, %.2f, w: %d h: %d) layer %d, frame scroll position is %d, %d", m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight(), m_contentLayer->uniqueId(), view->scrollX(), view->scrollY()); diff --git a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp index 1178103..c29ab2d 100644 --- a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.cpp @@ -29,21 +29,31 @@ bool ScrollableLayerAndroid::scrollTo(int x, int y) void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const { - const SkPoint& pos = getPosition(); - out->setX(m_scrollLimits.fLeft - pos.fX); - out->setY(m_scrollLimits.fTop - pos.fY); - out->setWidth(getSize().width() - m_scrollLimits.width()); - out->setHeight(getSize().height() - m_scrollLimits.height()); + out->setX(m_scrollLimits.fLeft); + out->setY(m_scrollLimits.fTop); + out->setWidth(m_scrollLimits.width()); + out->setHeight(m_scrollLimits.height()); } void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const { - const SkPoint& pos = getPosition(); - out->fLeft = m_scrollLimits.fLeft - pos.fX + getScrollOffset().x(); - out->fTop = m_scrollLimits.fTop - pos.fY + getScrollOffset().y(); + out->fLeft = getScrollOffset().x(); + out->fTop = getScrollOffset().y(); - out->fRight = getSize().width() - m_scrollLimits.width(); - out->fBottom = getSize().height() - m_scrollLimits.height(); + out->fRight = m_scrollLimits.width(); + out->fBottom = m_scrollLimits.height(); +} + +void ScrollableLayerAndroid::setScrollLimits(float minX, float minY, + float maxX, float maxY) +{ + if (minX < 0) minX = 0; + if (minY < 0) minY = 0; + if (maxX < 0) maxX = 0; + if (maxY < 0) maxY = 0; + if (minX > maxX) minX = maxX; + if (minY > maxY) minY = maxY; + m_scrollLimits.set(minX, minY, minX + maxX, minY + maxY); } bool ScrollableLayerAndroid::scrollRectIntoView(const SkIRect& rect) diff --git a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h index 430f053..b3c828f 100644 --- a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h @@ -54,10 +54,7 @@ public: // fBottom = maxScrollY virtual void getScrollRect(SkIRect*) const; - void setScrollLimits(float x, float y, float width, float height) - { - m_scrollLimits.set(x, y, x + width, y + height); - } + void setScrollLimits(float minX, float minY, float maxX, float maxY); // Given a rect in the layer, scrolls to bring the rect into view. Uses a // lazy approach, whereby we scroll as little as possible to bring the |