| Index: Source/core/animation/Animation.cpp
|
| diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/Animation.cpp
|
| index 37715b2c7c078f8c8db951c3607040a4a8d75178..0e520555e8bafa84d65345e12bad22f6b76ec790 100644
|
| --- a/Source/core/animation/Animation.cpp
|
| +++ b/Source/core/animation/Animation.cpp
|
| @@ -32,6 +32,8 @@
|
| #include "core/animation/Animation.h"
|
|
|
| #include "core/animation/ActiveAnimations.h"
|
| +#include "core/animation/CompositorAnimations.h"
|
| +#include "core/animation/KeyframeAnimationEffect.h"
|
| #include "core/animation/Player.h"
|
| #include "core/dom/Element.h"
|
|
|
| @@ -61,7 +63,7 @@ void Animation::willDetach()
|
| {
|
| if (m_target)
|
| m_target->activeAnimations()->players().remove(player());
|
| -
|
| + cancelCompositorAnimations();
|
| if (m_activeInAnimationStack)
|
| clearEffects();
|
| }
|
| @@ -112,14 +114,18 @@ bool Animation::updateChildrenAndEffects() const
|
| return false;
|
| }
|
|
|
| -double Animation::calculateTimeToEffectChange(double localTime, double) const
|
| +double Animation::calculateTimeToEffectChange(double localTime, double timeToNextIteration) const
|
| {
|
| const double activeStartTime = startTime() + specified().startDelay;
|
| -
|
| switch (phase()) {
|
| case PhaseBefore:
|
| return activeStartTime - localTime;
|
| case PhaseActive:
|
| + if (isRunningCompositorAnimation()) {
|
| + // Need service to apply fill / fire events.
|
| + const double activeEndTime = activeStartTime + activeDuration();
|
| + return isNull(timeToNextIteration) ? activeEndTime - localTime : timeToNextIteration;
|
| + }
|
| return 0;
|
| case PhaseAfter:
|
| // If this Animation is still in effect then it will need to update
|
| @@ -133,4 +139,58 @@ double Animation::calculateTimeToEffectChange(double localTime, double) const
|
| }
|
| }
|
|
|
| +bool Animation::isCandidateForCompositorAnimation() const
|
| +{
|
| + if (!effect() || !m_target)
|
| + return false;
|
| + return CompositorAnimations::instance()->isCandidateForCompositorAnimation(specified(), *effect());
|
| +}
|
| +
|
| +bool Animation::startCompositorAnimations()
|
| +{
|
| + ASSERT(!isRunningCompositorAnimation());
|
| + if (!isCandidateForCompositorAnimation())
|
| + return false;
|
| + if (!CompositorAnimations::instance()->canStartCompositorAnimation(*m_target.get()))
|
| + return false;
|
| + if (CompositorAnimations::instance()->startCompositorAnimation(*m_target.get(), specified(), *effect(), m_acceleratedAnimationIds)) {
|
| + ASSERT(!m_acceleratedAnimationIds.isEmpty());
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +bool Animation::isRunningCompositorAnimation(const Element* element, CSSPropertyID property) const
|
| +{
|
| + if (element && element != m_target)
|
| + return false;
|
| +
|
| + if (m_acceleratedAnimationIds.isEmpty())
|
| + return false;
|
| +
|
| + return affects(property);
|
| +}
|
| +
|
| +bool Animation::affects(CSSPropertyID property) const
|
| +{
|
| + if (property == CSSPropertyInvalid) {
|
| + // Can't affect anything if there's no effect.
|
| + return m_effect;
|
| + }
|
| +
|
| + return toKeyframeAnimationEffect(m_effect.get())->affects(property);
|
| +}
|
| +
|
| +void Animation::cancelCompositorAnimations()
|
| +{
|
| + if (!isRunningCompositorAnimation())
|
| + return;
|
| + if (!m_target || !m_target->renderer())
|
| + return;
|
| + for (size_t i = 0; i < m_acceleratedAnimationIds.size(); ++i) {
|
| + CompositorAnimations::instance()->cancelCompositorAnimation(*m_target.get(), m_acceleratedAnimationIds[i]);
|
| + }
|
| + m_acceleratedAnimationIds.clear();
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|