diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/page/animation/CompositeAnimation.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/page/animation/CompositeAnimation.cpp | 147 |
1 files changed, 56 insertions, 91 deletions
diff --git a/src/3rdparty/webkit/WebCore/page/animation/CompositeAnimation.cpp b/src/3rdparty/webkit/WebCore/page/animation/CompositeAnimation.cpp index b03dfe35ee..9481b8d986 100644 --- a/src/3rdparty/webkit/WebCore/page/animation/CompositeAnimation.cpp +++ b/src/3rdparty/webkit/WebCore/page/animation/CompositeAnimation.cpp @@ -117,7 +117,10 @@ void CompositeAnimation::updateTransitions(RenderObject* renderer, RenderStyle* bool equal = true; if (implAnim) { - implAnim->setActive(true); + // If we are post active don't bother setting the active flag. This will cause + // this animation to get removed at the end of this function. + if (!implAnim->postActive()) + implAnim->setActive(true); // This might be a transition that is just finishing. That would be the case // if it were postActive. But we still need to check for equality because @@ -183,52 +186,62 @@ void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, Render if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; - // Nothing to do if the current and target animations are the same - if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) - return; - - // Mark all existing animations as no longer active AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); - for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) - it->second->setIndex(-1); - - // Toss the animation order map - m_keyframeAnimationOrderMap.clear(); - // Now mark any still active animations as active and add any new animations - if (targetStyle->animations()) { - int numAnims = targetStyle->animations()->size(); - for (int i = 0; i < numAnims; ++i) { - const Animation* anim = targetStyle->animations()->animation(i); - AtomicString animationName(anim->name()); - - if (!anim->isValidAnimation()) - continue; + if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { + // The current and target animations are the same so we just need to toss any + // animation which is finished (postActive). + for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { + if (it->second->postActive()) + it->second->setIndex(-1); + } + } else { + // Mark all existing animations as no longer active. + for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) + it->second->setIndex(-1); - // See if there is a current animation for this name - RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); + // Toss the animation order map. + m_keyframeAnimationOrderMap.clear(); + + // Now mark any still active animations as active and add any new animations. + if (targetStyle->animations()) { + int numAnims = targetStyle->animations()->size(); + for (int i = 0; i < numAnims; ++i) { + const Animation* anim = targetStyle->animations()->animation(i); + AtomicString animationName(anim->name()); + + if (!anim->isValidAnimation()) + continue; + + // See if there is a current animation for this name. + RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); + + if (keyframeAnim) { + // If this animation is postActive, skip it so it gets removed at the end of this function. + if (keyframeAnim->postActive()) + continue; + + // This one is still active. + + // Animations match, but play states may differ. Update if needed. + keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); + + // Set the saved animation to this new one, just in case the play state has changed. + keyframeAnim->setAnimation(anim); + keyframeAnim->setIndex(i); + } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { + keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(anim), renderer, i, this, currentStyle ? currentStyle : targetStyle); + m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); + } - if (keyframeAnim) { - // There is one so it is still active - - // Animations match, but play states may differ. update if needed - keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); - - // Set the saved animation to this new one, just in case the play state has changed - keyframeAnim->setAnimation(anim); - keyframeAnim->setIndex(i); - } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { - keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(anim), renderer, i, this, currentStyle ? currentStyle : targetStyle); - m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); + // Add this to the animation order map. + if (keyframeAnim) + m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } - - // Add this to the animation order map - if (keyframeAnim) - m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } - - // Make a list of animations to be removed + + // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { @@ -237,7 +250,7 @@ void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, Render animsToBeRemoved.append(keyframeAnim->name().impl()); } - // Now remove the animations from the list + // Now remove the animations from the list. for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); } @@ -246,11 +259,9 @@ PassRefPtr<RenderStyle> CompositeAnimation::animate(RenderObject* renderer, Rend { RefPtr<RenderStyle> resultStyle; - // Update animations first so we can see if any transitions are overridden - updateKeyframeAnimations(renderer, currentStyle, targetStyle); - - // We don't do any transitions if we don't have a currentStyle (on startup) + // We don't do any transitions if we don't have a currentStyle (on startup). updateTransitions(renderer, currentStyle, targetStyle); + updateKeyframeAnimations(renderer, currentStyle, targetStyle); if (currentStyle) { // Now that we have transition objects ready, let them know about the new goal state. We want them @@ -272,8 +283,6 @@ PassRefPtr<RenderStyle> CompositeAnimation::animate(RenderObject* renderer, Rend keyframeAnim->animate(this, renderer, currentStyle, targetStyle, resultStyle); } - cleanupFinishedAnimations(); - return resultStyle ? resultStyle.release() : targetStyle; } @@ -364,50 +373,6 @@ PassRefPtr<KeyframeAnimation> CompositeAnimation::getAnimationForProperty(int pr return retval; } -void CompositeAnimation::cleanupFinishedAnimations() -{ - if (isSuspended()) - return; - - // Make a list of transitions to be deleted - Vector<int> finishedTransitions; - if (!m_transitions.isEmpty()) { - CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end(); - - for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) { - ImplicitAnimation* anim = it->second.get(); - if (!anim) - continue; - if (anim->postActive()) - finishedTransitions.append(anim->animatingProperty()); - } - - // Delete them - size_t finishedTransitionCount = finishedTransitions.size(); - for (size_t i = 0; i < finishedTransitionCount; ++i) - m_transitions.remove(finishedTransitions[i]); - } - - // Make a list of animations to be deleted - Vector<AtomicStringImpl*> finishedAnimations; - if (!m_keyframeAnimations.isEmpty()) { - AnimationNameMap::const_iterator animationsEnd = m_keyframeAnimations.end(); - - for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != animationsEnd; ++it) { - KeyframeAnimation* anim = it->second.get(); - if (!anim) - continue; - if (anim->postActive()) - finishedAnimations.append(anim->name().impl()); - } - - // Delete them - size_t finishedAnimationCount = finishedAnimations.size(); - for (size_t i = 0; i < finishedAnimationCount; ++i) - m_keyframeAnimations.remove(finishedAnimations[i]); - } -} - void CompositeAnimation::suspendAnimations() { if (m_isSuspended) |