summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-12-12 11:48:30 -0800
committerMichael Kolb <kolby@google.com>2011-12-16 13:14:33 -0800
commit5b0a8b4c05b332cd6cac21d4dae8fac868f81ec8 (patch)
treed9cf8c9836ed160a3b223eaf1488544995222727 /Source
parent84cfd72cfe2fecd8faea83ea3511f3ce343e7c02 (diff)
downloadexternal_webkit-5b0a8b4c05b332cd6cac21d4dae8fac868f81ec8.zip
external_webkit-5b0a8b4c05b332cd6cac21d4dae8fac868f81ec8.tar.gz
external_webkit-5b0a8b4c05b332cd6cac21d4dae8fac868f81ec8.tar.bz2
fix layer scrolling
Bug: 5774119 Add support for layer scrolling; also fixes the scrollTop demo referenced in bug: 5748199 Change-Id: Id04a3d52bb1e75e9ee24a4f1b8aa9b0334369ba1
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp13
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h3
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp29
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h3
-rw-r--r--Source/WebCore/rendering/RenderLayer.cpp3
7 files changed, 42 insertions, 14 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index d466cf3..1369a62 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -555,6 +555,15 @@ void GraphicsLayerAndroid::updateScrollingLayers()
#endif
}
+void GraphicsLayerAndroid::updateScrollOffset() {
+ RenderLayer* layer = renderLayerFromClient(m_client);
+ if (!layer || !m_foregroundLayer)
+ return;
+ IntSize scroll = layer->scrolledContentOffset();
+ m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height()));
+ askForSync();
+}
+
bool GraphicsLayerAndroid::repaint()
{
LOG("(%x) repaint(), gPaused(%d) m_needsRepaint(%d) m_haveContents(%d) ",
@@ -610,9 +619,11 @@ bool GraphicsLayerAndroid::repaint()
if (!layer->renderer()->style()->isLeftToRightDirection()) {
rtlOffset = layer->scrollWidth() - clip.width(); // Scroll all the way right.
}
+ m_foregroundLayer->setScrollOffset(IntPoint(scroll.width() + rtlOffset,
+ scroll.height()));
// Need to offset the foreground layer by the clip layer in order
// for the contents to be in the correct position.
- m_foregroundLayer->setPosition(-x - rtlOffset, -y);
+ m_foregroundLayer->setPosition(-x, -y);
// Set the scrollable bounds of the layer.
m_foregroundLayer->setScrollLimits(-x, -y, m_size.width(), m_size.height());
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index 358f674..e872c91 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -123,6 +123,8 @@ public:
static int instancesCount();
+ virtual void updateScrollOffset();
+
private:
void askForSync();
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 25c5e7b..342a541 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -117,6 +117,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_fixedMarginBottom = layer.m_fixedMarginBottom;
m_fixedRect = layer.m_fixedRect;
m_iframeOffset = layer.m_iframeOffset;
+ m_offset = layer.m_offset;
m_recordingPicture = layer.m_recordingPicture;
SkSafeRef(m_recordingPicture);
@@ -610,7 +611,7 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
m_atomicSync.lock();
IntSize layerSize(getSize().width(), getSize().height());
FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY);
- FloatPoint position(getPosition().fX, getPosition().fY);
+ FloatPoint position(getPosition().fX - m_offset.x(), getPosition().fY - m_offset.y());
float centerOffsetX = (0.5f - anchorPoint.x()) * layerSize.width();
float centerOffsetY = (0.5f - anchorPoint.y()) * layerSize.height();
float originX = anchorPoint.x() * layerSize.width();
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index d6e1e9a..578c2ff 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -199,6 +199,7 @@ public:
setShouldInheritFromRootTransform(true);
}
+ void setScrollOffset(IntPoint offset) { m_offset = offset; }
void setBackgroundColor(SkColor color);
void setMaskLayer(LayerAndroid*);
void setMasksToBounds(bool masksToBounds)
@@ -315,7 +316,7 @@ public:
protected:
virtual void onDraw(SkCanvas*, SkScalar opacity);
-
+ IntPoint m_offset;
TransformationMatrix m_drawTransform;
private:
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
index 3c2ced5..55692be 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
@@ -9,27 +9,34 @@ namespace WebCore {
bool ScrollableLayerAndroid::scrollTo(int x, int y)
{
- SkIRect scrollBounds;
- getScrollRect(&scrollBounds);
- if (!scrollBounds.fRight && !scrollBounds.fBottom)
+ IntRect scrollBounds;
+ getScrollBounds(&scrollBounds);
+ if (!scrollBounds.width() && !scrollBounds.height())
return false;
-
- SkScalar newX = SkScalarPin(x, 0, scrollBounds.fRight);
- SkScalar newY = SkScalarPin(y, 0, scrollBounds.fBottom);
+ SkScalar newX = SkScalarPin(x, scrollBounds.x(), scrollBounds.width());
+ SkScalar newY = SkScalarPin(y, scrollBounds.y(), scrollBounds.height());
// Check for no change.
- if (newX == scrollBounds.fLeft && newY == scrollBounds.fTop)
+ if (newX == m_offset.x() && newY == m_offset.y())
return false;
+ setScrollOffset(IntPoint(newX, newY));
+ return true;
+}
- setPosition(m_scrollLimits.fLeft - newX, m_scrollLimits.fTop - newY);
+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());
- return true;
}
void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const
{
const SkPoint& pos = getPosition();
- out->fLeft = m_scrollLimits.fLeft - pos.fX;
- out->fTop = m_scrollLimits.fTop - pos.fY;
+ out->fLeft = m_scrollLimits.fLeft - pos.fX + m_offset.x();
+ out->fTop = m_scrollLimits.fTop - pos.fY + m_offset.y();
out->fRight = getSize().width() - m_scrollLimits.width();
out->fBottom = getSize().height() - m_scrollLimits.height();
}
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
index 5cba5d9..b8ff299 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
@@ -71,6 +71,9 @@ public:
friend LayerAndroid* android::deserializeLayer(SkStream* stream);
private:
+
+ void getScrollBounds(IntRect*) const;
+
// The position of the visible area of the layer, relative to the parent
// layer. This is fixed during scrolling. We acheive scrolling by modifying
// the position of the layer.
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index cdc4c05..0932224 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -64,6 +64,7 @@
#include "HTMLNames.h"
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
#include "HTMLTextAreaElement.h"
+#include "GraphicsLayerAndroid.h"
#endif
#include "HitTestRequest.h"
#include "HitTestResult.h"
@@ -1424,6 +1425,8 @@ void RenderLayer::scrollTo(int x, int y)
// do not need to repaint simply because we are scrolling
if (view && !hasOverflowScroll())
renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);
+ if (view && hasOverflowScroll() && backing() && backing()->graphicsLayer())
+ static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer())->updateScrollOffset();
#else
if (view)
renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);