diff options
author | John Reck <jreck@google.com> | 2012-05-29 09:03:08 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-29 09:03:08 -0700 |
commit | 7d00f9ffff22988e977504545835e2029e90ac46 (patch) | |
tree | 32c1ee12ffde5658e323846041e445d04cdc8d5a /Source | |
parent | 79d4c3bf51bdd06911212642da6d697f6a8245c5 (diff) | |
parent | eeb490ff95e8b9fd90f186ab2ec170d02af896dd (diff) | |
download | external_webkit-7d00f9ffff22988e977504545835e2029e90ac46.zip external_webkit-7d00f9ffff22988e977504545835e2029e90ac46.tar.gz external_webkit-7d00f9ffff22988e977504545835e2029e90ac46.tar.bz2 |
am eeb490ff: am 86ba0734: Compute scroll limits correctly
* commit 'eeb490ff95e8b9fd90f186ab2ec170d02af896dd':
Compute scroll limits correctly
Diffstat (limited to 'Source')
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 |