Chromium Code Reviews| Index: Source/core/animation/Animation.cpp |
| diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/Animation.cpp |
| index 37715b2c7c078f8c8db951c3607040a4a8d75178..6e8f93b5310951781701df809f089200d2dcaa7f 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,6 @@ void Animation::willDetach() |
| { |
| if (m_target) |
| m_target->activeAnimations()->players().remove(player()); |
| - |
| if (m_activeInAnimationStack) |
| clearEffects(); |
| } |
| @@ -92,6 +93,7 @@ void Animation::clearEffects() |
| ASSERT(player()); |
| ASSERT(m_activeInAnimationStack); |
| ensureAnimationStack(m_target.get()).remove(this); |
| + cancelCompositorAnimations(); |
| m_activeInAnimationStack = false; |
| m_compositableValues.clear(); |
| m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
| @@ -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; |
|
Steve Block
2013/11/18 05:03:03
Does this assume that timeToNextIteration is alway
dstockwell
2013/11/18 06:11:20
Done.
|
| + } |
| return 0; |
| case PhaseAfter: |
| // If this Animation is still in effect then it will need to update |
| @@ -133,4 +139,52 @@ 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)) { |
|
Steve Block
2013/11/18 05:03:03
Given that startCompositorAnimation() returns a ve
dstockwell
2013/11/18 06:11:20
Done.
|
| + ASSERT(!m_acceleratedAnimationIds.isEmpty()); |
| + return true; |
|
Steve Block
2013/11/18 05:03:03
Can you invert this 'if' to make all the early-out
dstockwell
2013/11/18 06:11:20
Done.
|
| + } |
| + return false; |
| +} |
| + |
| +bool Animation::isRunningCompositorAnimation() const |
| +{ |
| + return !m_acceleratedAnimationIds.isEmpty(); |
| +} |
| + |
| +bool Animation::isRunningCompositorAnimation(CSSPropertyID property) const |
| +{ |
| + return isRunningCompositorAnimation() && affects(property); |
| +} |
| + |
| +bool Animation::affects(CSSPropertyID property) const |
| +{ |
| + return toKeyframeAnimationEffect(m_effect.get())->affects(property); |
|
Steve Block
2013/11/18 05:03:03
Hmm, why isn't affects() on AnimationEffect, rathe
dstockwell
2013/11/18 06:11:20
Done.
|
| +} |
| + |
| +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 |