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

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: 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
Index: Source/platform/scroll/ScrollView.cpp
diff --git a/Source/platform/scroll/ScrollView.cpp b/Source/platform/scroll/ScrollView.cpp
index e362c659d1378b7ed09bcdb9103402f5a08ef821..30b4d15e84d4dc6db664b826a39cb79890465d2c 100644
--- a/Source/platform/scroll/ScrollView.cpp
+++ b/Source/platform/scroll/ScrollView.cpp
@@ -123,7 +123,7 @@ void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode v
if (!needsUpdate)
return;
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
if (!layerForScrolling())
return;
@@ -201,7 +201,7 @@ void ScrollView::setContentsSize(const IntSize& newSize)
if (contentsSize() == newSize)
return;
m_contentsSize = newSize;
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
updateOverhangAreas();
}
@@ -295,17 +295,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)
@@ -339,7 +341,7 @@ IntSize ScrollView::overhangAmount() const
void ScrollView::windowResizerRectChanged()
{
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
}
static bool useOverlayScrollbars()
@@ -470,7 +472,7 @@ bool ScrollView::adjustScrollbarExistence(ComputeScrollbarExistenceOption option
return true;
}
-void ScrollView::updateScrollbars(const IntSize& desiredOffset)
+void ScrollView::updateScrollbars(const DoubleSize& desiredOffset)
{
if (scrollbarsDisabled()) {
setScrollOffsetFromUpdateScrollbars(desiredOffset);
@@ -514,15 +516,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();
}
}
@@ -730,7 +732,7 @@ void ScrollView::setFrameRect(const IntRect& newRect)
Widget::setFrameRect(newRect);
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
frameRectsChanged();
}
@@ -840,7 +842,7 @@ void ScrollView::scrollbarStyleChanged()
{
adjustScrollbarOpacity();
contentsResized();
- updateScrollbars(scrollOffset());
+ updateScrollbars(scrollOffsetDouble());
positionScrollbarLayers();
}
@@ -1136,7 +1138,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
« Source/platform/geometry/DoubleSize.h ('K') | « Source/platform/scroll/ScrollView.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698