summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-09 16:25:46 +0100
committerSteve Block <steveblock@google.com>2011-05-12 14:28:33 +0100
commit31dbc523d9ee6fd7d7e46c540b5f675eeb559ed7 (patch)
tree3e73099a4bf4c6849c6f448aa3aba9fe408998f8 /Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
parentcad810f21b803229eb11403f9209855525a25d57 (diff)
downloadexternal_webkit-31dbc523d9ee6fd7d7e46c540b5f675eeb559ed7.zip
external_webkit-31dbc523d9ee6fd7d7e46c540b5f675eeb559ed7.tar.gz
external_webkit-31dbc523d9ee6fd7d7e46c540b5f675eeb559ed7.tar.bz2
Merge WebKit at r75315: Move Android-specific WebCore files to Source
This moves files in the following WebCore subdirectories ... - bindings/js - bindings/v8/custom - plugins/android - platform/android - platform/graphics/android - page/ - css/ - dom/ - loader/archive/android
Diffstat (limited to 'Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
new file mode 100644
index 0000000..ca8f03c
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
@@ -0,0 +1,39 @@
+#include "config.h"
+#include "ScrollableLayerAndroid.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+bool ScrollableLayerAndroid::scrollTo(int x, int y)
+{
+ SkIRect scrollBounds;
+ getScrollRect(&scrollBounds);
+ if (!scrollBounds.fRight && !scrollBounds.fBottom)
+ return false;
+
+ SkScalar newX = SkScalarPin(x, 0, scrollBounds.fRight);
+ SkScalar newY = SkScalarPin(y, 0, scrollBounds.fBottom);
+ // Check for no change.
+ if (newX == scrollBounds.fLeft && newY == scrollBounds.fTop)
+ return false;
+
+ SkScalar diffX = newX - scrollBounds.fLeft;
+ SkScalar diffY = newY - scrollBounds.fTop;
+ const SkPoint& pos = getPosition();
+ setPosition(pos.fX - diffX, pos.fY - diffY);
+ 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->fRight = getSize().width() - m_scrollLimits.width();
+ out->fBottom = getSize().height() - m_scrollLimits.height();
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)