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

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

Issue 1551933002: Fix retargeting of composited smooth scrolls from the main thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comment 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 f5a31538c089572fbe47800f9506d218d3393c72..634381a2e830c25a7b6537406c0f8be4501b29e7 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
@@ -50,7 +50,6 @@ PassOwnPtrWillBeRawPtr<ScrollAnimatorBase> ScrollAnimatorBase::create(Scrollable
ScrollAnimator::ScrollAnimator(ScrollableArea* scrollableArea, WTF::TimeFunction timeFunction)
: ScrollAnimatorBase(scrollableArea)
- , m_lastTickTime(0.0)
, m_timeFunction(timeFunction)
{
}
@@ -114,7 +113,8 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
if (m_runState == RunState::RunningOnCompositor
|| m_runState == RunState::RunningOnCompositorButNeedsUpdate) {
- m_runState = RunState::RunningOnCompositorButNeedsUpdate;
+ if (registerAndScheduleAnimation())
+ m_runState = RunState::RunningOnCompositorButNeedsUpdate;
return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
}
@@ -134,14 +134,9 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
m_targetOffset = targetPos;
m_startTime = m_timeFunction();
- scrollableArea()->registerForAnimation();
- if (!m_scrollableArea->scheduleAnimation()) {
- scrollToOffsetWithoutAnimation(targetPos);
- resetAnimationState();
- return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
- }
+ if (registerAndScheduleAnimation())
+ m_runState = RunState::WaitingToSendToCompositor;
- m_runState = RunState::WaitingToSendToCompositor;
return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
}
@@ -156,8 +151,6 @@ void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
void ScrollAnimator::tickAnimation(double monotonicTime)
{
- m_lastTickTime = monotonicTime;
-
if (m_runState != RunState::RunningOnMainThread)
return;
@@ -213,7 +206,7 @@ void ScrollAnimator::updateCompositorAnimations()
m_compositorAnimationId = 0;
m_compositorAnimationGroupId = 0;
- m_animationCurve->updateTarget(m_lastTickTime - m_startTime,
+ m_animationCurve->updateTarget(m_timeFunction() - m_startTime,
m_targetOffset);
m_runState = RunState::WaitingToSendToCompositor;
}
@@ -256,11 +249,8 @@ void ScrollAnimator::updateCompositorAnimations()
}
if (!sentToCompositor) {
- m_runState = RunState::RunningOnMainThread;
- if (!m_scrollableArea->scheduleAnimation()) {
- scrollToOffsetWithoutAnimation(m_targetOffset);
- resetAnimationState();
- }
+ if (registerAndScheduleAnimation())
+ m_runState = RunState::RunningOnMainThread;
}
}
}
@@ -281,6 +271,17 @@ void ScrollAnimator::layerForCompositedScrollingDidChange(
reattachCompositorPlayerIfNeeded(timeline);
}
+bool ScrollAnimator::registerAndScheduleAnimation()
+{
+ scrollableArea()->registerForAnimation();
+ if (!m_scrollableArea->scheduleAnimation()) {
+ scrollToOffsetWithoutAnimation(m_targetOffset);
+ resetAnimationState();
+ return false;
+ }
+ return true;
+}
+
DEFINE_TRACE(ScrollAnimator)
{
ScrollAnimatorBase::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698