Index: Source/core/animation/css/CSSAnimations.cpp |
diff --git a/Source/core/animation/css/CSSAnimations.cpp b/Source/core/animation/css/CSSAnimations.cpp |
index 2172e4d6df67e988f93a8ef73debbc6cbd72dbfe..bb8d28b05271cfe51504d896617b8d9725588a07 100644 |
--- a/Source/core/animation/css/CSSAnimations.cpp |
+++ b/Source/core/animation/css/CSSAnimations.cpp |
@@ -256,6 +256,7 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
const CSSAnimationData* animationData = style.animations(); |
const CSSAnimations* cssAnimations = activeAnimations ? &activeAnimations->cssAnimations() : nullptr; |
+ const Element* elementForScoping = animatingElement ? animatingElement : &element; |
HashSet<AtomicString> inactive; |
if (cssAnimations) { |
@@ -272,6 +273,7 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
const bool isPaused = CSSTimingData::getRepeated(animationData->playStateList(), i) == AnimPlayStatePaused; |
Timing timing = animationData->convertToTiming(i); |
+ Timing newTiming = timing; |
RefPtr<TimingFunction> keyframeTimingFunction = timing.timingFunction; |
timing.timingFunction = Timing::defaults().timingFunction; |
@@ -282,15 +284,18 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
AnimationPlayer* player = existing->value.get(); |
- // FIXME: Should handle changes in the timing function. |
- if (timing != player->source()->specifiedTiming()) { |
- ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); |
+ const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframesRule(resolver, elementForScoping, animationName.impl()); |
+ ASSERT(keyframesRule); |
+ auto prevTiming = cssAnimations->m_timings.find(animationName); |
+ ASSERT(prevTiming != cssAnimations->m_timings.end()); |
+ |
+ if (keyframesRule->styleChangeCounter() > player->source()->styleChangeCounter() || prevTiming->value != newTiming) { |
AnimatableValueKeyframeVector resolvedKeyframes; |
resolveKeyframes(resolver, animatingElement, element, style, parentStyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes); |
- update->updateAnimationTiming(player, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), |
- timing, isPaused, player->currentTimeInternal()), timing); |
+ update->updateAnimation(player, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), |
+ timing, isPaused, player->currentTimeInternal()), newTiming, keyframesRule->styleChangeCounter()); |
} |
if (isPaused != player->paused()) { |
@@ -306,7 +311,7 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
resolveKeyframes(resolver, animatingElement, element, style, parentStyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes); |
if (!resolvedKeyframes.isEmpty()) { |
ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); |
- update->startAnimation(animationName, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), timing, isPaused, 0)); |
+ update->startAnimation(animationName, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), timing, isPaused, 0), newTiming); |
} |
} |
} |
@@ -350,9 +355,14 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element) |
player->update(TimingUpdateOnDemand); |
} |
- for (const auto& timingUpdate : update->animationsWithTimingUpdates()) { |
- timingUpdate.player->source()->updateSpecifiedTiming(timingUpdate.newTiming); |
- timingUpdate.player->update(TimingUpdateOnDemand); |
+ for (const auto& entry : update->animationsWithUpdates()) { |
+ ASSERT(entry.player->source()->isAnimation()); |
+ Animation* animation = static_cast<Animation*>(entry.player->source()); |
+ |
+ animation->setEffect(entry.animation->effect()); |
+ animation->updateSpecifiedTiming(entry.animation->specifiedTiming()); |
+ animation->updateStyleChangeCounter(entry.styleChangeCounter); |
+ m_timings.set(AtomicString(entry.player->source()->name()), entry.newTiming); |
} |
for (const auto& entry : update->newAnimations()) { |
@@ -365,6 +375,7 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element) |
player->pause(); |
player->update(TimingUpdateOnDemand); |
m_animations.set(entry.name, player.get()); |
+ m_timings.set(entry.name, entry.newTiming); |
} |
// Transitions that are run on the compositor only update main-thread state |
@@ -582,8 +593,8 @@ void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u |
WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newAnimations; |
for (const auto& newAnimation : update->newAnimations()) |
newAnimations.append(newAnimation.animation.get()); |
- for (const auto& updatedAnimation : update->animationsWithTimingUpdates()) |
- newAnimations.append(updatedAnimation.animation.get()); // Animations with timing updates use a temporary InertAnimation for the current frame. |
+ for (const auto& updatedAnimation : update->animationsWithUpdates()) |
+ newAnimations.append(updatedAnimation.animation.get()); // Animations with updates use a temporary InertAnimation for the current frame. |
WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> activeInterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack, &newAnimations, &update->suppressedAnimationAnimationPlayers(), Animation::DefaultPriority, timelineCurrentTime)); |
update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimations); |
@@ -769,7 +780,7 @@ void CSSAnimationUpdate::trace(Visitor* visitor) |
visitor->trace(m_activeInterpolationsForTransitions); |
visitor->trace(m_newAnimations); |
visitor->trace(m_suppressedAnimationPlayers); |
- visitor->trace(m_animationsWithTimingUpdates); |
+ visitor->trace(m_animationsWithUpdates); |
#endif |
} |