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

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

Issue 1496693005: Update RootFrameViewport::userScroll to distribute scrolls between viewports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/ScrollAnimatorBase.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp
index 78d359c2dea59e08db13134140b32ded8441d8f4..da2a57cb3a310086ac2aa05ddc692e370475ac9a 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp
@@ -50,19 +50,26 @@ ScrollAnimatorBase::~ScrollAnimatorBase()
{
}
+float ScrollAnimatorBase::computeDeltaToConsume(ScrollbarOrientation orientation, float pixelDelta) const
+{
+ float currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m_currentPosY;
+ float newPos = clampScrollPosition(orientation, currentPos + pixelDelta);
+ return (currentPos == newPos) ? 0.0f : (newPos - currentPos);
+}
+
ScrollResultOneDimensional ScrollAnimatorBase::userScroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float delta)
{
float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m_currentPosY;
- float newPos = clampScrollPosition(orientation, currentPos + step * delta);
+ float usedPixelDelta = computeDeltaToConsume(orientation, step * delta);
+ float newPos = currentPos + usedPixelDelta;
if (currentPos == newPos)
return ScrollResultOneDimensional(false, delta);
- float usedDelta = (newPos - currentPos) / step;
currentPos = newPos;
notifyPositionChanged();
- return ScrollResultOneDimensional(true, delta - usedDelta);
+ return ScrollResultOneDimensional(true, delta - (usedPixelDelta / step));
}
void ScrollAnimatorBase::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
@@ -88,7 +95,7 @@ void ScrollAnimatorBase::notifyPositionChanged()
m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_currentPosY), UserScroll);
}
-float ScrollAnimatorBase::clampScrollPosition(ScrollbarOrientation orientation, float pos)
+float ScrollAnimatorBase::clampScrollPosition(ScrollbarOrientation orientation, float pos) const
{
float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation);
float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation);

Powered by Google App Engine
This is Rietveld 408576698