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

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimator.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/ScrollAnimator.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
index a6dc9bffc3c47ebd627718a9fbf18deb93ab410c..c3b47315630a09445668430e1400f374fa7d5225 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
@@ -59,6 +59,19 @@ ScrollAnimator::~ScrollAnimator()
cancelAnimations();
}
+FloatPoint ScrollAnimator::desiredTargetPosition() const
+{
+ return m_animationCurve ? FloatPoint(m_animationCurve->targetValue()) : currentPosition();
+}
+
+float ScrollAnimator::computeDeltaToConsume(ScrollbarOrientation orientation, float pixelDelta) const
+{
+ FloatPoint pos = desiredTargetPosition();
+ float currentPos = (orientation == HorizontalScrollbar) ? pos.x() : pos.y();
+ float newPos = clampScrollPosition(orientation, currentPos + pixelDelta);
+ return (currentPos == newPos) ? 0.0f : (newPos - currentPos);
+}
+
ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float delta)
{
if (!m_scrollableArea->scrollAnimatorEnabled())
@@ -69,12 +82,11 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orien
if (granularity == ScrollByPrecisePixel)
return ScrollAnimatorBase::userScroll(orientation, granularity, step, delta);
- float pixelDelta = step * delta;
- FloatPoint desiredDelta = (orientation == VerticalScrollbar ? FloatPoint(0, pixelDelta) : FloatPoint(pixelDelta, 0));
+ float usedPixelDelta = computeDeltaToConsume(orientation, step * delta);
+ FloatPoint pixelDelta = (orientation == VerticalScrollbar ? FloatPoint(0, usedPixelDelta) : FloatPoint(usedPixelDelta, 0));
- FloatPoint targetPos = m_animationCurve ? FloatPoint(m_animationCurve->targetValue()) : currentPosition();
- targetPos.moveBy(desiredDelta);
- targetPos = FloatPoint(m_scrollableArea->clampScrollPosition(targetPos));
+ FloatPoint targetPos = desiredTargetPosition();
+ targetPos.moveBy(pixelDelta);
if (m_animationCurve) {
if (!(targetPos - m_animationCurve->targetValue()).isZero())
@@ -86,7 +98,7 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orien
// Report unused delta only if there is no animation and we are not
// starting one. This ensures we latch for the duration of the
// animation rather than animating multiple scrollers at the same time.
- return ScrollResultOneDimensional(/* didScroll */ false, pixelDelta);
+ return ScrollResultOneDimensional(/* didScroll */ false, delta);
}
m_animationCurve = adoptPtr(Platform::current()->compositorSupport()->createScrollOffsetAnimationCurve(

Powered by Google App Engine
This is Rietveld 408576698