Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 851693007: Prepare for responsive CSS animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and tidy up Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/css/CSSAnimations.h" 32 #include "core/animation/css/CSSAnimations.h"
33 33
34 #include "core/StylePropertyShorthand.h" 34 #include "core/StylePropertyShorthand.h"
35 #include "core/animation/ActiveAnimations.h" 35 #include "core/animation/ActiveAnimations.h"
36 #include "core/animation/AnimationPlayer.h" 36 #include "core/animation/AnimationPlayer.h"
37 #include "core/animation/AnimationTimeline.h" 37 #include "core/animation/AnimationTimeline.h"
38 #include "core/animation/CompositorAnimations.h" 38 #include "core/animation/CompositorAnimations.h"
39 #include "core/animation/DeferredLegacyStyleInterpolation.h"
39 #include "core/animation/Interpolation.h" 40 #include "core/animation/Interpolation.h"
40 #include "core/animation/KeyframeEffectModel.h" 41 #include "core/animation/KeyframeEffectModel.h"
41 #include "core/animation/LegacyStyleInterpolation.h"
42 #include "core/animation/css/CSSAnimatableValueFactory.h" 42 #include "core/animation/css/CSSAnimatableValueFactory.h"
43 #include "core/animation/css/CSSPropertyEquality.h" 43 #include "core/animation/css/CSSPropertyEquality.h"
44 #include "core/css/CSSKeyframeRule.h" 44 #include "core/css/CSSKeyframeRule.h"
45 #include "core/css/CSSPropertyMetadata.h" 45 #include "core/css/CSSPropertyMetadata.h"
46 #include "core/css/resolver/CSSToStyleMap.h" 46 #include "core/css/resolver/CSSToStyleMap.h"
47 #include "core/css/resolver/StyleResolver.h" 47 #include "core/css/resolver/StyleResolver.h"
48 #include "core/dom/Element.h" 48 #include "core/dom/Element.h"
49 #include "core/dom/PseudoElement.h" 49 #include "core/dom/PseudoElement.h"
50 #include "core/dom/StyleEngine.h" 50 #include "core/dom/StyleEngine.h"
51 #include "core/events/TransitionEvent.h" 51 #include "core/events/TransitionEvent.h"
(...skipping 26 matching lines...) Expand all
78 case CSSPropertyWebkitTransformOriginY: 78 case CSSPropertyWebkitTransformOriginY:
79 case CSSPropertyWebkitTransformOriginZ: 79 case CSSPropertyWebkitTransformOriginZ:
80 case CSSPropertyWebkitTransformOrigin: 80 case CSSPropertyWebkitTransformOrigin:
81 return CSSPropertyTransformOrigin; 81 return CSSPropertyTransformOrigin;
82 default: 82 default:
83 break; 83 break;
84 } 84 }
85 return property; 85 return property;
86 } 86 }
87 87
88 static void resolveKeyframes(StyleResolver* resolver, const Element* animatingEl ement, Element& element, const LayoutStyle& style, LayoutStyle* parentStyle, con st AtomicString& name, TimingFunction* defaultTimingFunction, 88 static PassRefPtrWillBeRawPtr<StringKeyframeEffectModel> createKeyframeEffect(St yleResolver* resolver, const Element* animatingElement, Element& element, const LayoutStyle& style, LayoutStyle* parentStyle,
89 AnimatableValueKeyframeVector& keyframes) 89 const AtomicString& name, TimingFunction* defaultTimingFunction)
90 { 90 {
91 // When the animating element is null, use its parent for scoping purposes. 91 // When the animating element is null, use its parent for scoping purposes.
92 const Element* elementForScoping = animatingElement ? animatingElement : &el ement; 92 const Element* elementForScoping = animatingElement ? animatingElement : &el ement;
93 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen tForScoping, name); 93 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen tForScoping, name);
94 if (!keyframesRule) 94 ASSERT(keyframesRule);
95 return;
96 95
96 StringKeyframeVector keyframes;
97 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe s = keyframesRule->keyframes(); 97 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe s = keyframesRule->keyframes();
98 98
99 // Construct and populate the style for each keyframe 99 // Construct and populate the style for each keyframe
100 PropertySet specifiedPropertiesForUseCounter; 100 PropertySet specifiedPropertiesForUseCounter;
101 for (size_t i = 0; i < styleKeyframes.size(); ++i) { 101 for (size_t i = 0; i < styleKeyframes.size(); ++i) {
102 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get(); 102 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get();
103 RefPtr<LayoutStyle> keyframeStyle = resolver->styleForKeyframe(element, style, parentStyle, styleKeyframe, name); 103 RefPtr<LayoutStyle> keyframeStyle = resolver->styleForKeyframe(element, style, parentStyle, styleKeyframe, name);
104 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe yframe::create(); 104 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create();
105 const Vector<double>& offsets = styleKeyframe->keys(); 105 const Vector<double>& offsets = styleKeyframe->keys();
106 ASSERT(!offsets.isEmpty()); 106 ASSERT(!offsets.isEmpty());
107 keyframe->setOffset(offsets[0]); 107 keyframe->setOffset(offsets[0]);
108 keyframe->setEasing(defaultTimingFunction); 108 keyframe->setEasing(defaultTimingFunction);
109 const StylePropertySet& properties = styleKeyframe->properties(); 109 const StylePropertySet& properties = styleKeyframe->properties();
110 for (unsigned j = 0; j < properties.propertyCount(); j++) { 110 for (unsigned j = 0; j < properties.propertyCount(); j++) {
111 specifiedPropertiesForUseCounter.add(properties.propertyAt(j).id()); 111 specifiedPropertiesForUseCounter.add(properties.propertyAt(j).id());
112 CSSPropertyID property = propertyForAnimation(properties.propertyAt( j).id()); 112 CSSPropertyID property = propertyForAnimation(properties.propertyAt( j).id());
113 if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction) { 113 if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction) {
114 CSSValue* value = properties.propertyAt(j).value(); 114 CSSValue* value = properties.propertyAt(j).value();
115 RefPtr<TimingFunction> timingFunction; 115 RefPtr<TimingFunction> timingFunction;
116 if (value->isInheritedValue() && parentStyle->animations()) { 116 if (value->isInheritedValue() && parentStyle->animations()) {
117 timingFunction = parentStyle->animations()->timingFunctionLi st()[0]; 117 timingFunction = parentStyle->animations()->timingFunctionLi st()[0];
118 } else if (value->isValueList()) { 118 } else if (value->isValueList()) {
119 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t oCSSValueList(value)->item(0)); 119 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t oCSSValueList(value)->item(0));
120 } else { 120 } else {
121 ASSERT(value->isInheritedValue() || value->isInitialValue() || value->isUnsetValue()); 121 ASSERT(value->isInheritedValue() || value->isInitialValue() || value->isUnsetValue());
122 timingFunction = CSSTimingData::initialTimingFunction(); 122 timingFunction = CSSTimingData::initialTimingFunction();
123 } 123 }
124 keyframe->setEasing(timingFunction.release()); 124 keyframe->setEasing(timingFunction.release());
125 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) { 125 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) {
126 keyframe->setPropertyValue(property, CSSAnimatableValueFactory:: create(property, *keyframeStyle).get()); 126 keyframe->setPropertyValue(property, properties.propertyAt(j).va lue());
127 } 127 }
128 } 128 }
129 keyframes.append(keyframe); 129 keyframes.append(keyframe);
130 // The last keyframe specified at a given offset is used. 130 // The last keyframe specified at a given offset is used.
131 for (size_t j = 1; j < offsets.size(); ++j) { 131 for (size_t j = 1; j < offsets.size(); ++j) {
132 keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset (offsets[j]).get())); 132 keyframes.append(toStringKeyframe(keyframe->cloneWithOffset(offsets[ j]).get()));
133 } 133 }
134 } 134 }
135 135
136 for (CSSPropertyID property : specifiedPropertiesForUseCounter) { 136 for (CSSPropertyID property : specifiedPropertiesForUseCounter) {
137 ASSERT(property != CSSPropertyInvalid); 137 ASSERT(property != CSSPropertyInvalid);
138 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property)); 138 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property));
139 } 139 }
140 140
141 // Merge duplicate keyframes. 141 // Merge duplicate keyframes.
142 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s); 142 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s);
143 size_t targetIndex = 0; 143 size_t targetIndex = 0;
144 for (size_t i = 1; i < keyframes.size(); i++) { 144 for (size_t i = 1; i < keyframes.size(); i++) {
145 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) { 145 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) {
146 for (CSSPropertyID property : keyframes[i]->properties()) 146 for (CSSPropertyID property : keyframes[i]->properties())
147 keyframes[targetIndex]->setPropertyValue(property, keyframes[i]- >propertyValue(property)); 147 keyframes[targetIndex]->setPropertyValue(property, keyframes[i]- >propertyValue(property));
148 } else { 148 } else {
149 targetIndex++; 149 targetIndex++;
150 keyframes[targetIndex] = keyframes[i]; 150 keyframes[targetIndex] = keyframes[i];
151 } 151 }
152 } 152 }
153 if (!keyframes.isEmpty()) 153 if (!keyframes.isEmpty())
154 keyframes.shrink(targetIndex + 1); 154 keyframes.shrink(targetIndex + 1);
155 155
156 // Add 0% and 100% keyframes if absent. 156 // Add 0% and 100% keyframes if absent.
157 RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = keyframes.isEmpt y() ? nullptr : keyframes[0]; 157 RefPtrWillBeRawPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nul lptr : keyframes[0];
158 if (!startKeyframe || keyframes[0]->offset() != 0) { 158 if (!startKeyframe || keyframes[0]->offset() != 0) {
159 startKeyframe = AnimatableValueKeyframe::create(); 159 startKeyframe = StringKeyframe::create();
160 startKeyframe->setOffset(0); 160 startKeyframe->setOffset(0);
161 startKeyframe->setEasing(defaultTimingFunction); 161 startKeyframe->setEasing(defaultTimingFunction);
162 keyframes.prepend(startKeyframe); 162 keyframes.prepend(startKeyframe);
163 } 163 }
164 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = keyframes[keyframe s.size() - 1]; 164 RefPtrWillBeRawPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size() - 1];
165 if (endKeyframe->offset() != 1) { 165 if (endKeyframe->offset() != 1) {
166 endKeyframe = AnimatableValueKeyframe::create(); 166 endKeyframe = StringKeyframe::create();
167 endKeyframe->setOffset(1); 167 endKeyframe->setOffset(1);
168 endKeyframe->setEasing(defaultTimingFunction); 168 endKeyframe->setEasing(defaultTimingFunction);
169 keyframes.append(endKeyframe); 169 keyframes.append(endKeyframe);
170 } 170 }
171 ASSERT(keyframes.size() >= 2); 171 ASSERT(keyframes.size() >= 2);
172 ASSERT(!keyframes.first()->offset()); 172 ASSERT(!keyframes.first()->offset());
173 ASSERT(keyframes.last()->offset() == 1); 173 ASSERT(keyframes.last()->offset() == 1);
174 174
175 // Snapshot current property values for 0% and 100% if missing. 175 // FIXME: This is only used for use counting neutral keyframes running on th e compositor.
176 PropertySet allProperties; 176 PropertySet allProperties;
177 for (const auto& keyframe : keyframes) { 177 for (const auto& keyframe : keyframes) {
178 for (CSSPropertyID property : keyframe->properties()) 178 for (CSSPropertyID property : keyframe->properties())
179 allProperties.add(property); 179 allProperties.add(property);
180 } 180 }
181 const PropertySet& startKeyframeProperties = startKeyframe->properties(); 181 const PropertySet& startKeyframeProperties = startKeyframe->properties();
182 const PropertySet& endKeyframeProperties = endKeyframe->properties(); 182 const PropertySet& endKeyframeProperties = endKeyframe->properties();
183 bool missingStartValues = startKeyframeProperties.size() < allProperties.siz e(); 183 bool missingStartValues = startKeyframeProperties.size() < allProperties.siz e();
184 bool missingEndValues = endKeyframeProperties.size() < allProperties.size(); 184 bool missingEndValues = endKeyframeProperties.size() < allProperties.size();
185 if (missingStartValues || missingEndValues) { 185 if (missingStartValues || missingEndValues) {
186 for (CSSPropertyID property : allProperties) { 186 for (CSSPropertyID property : allProperties) {
187 bool startNeedsValue = missingStartValues && !startKeyframePropertie s.contains(property); 187 bool startNeedsValue = missingStartValues && !startKeyframePropertie s.contains(property);
188 bool endNeedsValue = missingEndValues && !endKeyframeProperties.cont ains(property); 188 bool endNeedsValue = missingEndValues && !endKeyframeProperties.cont ains(property);
189 if (!startNeedsValue && !endNeedsValue) 189 if (!startNeedsValue && !endNeedsValue)
190 continue; 190 continue;
191 RefPtrWillBeRawPtr<AnimatableValue> snapshotValue = CSSAnimatableVal ueFactory::create(property, style); 191 if (CompositorAnimations::isCompositableProperty(property))
192 if (startNeedsValue)
193 startKeyframe->setPropertyValue(property, snapshotValue.get());
194 if (endNeedsValue)
195 endKeyframe->setPropertyValue(property, snapshotValue.get());
196 if (property == CSSPropertyOpacity || property == CSSPropertyTransfo rm)
197 UseCounter::count(elementForScoping->document(), UseCounter::Syn theticKeyframesInCompositedCSSAnimation); 192 UseCounter::count(elementForScoping->document(), UseCounter::Syn theticKeyframesInCompositedCSSAnimation);
198 } 193 }
199 } 194 }
200 ASSERT(startKeyframe->properties().size() == allProperties.size()); 195
201 ASSERT(endKeyframe->properties().size() == allProperties.size()); 196 RefPtrWillBeRawPtr<StringKeyframeEffectModel> effect = StringKeyframeEffectM odel::create(keyframes, &keyframes[0]->easing());
197 effect->snapshotCompositableProperties(animatingElement, style); // FIXME: R emove this once CompositorAnimations no longer depends on AnimatableValues
198 effect->forceConversionsToAnimatableValues(&element); // FIXME: Remove this once LegacyStyleInterpolation is removed from StringKeyframe
199 return effect;
202 } 200 }
203 201
202 CSSAnimationUpdate::UpdatedAnimationStyle::CompositableStyleSnapshot snapshotCom positableProperties(LayoutObject* renderer, const LayoutStyle& newStyle, const A nimationEffect* effect)
203 {
204 CSSAnimationUpdate::UpdatedAnimationStyle::CompositableStyleSnapshot snapsho t;
205 if (!renderer)
206 return snapshot;
207
208 const LayoutStyle& oldStyle = *renderer->style();
Timothy Loh 2015/02/11 03:54:36 renderer->styleRef()
209 if (!CSSPropertyEquality::propertiesEqual(CSSPropertyOpacity, oldStyle, newS tyle) && effect->affects(CSSPropertyOpacity))
210 snapshot.opacity = CSSAnimatableValueFactory::create(CSSPropertyOpacity, newStyle);
211 if (!CSSPropertyEquality::propertiesEqual(CSSPropertyTransform, oldStyle, ne wStyle) && effect->affects(CSSPropertyTransform))
212 snapshot.transform = CSSAnimatableValueFactory::create(CSSPropertyTransf orm, newStyle);
213 if (!CSSPropertyEquality::propertiesEqual(CSSPropertyWebkitFilter, oldStyle, newStyle) && effect->affects(CSSPropertyWebkitFilter))
214 snapshot.webkitFilter = CSSAnimatableValueFactory::create(CSSPropertyWeb kitFilter, newStyle);
215
216 return snapshot;
217 }
204 } // namespace 218 } // namespace
205 219
206 CSSAnimations::CSSAnimations() 220 CSSAnimations::CSSAnimations()
207 { 221 {
208 } 222 }
209 223
210 const AtomicString CSSAnimations::getAnimationNameForInspector(const AnimationPl ayer& player) 224 const AtomicString CSSAnimations::getAnimationNameForInspector(const AnimationPl ayer& player)
211 { 225 {
212 for (const auto& it : m_animations) { 226 for (const auto& it : m_animations) {
213 if (it.value->player->sequenceNumber() == player.sequenceNumber()) 227 if (it.value->player->sequenceNumber() == player.sequenceNumber())
(...skipping 18 matching lines...) Expand all
232 calculateAnimationActiveInterpolations(update.get(), animatingElement, eleme nt.document().timeline().currentTimeInternal()); 246 calculateAnimationActiveInterpolations(update.get(), animatingElement, eleme nt.document().timeline().currentTimeInternal());
233 calculateTransitionUpdate(update.get(), animatingElement, style); 247 calculateTransitionUpdate(update.get(), animatingElement, style);
234 calculateTransitionActiveInterpolations(update.get(), animatingElement, elem ent.document().timeline().currentTimeInternal()); 248 calculateTransitionActiveInterpolations(update.get(), animatingElement, elem ent.document().timeline().currentTimeInternal());
235 return update->isEmpty() ? nullptr : update.release(); 249 return update->isEmpty() ? nullptr : update.release();
236 } 250 }
237 251
238 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E lement* animatingElement, Element& element, const LayoutStyle& style, LayoutStyl e* parentStyle, StyleResolver* resolver) 252 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E lement* animatingElement, Element& element, const LayoutStyle& style, LayoutStyl e* parentStyle, StyleResolver* resolver)
239 { 253 {
240 const ActiveAnimations* activeAnimations = animatingElement ? animatingEleme nt->activeAnimations() : nullptr; 254 const ActiveAnimations* activeAnimations = animatingElement ? animatingEleme nt->activeAnimations() : nullptr;
241 255
256 bool isAnimationStyleChange = activeAnimations && activeAnimations->isAnimat ionStyleChange();
257
242 #if !ENABLE(ASSERT) 258 #if !ENABLE(ASSERT)
243 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state. 259 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state.
244 // When ASSERT is enabled, we verify this optimization. 260 // When ASSERT is enabled, we verify this optimization.
245 if (activeAnimations && activeAnimations->isAnimationStyleChange()) 261 if (isAnimationStyleChange)
246 return; 262 return;
247 #endif 263 #endif
248 264
249 const CSSAnimationData* animationData = style.animations(); 265 const CSSAnimationData* animationData = style.animations();
250 const CSSAnimations* cssAnimations = activeAnimations ? &activeAnimations->c ssAnimations() : nullptr; 266 const CSSAnimations* cssAnimations = activeAnimations ? &activeAnimations->c ssAnimations() : nullptr;
251 const Element* elementForScoping = animatingElement ? animatingElement : &el ement; 267 const Element* elementForScoping = animatingElement ? animatingElement : &el ement;
252 268
253 HashSet<AtomicString> inactive; 269 HashSet<AtomicString> inactive;
254 if (cssAnimations) { 270 if (cssAnimations) {
255 for (const auto& entry : cssAnimations->m_animations) 271 for (const auto& entry : cssAnimations->m_animations)
(...skipping 18 matching lines...) Expand all
274 continue; // Cancel the animation if there's no style rule for i t. 290 continue; // Cancel the animation if there's no style rule for i t.
275 291
276 if (cssAnimations) { 292 if (cssAnimations) {
277 AnimationMap::const_iterator existing(cssAnimations->m_animation s.find(animationName)); 293 AnimationMap::const_iterator existing(cssAnimations->m_animation s.find(animationName));
278 if (existing != cssAnimations->m_animations.end()) { 294 if (existing != cssAnimations->m_animations.end()) {
279 inactive.remove(animationName); 295 inactive.remove(animationName);
280 296
281 const RunningAnimation* runningAnimation = existing->value.g et(); 297 const RunningAnimation* runningAnimation = existing->value.g et();
282 AnimationPlayer* player = runningAnimation->player.get(); 298 AnimationPlayer* player = runningAnimation->player.get();
283 299
284 ASSERT(keyframesRule);
285 if (keyframesRule != runningAnimation->styleRule || keyframe sRule->version() != runningAnimation->styleRuleVersion || runningAnimation->spec ifiedTiming != specifiedTiming) { 300 if (keyframesRule != runningAnimation->styleRule || keyframe sRule->version() != runningAnimation->styleRuleVersion || runningAnimation->spec ifiedTiming != specifiedTiming) {
286 AnimatableValueKeyframeVector resolvedKeyframes; 301 ASSERT(!isAnimationStyleChange);
287 resolveKeyframes(resolver, animatingElement, element, st yle, parentStyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes ); 302 update->updateAnimation(animationName, player, InertAnim ation::create(
288 303 createKeyframeEffect(resolver, animatingElement, ele ment, style, parentStyle, animationName, keyframeTimingFunction.get()),
289 update->updateAnimation(animationName, player, InertAnim ation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes),
290 timing, isPaused, player->currentTimeInternal()), sp ecifiedTiming, keyframesRule); 304 timing, isPaused, player->currentTimeInternal()), sp ecifiedTiming, keyframesRule);
305 } else if (!isAnimationStyleChange && player->source() && pl ayer->source()->isAnimation()) {
306 AnimationEffect* effect = toAnimation(player->source())- >effect();
307 if (effect && effect->isKeyframeEffectModel()) {
308 KeyframeEffectModelBase* keyframeEffect = toKeyframe EffectModelBase(effect);
309 if (keyframeEffect->hasSyntheticKeyframes())
310 update->updateAnimationStyle(player, keyframeEff ect, snapshotCompositableProperties(animatingElement->renderer(), style, effect) );
311 }
291 } 312 }
292 313
293 if (isPaused != player->paused()) { 314 if (isPaused != player->paused()) {
294 ASSERT(!activeAnimations || !activeAnimations->isAnimati onStyleChange()); 315 ASSERT(!isAnimationStyleChange);
295 update->toggleAnimationPaused(animationName); 316 update->toggleAnimationPaused(animationName);
296 } 317 }
297 318
298 continue; 319 continue;
299 } 320 }
300 } 321 }
301 322
302 AnimatableValueKeyframeVector resolvedKeyframes; 323 ASSERT(!isAnimationStyleChange);
303 resolveKeyframes(resolver, animatingElement, element, style, parentS tyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes); 324 update->startAnimation(animationName, InertAnimation::create(
304 if (!resolvedKeyframes.isEmpty()) { 325 createKeyframeEffect(resolver, animatingElement, element, style, parentStyle, animationName, keyframeTimingFunction.get()),
305 ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleC hange()); 326 timing, isPaused, 0), specifiedTiming, keyframesRule);
306 update->startAnimation(animationName, InertAnimation::create(Ani matableValueKeyframeEffectModel::create(resolvedKeyframes), timing, isPaused, 0) , specifiedTiming, keyframesRule);
307 }
308 } 327 }
309 } 328 }
310 329
311 ASSERT(inactive.isEmpty() || cssAnimations); 330 ASSERT(inactive.isEmpty() || cssAnimations);
312 for (const AtomicString& animationName : inactive) { 331 for (const AtomicString& animationName : inactive) {
313 ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange()) ; 332 ASSERT(!isAnimationStyleChange);
314 update->cancelAnimation(animationName, *cssAnimations->m_animations.get( animationName)->player); 333 update->cancelAnimation(animationName, *cssAnimations->m_animations.get( animationName)->player);
315 } 334 }
316 } 335 }
317 336
318 void CSSAnimations::maybeApplyPendingUpdate(Element* element) 337 void CSSAnimations::maybeApplyPendingUpdate(Element* element)
319 { 338 {
320 if (!m_pendingUpdate) { 339 if (!m_pendingUpdate) {
321 m_previousActiveInterpolationsForAnimations.clear(); 340 m_previousActiveInterpolationsForAnimations.clear();
322 return; 341 return;
323 } 342 }
(...skipping 25 matching lines...) Expand all
349 368
350 for (const auto& entry : update->animationsWithUpdates()) { 369 for (const auto& entry : update->animationsWithUpdates()) {
351 Animation* animation = toAnimation(entry.player->source()); 370 Animation* animation = toAnimation(entry.player->source());
352 371
353 animation->setEffect(entry.animation->effect()); 372 animation->setEffect(entry.animation->effect());
354 animation->updateSpecifiedTiming(entry.animation->specifiedTiming()); 373 animation->updateSpecifiedTiming(entry.animation->specifiedTiming());
355 374
356 m_animations.find(entry.name)->value->update(entry); 375 m_animations.find(entry.name)->value->update(entry);
357 } 376 }
358 377
378 for (const auto& styleUpdate : update->animationsWithStyleUpdates()) {
379 styleUpdate.effect->forEachInterpolation([](Interpolation& interpolation ) {
380 if (interpolation.isStyleInterpolation() && toStyleInterpolation(int erpolation).isDeferredLegacyStyleInterpolation())
381 toDeferredLegacyStyleInterpolation(toStyleInterpolation(interpol ation)).underlyingStyleChanged();
382 });
383
384 if (styleUpdate.snapshot.opacity || styleUpdate.snapshot.transform || st yleUpdate.snapshot.webkitFilter) {
385 styleUpdate.effect->updateNeutralKeyframeAnimatableValues(CSSPropert yOpacity, styleUpdate.snapshot.opacity);
386 styleUpdate.effect->updateNeutralKeyframeAnimatableValues(CSSPropert yTransform, styleUpdate.snapshot.transform);
387 styleUpdate.effect->updateNeutralKeyframeAnimatableValues(CSSPropert yWebkitFilter, styleUpdate.snapshot.webkitFilter);
388 styleUpdate.player->setOutdated();
389 styleUpdate.player->setCompositorPending(true);
390 }
391 }
392
359 for (const auto& entry : update->newAnimations()) { 393 for (const auto& entry : update->newAnimations()) {
360 const InertAnimation* inertAnimation = entry.animation.get(); 394 const InertAnimation* inertAnimation = entry.animation.get();
361 OwnPtrWillBeRawPtr<AnimationEventDelegate> eventDelegate = adoptPtrWillB eNoop(new AnimationEventDelegate(element, entry.name)); 395 OwnPtrWillBeRawPtr<AnimationEventDelegate> eventDelegate = adoptPtrWillB eNoop(new AnimationEventDelegate(element, entry.name));
362 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, ine rtAnimation->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPrio rity, eventDelegate.release()); 396 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, ine rtAnimation->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPrio rity, eventDelegate.release());
363 animation->setName(inertAnimation->name()); 397 animation->setName(inertAnimation->name());
364 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin e().play(animation.get()); 398 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin e().play(animation.get());
365 if (inertAnimation->paused()) 399 if (inertAnimation->paused())
366 player->pause(); 400 player->pause();
367 player->update(TimingUpdateOnDemand); 401 player->update(TimingUpdateOnDemand);
368 402
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 visitor->trace(m_newTransitions); 831 visitor->trace(m_newTransitions);
798 visitor->trace(m_activeInterpolationsForAnimations); 832 visitor->trace(m_activeInterpolationsForAnimations);
799 visitor->trace(m_activeInterpolationsForTransitions); 833 visitor->trace(m_activeInterpolationsForTransitions);
800 visitor->trace(m_newAnimations); 834 visitor->trace(m_newAnimations);
801 visitor->trace(m_suppressedAnimationPlayers); 835 visitor->trace(m_suppressedAnimationPlayers);
802 visitor->trace(m_animationsWithUpdates); 836 visitor->trace(m_animationsWithUpdates);
803 #endif 837 #endif
804 } 838 }
805 839
806 } // namespace blink 840 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698