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..c98906cf47d0d1ad415fc1b4c7f8fe33b1eedad4 100644 |
| --- a/Source/core/platform/Scrollbar.cpp |
| +++ b/Source/core/platform/Scrollbar.cpp |
| @@ -288,6 +288,9 @@ void Scrollbar::moveThumb(int pos, bool draggingDocument) |
| if (!m_scrollableArea) |
| return; |
| + float minPos = (m_orientation == HorizontalScrollbar) ? m_scrollableArea->minimumScrollPosition().x() : m_scrollableArea->minimumScrollPosition().y(); |
| + float maxPos = (m_orientation == HorizontalScrollbar) ? m_scrollableArea->maximumScrollPosition().x() : m_scrollableArea->maximumScrollPosition().y(); |
|
jamesr
2013/05/03 05:59:22
I think I've seen these lines before - can we shar
|
| + |
| int delta = pos - m_pressedPos; |
| if (draggingDocument) { |
| @@ -295,11 +298,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 = max(min(destinationPosition, maxPos), minPos); |
| m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, destinationPosition); |
| m_documentDragPos = pos; |
| return; |
| @@ -314,14 +314,13 @@ 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); |
| 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); |
| } |
| } |