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

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

Issue 1648293003: Fix smooth scroll jump when switching scroll handling between MT and CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated layout test Created 4 years, 10 months 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 de0000b4a8f5a948cb00f564d08a62014024fb01..e71a9abd110c6a541fcf624ea6ba98ddc303292a 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
@@ -32,6 +32,7 @@
#include "platform/TraceEvent.h"
#include "platform/graphics/GraphicsLayer.h"
+#include "platform/scroll/MainThreadScrollingReason.h"
#include "platform/scroll/ScrollableArea.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCompositorAnimation.h"
@@ -41,6 +42,11 @@
namespace blink {
+WebLayer* toWebLayer(blink::GraphicsLayer* layer)
+{
+ return layer ? layer->platformLayer() : nullptr;
+}
+
PassOwnPtrWillBeRawPtr<ScrollAnimatorBase> ScrollAnimatorBase::create(ScrollableArea* scrollableArea)
{
if (scrollableArea && scrollableArea->scrollAnimatorEnabled())
@@ -85,6 +91,10 @@ void ScrollAnimator::resetAnimationState()
if (m_animationCurve)
m_animationCurve.clear();
m_startTime = 0.0;
+
+ // Remove the temporary main thread scrolling reason that was added while
+ // main thread had scheduled an animation.
+ removeMainThreadScrollingReason();
}
ScrollResultOneDimensional ScrollAnimator::userScroll(
@@ -259,10 +269,33 @@ void ScrollAnimator::updateCompositorAnimations()
}
}
+ bool runningOnMainThread = false;
if (!sentToCompositor) {
- if (registerAndScheduleAnimation())
+ runningOnMainThread = registerAndScheduleAnimation();
+ if (runningOnMainThread)
m_runState = RunState::RunningOnMainThread;
}
+
+
+ // Main thread should deal with the scroll animations it started.
+ if (sentToCompositor || runningOnMainThread)
+ addMainThreadScrollingReason();
+ }
+}
+
+void ScrollAnimator::addMainThreadScrollingReason()
+{
+ if (WebLayer* scrollLayer = toWebLayer(scrollableArea()->layerForScrolling())) {
+ scrollLayer->addMainThreadScrollingReasons(
+ MainThreadScrollingReason::kAnimatingScollOnMainThread);
+ }
+}
+
+void ScrollAnimator::removeMainThreadScrollingReason()
+{
+ if (WebLayer* scrollLayer = toWebLayer(scrollableArea()->layerForScrolling())) {
+ scrollLayer->clearMainThreadScrollingReasons(
+ MainThreadScrollingReason::kAnimatingScollOnMainThread);
}
}
@@ -286,7 +319,8 @@ void ScrollAnimator::cancelAnimation()
void ScrollAnimator::layerForCompositedScrollingDidChange(
WebCompositorAnimationTimeline* timeline)
{
- reattachCompositorPlayerIfNeeded(timeline);
+ if (reattachCompositorPlayerIfNeeded(timeline) && m_animationCurve)
+ addMainThreadScrollingReason();
}
bool ScrollAnimator::registerAndScheduleAnimation()

Powered by Google App Engine
This is Rietveld 408576698