Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2629)

Unified Diff: Source/platform/scroll/ScrollView.cpp

Issue 610423004: Preserve fractional scroll offset for JS scrolling API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/scroll/ScrollView.h ('k') | Source/platform/scroll/ScrollableArea.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scroll/ScrollView.cpp
diff --git a/Source/platform/scroll/ScrollView.cpp b/Source/platform/scroll/ScrollView.cpp
index 653857b12a8019fa5ca9e2360787d6742376335c..c7d3bdd2f26c7b06fa76c7eb27715579298b1786 100644
--- a/Source/platform/scroll/ScrollView.cpp
+++ b/Source/platform/scroll/ScrollView.cpp
@@ -131,7 +131,7 @@ void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode v
if (!needsUpdate)
return;
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
if (!layerForScrolling())
return;
@@ -209,7 +209,7 @@ void ScrollView::setContentsSize(const IntSize& newSize)
if (contentsSize() == newSize)
return;
m_contentsSize = newSize;
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
updateOverhangAreas();
}
@@ -303,17 +303,19 @@ void ScrollView::scrollTo(const DoublePoint& newPosition)
scrollContents(flooredIntSize(scrollDelta));
}
-void ScrollView::setScrollPosition(const IntPoint& scrollPoint, ScrollBehavior scrollBehavior)
+void ScrollView::setScrollPosition(const DoublePoint& scrollPoint, ScrollBehavior scrollBehavior)
{
- IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
+ DoublePoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
- if (newScrollPosition == scrollPosition())
+ if (newScrollPosition == scrollPositionDouble())
return;
- if (scrollBehavior == ScrollBehaviorInstant)
- updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y()));
- else
- programmaticallyScrollSmoothlyToOffset(newScrollPosition);
+ if (scrollBehavior == ScrollBehaviorInstant) {
+ DoubleSize newOffset(newScrollPosition.x(), newScrollPosition.y());
+ updateScrollbars(newOffset);
+ } else {
+ programmaticallyScrollSmoothlyToOffset(toFloatPoint(newScrollPosition));
+ }
}
bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity)
@@ -347,7 +349,7 @@ IntSize ScrollView::overhangAmount() const
void ScrollView::windowResizerRectChanged()
{
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
}
static bool useOverlayScrollbars()
@@ -509,7 +511,7 @@ bool ScrollView::adjustScrollbarExistence(ComputeScrollbarExistenceOption option
return true;
}
-void ScrollView::updateScrollbars(const IntSize& desiredOffset)
+void ScrollView::updateScrollbars(const DoubleSize& desiredOffset)
{
if (scrollbarsDisabled()) {
setScrollOffsetFromUpdateScrollbars(desiredOffset);
@@ -553,15 +555,15 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
setScrollOffsetFromUpdateScrollbars(desiredOffset);
}
-void ScrollView::setScrollOffsetFromUpdateScrollbars(const IntSize& offset)
+void ScrollView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset)
{
- IntPoint adjustedScrollPosition = IntPoint(offset);
+ DoublePoint adjustedScrollPosition = DoublePoint(offset);
if (!isRubberBandInProgress())
adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollPosition);
- if (adjustedScrollPosition != scrollPosition() || scrollOriginChanged()) {
- ScrollableArea::scrollToOffsetWithoutAnimation(adjustedScrollPosition);
+ if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged()) {
+ ScrollableArea::scrollToOffsetWithoutAnimation(toFloatPoint(adjustedScrollPosition));
resetScrollOriginChanged();
}
}
@@ -769,7 +771,7 @@ void ScrollView::setFrameRect(const IntRect& newRect)
Widget::setFrameRect(newRect);
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
frameRectsChanged();
}
@@ -879,7 +881,7 @@ void ScrollView::scrollbarStyleChanged()
{
adjustScrollbarOpacity();
contentsResized();
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
positionScrollbarLayers();
}
@@ -1175,7 +1177,7 @@ void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAl
// Update if the scroll origin changes, since our position will be different if the content size did not change.
if (updatePositionAtAll && updatePositionSynchronously)
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
}
} // namespace blink
« no previous file with comments | « Source/platform/scroll/ScrollView.h ('k') | Source/platform/scroll/ScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698