Chromium Code Reviews| Index: Source/core/platform/Scrollbar.cpp |
| diff --git a/Source/core/platform/Scrollbar.cpp b/Source/core/platform/Scrollbar.cpp |
| index 1811023455171fb5b196ef4d5d7a59d51cbf57a2..cf6f5c0285de667b7a4faaf594983750e655273a 100644 |
| --- a/Source/core/platform/Scrollbar.cpp |
| +++ b/Source/core/platform/Scrollbar.cpp |
| @@ -288,6 +288,7 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument) |
| if (!m_scrollableArea) |
| return; |
| + |
|
jamesr
2013/05/07 03:33:31
nit: don't need this blank line
|
| int delta = pos - m_pressedPos; |
| if (draggingDocument) { |
| @@ -295,11 +296,8 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument) |
| delta = pos - m_documentDragPos; |
| m_draggingDocument = true; |
| FloatPoint currentPosition = m_scrollableArea->scrollAnimator()->currentPosition(); |
| - int destinationPosition = (m_orientation == HorizontalScrollbar ? currentPosition.x() : currentPosition.y()) + delta; |
| - if (delta > 0) |
| - destinationPosition = min(destinationPosition + delta, maximum()); |
| - else if (delta < 0) |
| - destinationPosition = max(destinationPosition + delta, 0); |
| + float destinationPosition = (m_orientation == HorizontalScrollbar ? currentPosition.x() : currentPosition.y()) + delta; |
| + destinationPosition = m_scrollableArea->clampScrollPosition(m_orientation, destinationPosition); |
| m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, destinationPosition); |
| m_documentDragPos = pos; |
| return; |
| @@ -314,14 +312,15 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument) |
| int thumbPos = theme()->thumbPosition(this); |
| int thumbLen = theme()->thumbLength(this); |
| int trackLen = theme()->trackLength(this); |
| - int maxPos = trackLen - thumbLen; |
| if (delta > 0) |
| - delta = min(maxPos - thumbPos, delta); |
| + delta = min(trackLen - thumbLen - thumbPos, delta); |
| else if (delta < 0) |
| delta = max(-thumbPos, delta); |
| + float minPos = m_scrollableArea->minimumScrollPosition(m_orientation); |
| + float maxPos = m_scrollableArea->maximumScrollPosition(m_orientation); |
| if (delta) { |
| - float newPosition = static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen); |
| + float newPosition = static_cast<float>(thumbPos + delta) * (maxPos - minPos) / (trackLen - thumbLen) + minPos; |
| m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, newPosition); |
| } |
| } |