Chromium Code Reviews| Index: Source/core/animation/css/CSSAnimations.cpp |
| diff --git a/Source/core/animation/css/CSSAnimations.cpp b/Source/core/animation/css/CSSAnimations.cpp |
| index bb7a6b3332500ea30e910c5074758027167bc6de..a964daf684c44ec6d18ee2206dae3a27acb3a714 100644 |
| --- a/Source/core/animation/css/CSSAnimations.cpp |
| +++ b/Source/core/animation/css/CSSAnimations.cpp |
| @@ -86,7 +86,7 @@ CSSPropertyID propertyForAnimation(CSSPropertyID property) |
| } |
| static void resolveKeyframes(StyleResolver* resolver, const Element* animatingElement, Element& element, const RenderStyle& style, RenderStyle* parentStyle, const AtomicString& name, TimingFunction* defaultTimingFunction, |
| - AnimatableValueKeyframeVector& keyframes) |
| + StringKeyframeVector& keyframes) |
| { |
| // When the animating element is null, use its parent for scoping purposes. |
| const Element* elementForScoping = animatingElement ? animatingElement : &element; |
| @@ -101,7 +101,7 @@ static void resolveKeyframes(StyleResolver* resolver, const Element* animatingEl |
| for (size_t i = 0; i < styleKeyframes.size(); ++i) { |
| const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get(); |
| RefPtr<RenderStyle> keyframeStyle = resolver->styleForKeyframe(element, style, parentStyle, styleKeyframe, name); |
| - RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKeyframe::create(); |
| + RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); |
| const Vector<double>& offsets = styleKeyframe->keys(); |
| ASSERT(!offsets.isEmpty()); |
| keyframe->setOffset(offsets[0]); |
| @@ -123,13 +123,13 @@ static void resolveKeyframes(StyleResolver* resolver, const Element* animatingEl |
| } |
| keyframe->setEasing(timingFunction.release()); |
| } else if (CSSPropertyMetadata::isAnimatableProperty(property)) { |
| - keyframe->setPropertyValue(property, CSSAnimatableValueFactory::create(property, *keyframeStyle).get()); |
| + keyframe->setPropertyValue(property, properties.propertyAt(j).value()); |
| } |
| } |
| keyframes.append(keyframe); |
| // The last keyframe specified at a given offset is used. |
| for (size_t j = 1; j < offsets.size(); ++j) { |
| - keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset(offsets[j]).get())); |
| + keyframes.append(toStringKeyframe(keyframe->cloneWithOffset(offsets[j]).get())); |
| } |
| } |
| @@ -154,16 +154,16 @@ static void resolveKeyframes(StyleResolver* resolver, const Element* animatingEl |
| keyframes.shrink(targetIndex + 1); |
| // Add 0% and 100% keyframes if absent. |
| - RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = keyframes.isEmpty() ? nullptr : keyframes[0]; |
| + RefPtrWillBeRawPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nullptr : keyframes[0]; |
| if (!startKeyframe || keyframes[0]->offset() != 0) { |
| - startKeyframe = AnimatableValueKeyframe::create(); |
| + startKeyframe = StringKeyframe::create(); |
| startKeyframe->setOffset(0); |
| startKeyframe->setEasing(defaultTimingFunction); |
| keyframes.prepend(startKeyframe); |
| } |
| - RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = keyframes[keyframes.size() - 1]; |
| + RefPtrWillBeRawPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size() - 1]; |
| if (endKeyframe->offset() != 1) { |
| - endKeyframe = AnimatableValueKeyframe::create(); |
| + endKeyframe = StringKeyframe::create(); |
| endKeyframe->setOffset(1); |
| endKeyframe->setEasing(defaultTimingFunction); |
| keyframes.append(endKeyframe); |
| @@ -172,7 +172,7 @@ static void resolveKeyframes(StyleResolver* resolver, const Element* animatingEl |
| ASSERT(!keyframes.first()->offset()); |
| ASSERT(keyframes.last()->offset() == 1); |
| - // Snapshot current property values for 0% and 100% if missing. |
| + // FIXME: This is only used for use counting neutral keyframes running on the compositor. |
| PropertySet allProperties; |
| for (const auto& keyframe : keyframes) { |
| for (CSSPropertyID property : keyframe->properties()) |
| @@ -188,17 +188,10 @@ static void resolveKeyframes(StyleResolver* resolver, const Element* animatingEl |
| bool endNeedsValue = missingEndValues && !endKeyframeProperties.contains(property); |
| if (!startNeedsValue && !endNeedsValue) |
| continue; |
| - RefPtrWillBeRawPtr<AnimatableValue> snapshotValue = CSSAnimatableValueFactory::create(property, style); |
| - if (startNeedsValue) |
| - startKeyframe->setPropertyValue(property, snapshotValue.get()); |
| - if (endNeedsValue) |
| - endKeyframe->setPropertyValue(property, snapshotValue.get()); |
| - if (property == CSSPropertyOpacity || property == CSSPropertyTransform) |
| + if (CompositorAnimations::isCompositableProperty(property)) |
| UseCounter::count(elementForScoping->document(), UseCounter::SyntheticKeyframesInCompositedCSSAnimation); |
| } |
| } |
| - ASSERT(startKeyframe->properties().size() == allProperties.size()); |
| - ASSERT(endKeyframe->properties().size() == allProperties.size()); |
| } |
| } // namespace |
| @@ -240,6 +233,8 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
| const CSSAnimationData* animationData = style.animations(); |
| const CSSAnimations* cssAnimations = activeAnimations ? &activeAnimations->cssAnimations() : nullptr; |
| + bool isStyleChange = !activeAnimations || !activeAnimations->isAnimationStyleChange(); |
|
dstockwell
2015/01/27 02:22:59
I think it's better to invert this to be bool isAn
shend
2015/01/28 02:44:50
Done.
|
| + |
| HashSet<AtomicString> inactive; |
| if (cssAnimations) { |
| for (const auto& entry : cssAnimations->m_animations) |
| @@ -265,19 +260,37 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
| AnimationPlayer* player = existing->value.get(); |
| + if (isStyleChange && player->source()->isAnimation()) { |
| + AnimationEffect* effect = toAnimation(player->source())->effect(); |
| + if (effect && effect->isKeyframeEffectModel()) { |
|
dstockwell
2015/01/27 02:22:59
can effect ever be null?
shend
2015/01/28 02:44:50
I'm not sure. Some methods in the Animation class
|
| + KeyframeEffectModelBase* keyframeEffect = toKeyframeEffectModelBase(effect); |
| + if (keyframeEffect->hasSyntheticKeyframes()) { |
| + keyframeEffect->setDeferredInterpolationsOutdated(); |
|
dstockwell
2015/01/27 02:22:58
We shouldn't be modifying state in the calculation
shend
2015/01/28 02:44:50
Done.
|
| + if (const RenderObject* renderer = animatingElement->renderer()) { |
| + if (keyframeEffect->snapshotCompositablePropertiesIfNeeded(animatingElement, *renderer->style(), style)) { |
| + player->setOutdated(); |
|
dstockwell
2015/01/27 02:22:58
Ditto.
shend
2015/01/28 02:44:50
Done.
|
| + player->setCompositorPending(true); |
| + } |
| + } |
| + } |
| + } |
| + } |
| + |
| // FIXME: Should handle changes in the timing function. |
| if (timing != player->source()->specifiedTiming()) { |
| - ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); |
| + ASSERT(isStyleChange); |
| - AnimatableValueKeyframeVector resolvedKeyframes; |
| + StringKeyframeVector resolvedKeyframes; |
| resolveKeyframes(resolver, animatingElement, element, style, parentStyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes); |
| - update->updateAnimationTiming(player, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), |
| - timing, isPaused, player->currentTimeInternal()), timing); |
| + auto effect = StringKeyframeEffectModel::create(resolvedKeyframes); |
| + effect->forceConversionsToAnimatableValues(&element); // FIXME: remove this once LegacyStyleInterpolation is removed from StringKeyframe |
| + effect->snapshotCompositableProperties(animatingElement, style); |
| + update->updateAnimationTiming(player, InertAnimation::create(effect, timing, isPaused, player->currentTimeInternal()), timing); |
| } |
| if (isPaused != player->paused()) { |
| - ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); |
| + ASSERT(isStyleChange); |
| update->toggleAnimationPaused(animationName); |
| } |
| @@ -285,18 +298,21 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E |
| } |
| } |
| - AnimatableValueKeyframeVector resolvedKeyframes; |
| + StringKeyframeVector resolvedKeyframes; |
| 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)); |
| + ASSERT(isStyleChange); |
| + auto effect = StringKeyframeEffectModel::create(resolvedKeyframes); |
| + effect->forceConversionsToAnimatableValues(&element); // FIXME: remove this once LegacyStyleInterpolation is removed from StringKeyframe |
| + effect->snapshotCompositableProperties(animatingElement, style); |
| + update->startAnimation(animationName, InertAnimation::create(effect, timing, isPaused, 0)); |
| } |
| } |
| } |
| ASSERT(inactive.isEmpty() || cssAnimations); |
| for (const AtomicString& animationName : inactive) { |
| - ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()); |
| + ASSERT(isStyleChange); |
| update->cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName)); |
| } |
| } |