Index: Source/core/animation/AnimationStack.cpp |
diff --git a/Source/core/animation/AnimationStack.cpp b/Source/core/animation/AnimationStack.cpp |
index b1959b31a11f08f86e669c36ef084811a3474cb6..0fc86c0045fbbff57291c0376acba8b978905619 100644 |
--- a/Source/core/animation/AnimationStack.cpp |
+++ b/Source/core/animation/AnimationStack.cpp |
@@ -30,8 +30,8 @@ |
#include "config.h" |
#include "core/animation/AnimationStack.h" |
-#include "core/animation/Interpolation.h" |
+#include "core/animation/Interpolation.h" |
#include "core/animation/css/CSSAnimations.h" |
namespace WebCore { |
@@ -47,6 +47,22 @@ void copyToActiveInterpolationMap(const WillBeHeapVector<RefPtrWillBeMember<WebC |
} |
} |
+bool compareAnimations(Animation* animation1, Animation* animation2) |
+{ |
+ ASSERT(animation1->player() && animation2->player()); |
+ return AnimationPlayer::hasLowerPriority(animation1->player(), animation2->player()); |
+} |
+ |
+void copyNewAnimationsToActiveInterpolationMap(const Vector<InertAnimation*>& newAnimations, WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& result) |
+{ |
+ for (size_t i = 0; i < newAnimations.size(); ++i) { |
+ OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > sample = newAnimations[i]->sample(); |
+ if (sample) { |
+ copyToActiveInterpolationMap(*sample, result); |
+ } |
+ } |
+} |
+ |
} // namespace |
bool AnimationStack::affects(CSSPropertyID property) const |
@@ -67,30 +83,31 @@ bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con |
return false; |
} |
-WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > AnimationStack::activeInterpolations(const AnimationStack* animationStack, const Vector<InertAnimation*>* newAnimations, const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animation::Priority priority) |
+WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > AnimationStack::activeInterpolations(AnimationStack* animationStack, const Vector<InertAnimation*>* newAnimations, const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animation::Priority priority, double timelineCurrentTime) |
{ |
+ // We don't exactly know when new animations will start, but timelineCurrentTime is a good estimate. |
+ |
WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result; |
if (animationStack) { |
- const Vector<Animation*>& animations = animationStack->m_activeAnimations; |
+ Vector<Animation*>& animations = animationStack->m_activeAnimations; |
+ std::sort(animations.begin(), animations.end(), compareAnimations); |
for (size_t i = 0; i < animations.size(); ++i) { |
Animation* animation = animations[i]; |
if (animation->priority() != priority) |
continue; |
if (cancelledAnimationPlayers && cancelledAnimationPlayers->contains(animation->player())) |
continue; |
+ if (animation->player()->startTime() > timelineCurrentTime && newAnimations) { |
+ copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); |
+ newAnimations = 0; |
+ } |
copyToActiveInterpolationMap(animation->activeInterpolations(), result); |
} |
} |
- if (newAnimations) { |
- for (size_t i = 0; i < newAnimations->size(); ++i) { |
- OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > sample = newAnimations->at(i)->sample(); |
- if (sample) { |
- copyToActiveInterpolationMap(*sample, result); |
- } |
- } |
- } |
+ if (newAnimations) |
+ copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); |
return result; |
} |