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

Unified Diff: third_party/WebKit/Source/platform/scroll/Scrollbar.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 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: third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
index 080ab921d441fb0077730e65144390b1759efddf..1776d0e5cd11217f8c071f421a6bdc31a546c347 100644
--- a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
+++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
@@ -254,15 +254,15 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument) {
if (m_draggingDocument)
delta = pos - m_documentDragPos;
m_draggingDocument = true;
- FloatPoint currentPosition =
- m_scrollableArea->scrollAnimator().currentPosition();
+ ScrollOffset currentPosition =
+ m_scrollableArea->scrollAnimator().currentOffset();
float destinationPosition =
- (m_orientation == HorizontalScrollbar ? currentPosition.x()
- : currentPosition.y()) +
+ (m_orientation == HorizontalScrollbar ? currentPosition.width()
+ : currentPosition.height()) +
delta;
- destinationPosition = m_scrollableArea->clampScrollPosition(
- m_orientation, destinationPosition);
- m_scrollableArea->setScrollPositionSingleAxis(
+ destinationPosition =
+ m_scrollableArea->clampScrollOffset(m_orientation, destinationPosition);
+ m_scrollableArea->setScrollOffsetSingleAxis(
m_orientation, destinationPosition, UserScroll);
m_documentDragPos = pos;
return;
@@ -286,14 +286,14 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument) {
else if (delta < 0)
delta = std::max(-thumbPos, delta);
- float minPos = m_scrollableArea->minimumScrollPosition(m_orientation);
- float maxPos = m_scrollableArea->maximumScrollPosition(m_orientation);
+ float minOffset = m_scrollableArea->minimumScrollOffset(m_orientation);
+ float maxOffset = m_scrollableArea->maximumScrollOffset(m_orientation);
if (delta) {
- float newPosition = static_cast<float>(thumbPos + delta) *
- (maxPos - minPos) / (trackLen - thumbLen) +
- minPos;
- m_scrollableArea->setScrollPositionSingleAxis(m_orientation, newPosition,
- UserScroll);
+ float newOffset = static_cast<float>(thumbPos + delta) *
+ (maxOffset - minOffset) / (trackLen - thumbLen) +
+ minOffset;
+ m_scrollableArea->setScrollOffsetSingleAxis(m_orientation, newOffset,
+ UserScroll);
}
}
@@ -412,10 +412,9 @@ void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) {
if (m_pressedPart == ThumbPart) {
if (theme().shouldSnapBackToDragOrigin(*this, evt)) {
if (m_scrollableArea) {
- m_scrollableArea->setScrollPositionSingleAxis(
+ m_scrollableArea->setScrollOffsetSingleAxis(
m_orientation,
- m_dragOrigin +
- m_scrollableArea->minimumScrollPosition(m_orientation),
+ m_dragOrigin + m_scrollableArea->minimumScrollOffset(m_orientation),
UserScroll);
}
} else {
@@ -588,24 +587,26 @@ float Scrollbar::scrollableAreaCurrentPos() const {
if (!m_scrollableArea)
return 0;
- if (m_orientation == HorizontalScrollbar)
- return m_scrollableArea->scrollPosition().x() -
- m_scrollableArea->minimumScrollPosition().x();
+ if (m_orientation == HorizontalScrollbar) {
+ return m_scrollableArea->scrollOffset().width() -
+ m_scrollableArea->minimumScrollOffset().width();
+ }
- return m_scrollableArea->scrollPosition().y() -
- m_scrollableArea->minimumScrollPosition().y();
+ return m_scrollableArea->scrollOffset().height() -
+ m_scrollableArea->minimumScrollOffset().height();
}
float Scrollbar::scrollableAreaTargetPos() const {
if (!m_scrollableArea)
return 0;
- if (m_orientation == HorizontalScrollbar)
- return m_scrollableArea->scrollAnimator().desiredTargetPosition().x() -
- m_scrollableArea->minimumScrollPosition().x();
+ if (m_orientation == HorizontalScrollbar) {
+ return m_scrollableArea->scrollAnimator().desiredTargetOffset().width() -
+ m_scrollableArea->minimumScrollOffset().width();
+ }
- return m_scrollableArea->scrollAnimator().desiredTargetPosition().y() -
- m_scrollableArea->minimumScrollPosition().y();
+ return m_scrollableArea->scrollAnimator().desiredTargetOffset().height() -
+ m_scrollableArea->minimumScrollOffset().height();
}
LayoutRect Scrollbar::visualRect() const {

Powered by Google App Engine
This is Rietveld 408576698