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..af5c28963ac1ec5a85ff78d2bd8c2e24013a688e 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,19 @@ 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 (isRunningCompositorAnimations()) { |
| + // Need service to apply fill / fire events. |
| + const double activeEndTime = activeStartTime + activeDuration(); |
| + ASSERT(isNull(timeToNextIteration) || timeToNextIteration <= (activeEndTime - localTime)); |
| + return isNull(timeToNextIteration) ? activeEndTime - localTime : timeToNextIteration; |
|
shans
2013/11/18 21:55:01
This would be cleaner if timeToNextIteration was I
dstockwell
2013/11/19 02:04:58
Let's do that in another patch.
|
| + } |
| return 0; |
| case PhaseAfter: |
| // If this Animation is still in effect then it will need to update |
| @@ -133,4 +140,51 @@ double Animation::calculateTimeToEffectChange(double localTime, double) const |
| } |
| } |
| +bool Animation::isCandidateForCompositorAnimations() const |
| +{ |
| + if (!effect() || !m_target) |
| + return false; |
| + return CompositorAnimations::instance()->isCandidateForCompositorAnimations(specified(), *effect()); |
| +} |
| + |
| +bool Animation::maybeStartCompositorAnimations() |
| +{ |
| + ASSERT(!isRunningCompositorAnimations()); |
| + if (!isCandidateForCompositorAnimations()) |
| + return false; |
| + if (!CompositorAnimations::instance()->canStartCompositorAnimations(*m_target.get())) |
| + return false; |
| + if (!CompositorAnimations::instance()->startCompositorAnimations(*m_target.get(), specified(), *effect(), m_compositorAnimationIds)) |
| + return false; |
| + ASSERT(!m_compositorAnimationIds.isEmpty()); |
| + return true; |
| +} |
| + |
| +bool Animation::isRunningCompositorAnimations() const |
| +{ |
| + return !m_compositorAnimationIds.isEmpty(); |
| +} |
| + |
| +bool Animation::isRunningCompositorAnimations(CSSPropertyID property) const |
| +{ |
| + return isRunningCompositorAnimations() && affects(property); |
| +} |
| + |
| +bool Animation::affects(CSSPropertyID property) const |
| +{ |
| + return m_effect && m_effect->affects(property); |
| +} |
| + |
| +void Animation::cancelCompositorAnimations() |
| +{ |
| + if (!isRunningCompositorAnimations()) |
| + return; |
| + if (!m_target || !m_target->renderer()) |
| + return; |
| + for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) { |
| + CompositorAnimations::instance()->cancelCompositorAnimations(*m_target.get(), m_compositorAnimationIds[i]); |
| + } |
| + m_compositorAnimationIds.clear(); |
| +} |
| + |
| } // namespace WebCore |