| Index: third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
|
| diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
|
| index 142b27e77d62f5646402360ceea8281f46b330ca..abe02308ae41bdc775047555b70b1fdd13fe96ff 100644
|
| --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
|
| +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "platform/RuntimeEnabledFeatures.h"
|
| #include "platform/graphics/GraphicsLayer.h"
|
| +#include "platform/scroll/MainThreadScrollingReason.h"
|
| #include "platform/scroll/ScrollableArea.h"
|
| #include "public/platform/Platform.h"
|
| #include "public/platform/WebCompositorAnimationPlayer.h"
|
| @@ -14,11 +15,17 @@
|
|
|
| namespace blink {
|
|
|
| +WebLayer* toWebLayer(blink::GraphicsLayer* layer)
|
| +{
|
| + return layer ? layer->platformLayer() : nullptr;
|
| +}
|
| +
|
| ScrollAnimatorCompositorCoordinator::ScrollAnimatorCompositorCoordinator()
|
| : m_compositorAnimationAttachedToLayerId(0)
|
| , m_runState(RunState::Idle)
|
| , m_compositorAnimationId(0)
|
| , m_compositorAnimationGroupId(0)
|
| + , m_clearMainThreadScrollingReasons(false)
|
| {
|
| if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
|
| ASSERT(Platform::current()->compositorSupport());
|
| @@ -41,6 +48,42 @@ void ScrollAnimatorCompositorCoordinator::resetAnimationState()
|
| m_runState = RunState::Idle;
|
| m_compositorAnimationId = 0;
|
| m_compositorAnimationGroupId = 0;
|
| +
|
| + // While there was a running animation, a temporary main thread scrolling
|
| + // reason may have been added for the animation to complete on the main
|
| + // thread.
|
| + clearMainThreadScrollingReasonsOnLayer();
|
| +}
|
| +
|
| +void ScrollAnimatorCompositorCoordinator::clearMainThreadScrollingReasonsOnLayer()
|
| +{
|
| + if (WebLayer* scrollLayer = toWebLayer(scrollableArea()->layerForScrolling())) {
|
| + if (m_clearMainThreadScrollingReasons) {
|
| + scrollLayer->clearMainThreadScrollingReasons();
|
| + m_clearMainThreadScrollingReasons = false;
|
| + } else {
|
| + scrollLayer->clearMainThreadScrollingReasons(
|
| + MainThreadScrollingReason::kContinuingMainThreadScroll);
|
| + }
|
| + }
|
| +}
|
| +
|
| +void ScrollAnimatorCompositorCoordinator::clearMainThreadScrollingReasons(bool clear)
|
| +{
|
| + m_clearMainThreadScrollingReasons = clear;
|
| + if (!clear)
|
| + return;
|
| + if (!hasRunningAnimation()) {
|
| + clearMainThreadScrollingReasonsOnLayer();
|
| + } else if (WebLayer* scrollLayer = toWebLayer(scrollableArea()->layerForScrolling())) {
|
| + // If there is a running animation, finish it on main thread before
|
| + // clearing main thread scrolling reasons. In the mean time, add
|
| + // a temporary main thread scrolling reason that ensures that the cc
|
| + // doesn't start another scroll animation that will compete with this
|
| + // animation (see crbug.com/581875).
|
| + scrollLayer->addMainThreadScrollingReasons(
|
| + MainThreadScrollingReason::kContinuingMainThreadScroll);
|
| + }
|
| }
|
|
|
| bool ScrollAnimatorCompositorCoordinator::hasAnimationThatRequiresService() const
|
|
|