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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "public/platform/Platform.h" 59 #include "public/platform/Platform.h"
60 #include "wtf/BitArray.h" 60 #include "wtf/BitArray.h"
61 #include "wtf/HashSet.h" 61 #include "wtf/HashSet.h"
62 62
63 namespace blink { 63 namespace blink {
64 64
65 using PropertySet = HashSet<CSSPropertyID>; 65 using PropertySet = HashSet<CSSPropertyID>;
66 66
67 namespace { 67 namespace {
68 68
69 static PassRefPtrWillBeRawPtr<StringKeyframeEffectModel> createKeyframeEffect(St yleResolver* resolver, const Element* animatingElement, Element& element, const ComputedStyle* style, const ComputedStyle* parentStyle, const AtomicString& name , TimingFunction* defaultTimingFunction) 69 static StringKeyframeEffectModel* createKeyframeEffect(StyleResolver* resolver, const Element* animatingElement, Element& element, const ComputedStyle* style, c onst ComputedStyle* parentStyle, const AtomicString& name, TimingFunction* defau ltTimingFunction)
70 { 70 {
71 // When the animating element is null, use its parent for scoping purposes. 71 // When the animating element is null, use its parent for scoping purposes.
72 const Element* elementForScoping = animatingElement ? animatingElement : &el ement; 72 const Element* elementForScoping = animatingElement ? animatingElement : &el ement;
73 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen tForScoping, name); 73 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen tForScoping, name);
74 ASSERT(keyframesRule); 74 ASSERT(keyframesRule);
75 75
76 StringKeyframeVector keyframes; 76 StringKeyframeVector keyframes;
77 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe s = keyframesRule->keyframes(); 77 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe s = keyframesRule->keyframes();
78 78
79 // Construct and populate the style for each keyframe 79 // Construct and populate the style for each keyframe
80 PropertySet specifiedPropertiesForUseCounter; 80 PropertySet specifiedPropertiesForUseCounter;
81 for (size_t i = 0; i < styleKeyframes.size(); ++i) { 81 for (size_t i = 0; i < styleKeyframes.size(); ++i) {
82 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get(); 82 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get();
83 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); 83 StringKeyframe* keyframe = StringKeyframe::create();
84 const Vector<double>& offsets = styleKeyframe->keys(); 84 const Vector<double>& offsets = styleKeyframe->keys();
85 ASSERT(!offsets.isEmpty()); 85 ASSERT(!offsets.isEmpty());
86 keyframe->setOffset(offsets[0]); 86 keyframe->setOffset(offsets[0]);
87 keyframe->setEasing(defaultTimingFunction); 87 keyframe->setEasing(defaultTimingFunction);
88 const StylePropertySet& properties = styleKeyframe->properties(); 88 const StylePropertySet& properties = styleKeyframe->properties();
89 for (unsigned j = 0; j < properties.propertyCount(); j++) { 89 for (unsigned j = 0; j < properties.propertyCount(); j++) {
90 CSSPropertyID property = properties.propertyAt(j).id(); 90 CSSPropertyID property = properties.propertyAt(j).id();
91 specifiedPropertiesForUseCounter.add(property); 91 specifiedPropertiesForUseCounter.add(property);
92 if (property == CSSPropertyAnimationTimingFunction) { 92 if (property == CSSPropertyAnimationTimingFunction) {
93 CSSValue* value = properties.propertyAt(j).value(); 93 CSSValue* value = properties.propertyAt(j).value();
94 RefPtr<TimingFunction> timingFunction; 94 RefPtr<TimingFunction> timingFunction;
95 if (value->isInheritedValue() && parentStyle->animations()) { 95 if (value->isInheritedValue() && parentStyle->animations()) {
96 timingFunction = parentStyle->animations()->timingFunctionLi st()[0]; 96 timingFunction = parentStyle->animations()->timingFunctionLi st()[0];
97 } else if (value->isValueList()) { 97 } else if (value->isValueList()) {
98 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t oCSSValueList(value)->item(0)); 98 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t oCSSValueList(value)->item(0));
99 } else { 99 } else {
100 ASSERT(value->isInheritedValue() || value->isInitialValue() || value->isUnsetValue()); 100 ASSERT(value->isInheritedValue() || value->isInitialValue() || value->isUnsetValue());
101 timingFunction = CSSTimingData::initialTimingFunction(); 101 timingFunction = CSSTimingData::initialTimingFunction();
102 } 102 }
103 keyframe->setEasing(timingFunction.release()); 103 keyframe->setEasing(timingFunction.release());
104 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) { 104 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) {
105 keyframe->setPropertyValue(property, properties.propertyAt(j).va lue()); 105 keyframe->setPropertyValue(property, properties.propertyAt(j).va lue());
106 } 106 }
107 } 107 }
108 keyframes.append(keyframe); 108 keyframes.append(keyframe);
109 // The last keyframe specified at a given offset is used. 109 // The last keyframe specified at a given offset is used.
110 for (size_t j = 1; j < offsets.size(); ++j) { 110 for (size_t j = 1; j < offsets.size(); ++j) {
111 keyframes.append(toStringKeyframe(keyframe->cloneWithOffset(offsets[ j]).get())); 111 keyframes.append(toStringKeyframe(keyframe->cloneWithOffset(offsets[ j])));
112 } 112 }
113 } 113 }
114 114
115 for (CSSPropertyID property : specifiedPropertiesForUseCounter) { 115 for (CSSPropertyID property : specifiedPropertiesForUseCounter) {
116 ASSERT(property != CSSPropertyInvalid); 116 ASSERT(property != CSSPropertyInvalid);
117 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property)); 117 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property));
118 } 118 }
119 119
120 // Merge duplicate keyframes. 120 // Merge duplicate keyframes.
121 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s); 121 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s);
122 size_t targetIndex = 0; 122 size_t targetIndex = 0;
123 for (size_t i = 1; i < keyframes.size(); i++) { 123 for (size_t i = 1; i < keyframes.size(); i++) {
124 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) { 124 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) {
125 for (const auto& property : keyframes[i]->properties()) 125 for (const auto& property : keyframes[i]->properties())
126 keyframes[targetIndex]->setPropertyValue(property.cssProperty(), keyframes[i]->cssPropertyValue(property.cssProperty())); 126 keyframes[targetIndex]->setPropertyValue(property.cssProperty(), keyframes[i]->cssPropertyValue(property.cssProperty()));
127 } else { 127 } else {
128 targetIndex++; 128 targetIndex++;
129 keyframes[targetIndex] = keyframes[i]; 129 keyframes[targetIndex] = keyframes[i];
130 } 130 }
131 } 131 }
132 if (!keyframes.isEmpty()) 132 if (!keyframes.isEmpty())
133 keyframes.shrink(targetIndex + 1); 133 keyframes.shrink(targetIndex + 1);
134 134
135 // Add 0% and 100% keyframes if absent. 135 // Add 0% and 100% keyframes if absent.
136 RefPtrWillBeRawPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nul lptr : keyframes[0]; 136 StringKeyframe* startKeyframe = keyframes.isEmpty() ? nullptr : keyframes[0] ;
137 if (!startKeyframe || keyframes[0]->offset() != 0) { 137 if (!startKeyframe || keyframes[0]->offset() != 0) {
138 startKeyframe = StringKeyframe::create(); 138 startKeyframe = StringKeyframe::create();
139 startKeyframe->setOffset(0); 139 startKeyframe->setOffset(0);
140 startKeyframe->setEasing(defaultTimingFunction); 140 startKeyframe->setEasing(defaultTimingFunction);
141 keyframes.prepend(startKeyframe); 141 keyframes.prepend(startKeyframe);
142 } 142 }
143 RefPtrWillBeRawPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size() - 1]; 143 StringKeyframe* endKeyframe = keyframes[keyframes.size() - 1];
144 if (endKeyframe->offset() != 1) { 144 if (endKeyframe->offset() != 1) {
145 endKeyframe = StringKeyframe::create(); 145 endKeyframe = StringKeyframe::create();
146 endKeyframe->setOffset(1); 146 endKeyframe->setOffset(1);
147 endKeyframe->setEasing(defaultTimingFunction); 147 endKeyframe->setEasing(defaultTimingFunction);
148 keyframes.append(endKeyframe); 148 keyframes.append(endKeyframe);
149 } 149 }
150 ASSERT(keyframes.size() >= 2); 150 ASSERT(keyframes.size() >= 2);
151 ASSERT(!keyframes.first()->offset()); 151 ASSERT(!keyframes.first()->offset());
152 ASSERT(keyframes.last()->offset() == 1); 152 ASSERT(keyframes.last()->offset() == 1);
153 153
(...skipping 11 matching lines...) Expand all
165 for (CSSPropertyID property : allProperties) { 165 for (CSSPropertyID property : allProperties) {
166 bool startNeedsValue = missingStartValues && !startKeyframePropertie s.contains(PropertyHandle(property)); 166 bool startNeedsValue = missingStartValues && !startKeyframePropertie s.contains(PropertyHandle(property));
167 bool endNeedsValue = missingEndValues && !endKeyframeProperties.cont ains(PropertyHandle(property)); 167 bool endNeedsValue = missingEndValues && !endKeyframeProperties.cont ains(PropertyHandle(property));
168 if (!startNeedsValue && !endNeedsValue) 168 if (!startNeedsValue && !endNeedsValue)
169 continue; 169 continue;
170 if (CompositorAnimations::isCompositableProperty(property)) 170 if (CompositorAnimations::isCompositableProperty(property))
171 UseCounter::count(elementForScoping->document(), UseCounter::Syn theticKeyframesInCompositedCSSAnimation); 171 UseCounter::count(elementForScoping->document(), UseCounter::Syn theticKeyframesInCompositedCSSAnimation);
172 } 172 }
173 } 173 }
174 174
175 RefPtrWillBeRawPtr<StringKeyframeEffectModel> effect = StringKeyframeEffectM odel::create(keyframes, &keyframes[0]->easing()); 175 StringKeyframeEffectModel* effect = StringKeyframeEffectModel::create(keyfra mes, &keyframes[0]->easing());
176 effect->forceConversionsToAnimatableValues(element, style); 176 effect->forceConversionsToAnimatableValues(element, style);
177 return effect; 177 return effect;
178 } 178 }
179 179
180 } // namespace 180 } // namespace
181 181
182 CSSAnimations::CSSAnimations() 182 CSSAnimations::CSSAnimations()
183 { 183 {
184 } 184 }
185 185
186 const AtomicString CSSAnimations::getAnimationNameForInspector(const AnimationPl ayer& player) 186 const AtomicString CSSAnimations::getAnimationNameForInspector(const AnimationPl ayer& player)
187 { 187 {
188 for (const auto& it : m_animations) { 188 for (const auto& it : m_animations) {
189 if (it.value->player->sequenceNumber() == player.sequenceNumber()) 189 if (it.value->player->sequenceNumber() == player.sequenceNumber())
190 return it.key; 190 return it.key;
191 } 191 }
192 return nullAtom; 192 return nullAtom;
193 } 193 }
194 194
195 bool CSSAnimations::isTransitionAnimationForInspector(const AnimationPlayer& pla yer) const 195 bool CSSAnimations::isTransitionAnimationForInspector(const AnimationPlayer& pla yer) const
196 { 196 {
197 for (const auto& it : m_transitions) { 197 for (const auto& it : m_transitions) {
198 if (it.value.player->sequenceNumber() == player.sequenceNumber()) 198 if (it.value.player->sequenceNumber() == player.sequenceNumber())
199 return true; 199 return true;
200 } 200 }
201 return false; 201 return false;
202 } 202 }
203 203
204 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(const Element* animatingElement, Element& element, const ComputedStyle& style, Compute dStyle* parentStyle, StyleResolver* resolver) 204 CSSAnimationUpdate* CSSAnimations::calculateUpdate(const Element* animatingEleme nt, Element& element, const ComputedStyle& style, ComputedStyle* parentStyle, St yleResolver* resolver)
205 { 205 {
206 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAn imationUpdate()); 206 CSSAnimationUpdate* update = new CSSAnimationUpdate();
207 calculateAnimationUpdate(update.get(), animatingElement, element, style, par entStyle, resolver); 207 calculateAnimationUpdate(update, animatingElement, element, style, parentSty le, resolver);
208 calculateAnimationActiveInterpolations(update.get(), animatingElement, eleme nt.document().timeline().currentTimeInternal()); 208 calculateAnimationActiveInterpolations(update, animatingElement, element.doc ument().timeline().currentTimeInternal());
209 calculateTransitionUpdate(update.get(), animatingElement, style); 209 calculateTransitionUpdate(update, animatingElement, style);
210 calculateTransitionActiveInterpolations(update.get(), animatingElement, elem ent.document().timeline().currentTimeInternal()); 210 calculateTransitionActiveInterpolations(update, animatingElement, element.do cument().timeline().currentTimeInternal());
211 return update->isEmpty() ? nullptr : update.release(); 211 return update->isEmpty() ? nullptr : update;
212 } 212 }
213 213
214 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E lement* animatingElement, Element& element, const ComputedStyle& style, Computed Style* parentStyle, StyleResolver* resolver) 214 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E lement* animatingElement, Element& element, const ComputedStyle& style, Computed Style* parentStyle, StyleResolver* resolver)
215 { 215 {
216 const ElementAnimations* elementAnimations = animatingElement ? animatingEle ment->elementAnimations() : nullptr; 216 const ElementAnimations* elementAnimations = animatingElement ? animatingEle ment->elementAnimations() : nullptr;
217 217
218 bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnim ationStyleChange(); 218 bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnim ationStyleChange();
219 219
220 #if !ENABLE(ASSERT) 220 #if !ENABLE(ASSERT)
221 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state. 221 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 } 297 }
298 298
299 void CSSAnimations::maybeApplyPendingUpdate(Element* element) 299 void CSSAnimations::maybeApplyPendingUpdate(Element* element)
300 { 300 {
301 if (!m_pendingUpdate) { 301 if (!m_pendingUpdate) {
302 m_previousActiveInterpolationsForAnimations.clear(); 302 m_previousActiveInterpolationsForAnimations.clear();
303 return; 303 return;
304 } 304 }
305 305
306 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = m_pendingUpdate.release(); 306 CSSAnimationUpdate* update = m_pendingUpdate.release();
307 307
308 m_previousActiveInterpolationsForAnimations.swap(update->activeInterpolation sForAnimations()); 308 m_previousActiveInterpolationsForAnimations.swap(update->activeInterpolation sForAnimations());
309 309
310 // FIXME: cancelling, pausing, unpausing animations all query compositingSta te, which is not necessarily up to date here 310 // FIXME: cancelling, pausing, unpausing animations all query compositingSta te, which is not necessarily up to date here
311 // since we call this from recalc style. 311 // since we call this from recalc style.
312 // https://code.google.com/p/chromium/issues/detail?id=339847 312 // https://code.google.com/p/chromium/issues/detail?id=339847
313 DisableCompositingQueryAsserts disabler; 313 DisableCompositingQueryAsserts disabler;
314 314
315 for (const AtomicString& animationName : update->cancelledAnimationNames()) { 315 for (const AtomicString& animationName : update->cancelledAnimationNames()) {
316 RefPtrWillBeRawPtr<AnimationPlayer> player = m_animations.take(animation Name)->player; 316 RefPtrWillBeRawPtr<AnimationPlayer> player = m_animations.take(animation Name)->player;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (styleUpdate.snapshot.webkitFilter) 351 if (styleUpdate.snapshot.webkitFilter)
352 updated |= styleUpdate.effect->updateNeutralKeyframeAnimatableValues (CSSPropertyWebkitFilter, styleUpdate.snapshot.webkitFilter); 352 updated |= styleUpdate.effect->updateNeutralKeyframeAnimatableValues (CSSPropertyWebkitFilter, styleUpdate.snapshot.webkitFilter);
353 if (updated) { 353 if (updated) {
354 styleUpdate.player->setOutdated(); 354 styleUpdate.player->setOutdated();
355 styleUpdate.player->setCompositorPending(true); 355 styleUpdate.player->setCompositorPending(true);
356 } 356 }
357 } 357 }
358 358
359 for (const auto& entry : update->newAnimations()) { 359 for (const auto& entry : update->newAnimations()) {
360 const InertAnimation* inertAnimation = entry.animation.get(); 360 const InertAnimation* inertAnimation = entry.animation.get();
361 OwnPtrWillBeRawPtr<AnimationEventDelegate> eventDelegate = adoptPtrWillB eNoop(new AnimationEventDelegate(element, entry.name)); 361 AnimationEventDelegate* eventDelegate = new AnimationEventDelegate(eleme nt, entry.name);
362 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, ine rtAnimation->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPrio rity, eventDelegate.release()); 362 Animation* animation = Animation::create(element, inertAnimation->effect (), inertAnimation->specifiedTiming(), Animation::DefaultPriority, eventDelegate );
363 animation->setName(inertAnimation->name()); 363 animation->setName(inertAnimation->name());
364 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin e().play(animation.get()); 364 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin e().play(animation);
365 if (inertAnimation->paused()) 365 if (inertAnimation->paused())
366 player->pause(); 366 player->pause();
367 player->update(TimingUpdateOnDemand); 367 player->update(TimingUpdateOnDemand);
368 368
369 m_animations.set(entry.name, adoptRefWillBeNoop(new RunningAnimation(pla yer, entry))); 369 m_animations.set(entry.name, new RunningAnimation(player, entry));
370 } 370 }
371 371
372 // Transitions that are run on the compositor only update main-thread state 372 // Transitions that are run on the compositor only update main-thread state
373 // lazily. However, we need the new state to know what the from state shoud 373 // lazily. However, we need the new state to know what the from state shoud
374 // be when transitions are retargeted. Instead of triggering complete style 374 // be when transitions are retargeted. Instead of triggering complete style
375 // recalculation, we find these cases by searching for new transitions that 375 // recalculation, we find these cases by searching for new transitions that
376 // have matching cancelled animation property IDs on the compositor. 376 // have matching cancelled animation property IDs on the compositor.
377 WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<Animation>, do uble>> retargetedCompositorTransitions; 377 WillBeHeapHashMap<CSSPropertyID, std::pair<Member<Animation>, double>> retar getedCompositorTransitions;
378 for (CSSPropertyID id : update->cancelledTransitions()) { 378 for (CSSPropertyID id : update->cancelledTransitions()) {
379 ASSERT(m_transitions.contains(id)); 379 ASSERT(m_transitions.contains(id));
380 380
381 RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id).play er; 381 RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id).play er;
382 Animation* animation = toAnimation(player->source()); 382 Animation* animation = toAnimation(player->source());
383 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit ions().find(id) != update->newTransitions().end() && !player->limited()) 383 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit ions().find(id) != update->newTransitions().end() && !player->limited())
384 retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember <Animation>, double>(animation, player->startTimeInternal())); 384 retargetedCompositorTransitions.add(id, std::pair<Member<Animation>, double>(animation, player->startTimeInternal()));
385 player->cancel(); 385 player->cancel();
386 // after cancelation, transitions must be downgraded or they'll fail 386 // after cancelation, transitions must be downgraded or they'll fail
387 // to be considered when retriggering themselves. This can happen if 387 // to be considered when retriggering themselves. This can happen if
388 // the transition is captured through getAnimationPlayers then played. 388 // the transition is captured through getAnimationPlayers then played.
389 if (player->source() && player->source()->isAnimation()) 389 if (player->source() && player->source()->isAnimation())
390 toAnimation(player->source())->downgradeToNormalAnimation(); 390 toAnimation(player->source())->downgradeToNormalAnimation();
391 player->update(TimingUpdateOnDemand); 391 player->update(TimingUpdateOnDemand);
392 } 392 }
393 393
394 for (CSSPropertyID id : update->finishedTransitions()) { 394 for (CSSPropertyID id : update->finishedTransitions()) {
395 // This transition can also be cancelled and finished at the same time 395 // This transition can also be cancelled and finished at the same time
396 if (m_transitions.contains(id)) { 396 if (m_transitions.contains(id)) {
397 RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id). player; 397 RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id). player;
398 // Transition must be downgraded 398 // Transition must be downgraded
399 if (player->source() && player->source()->isAnimation()) 399 if (player->source() && player->source()->isAnimation())
400 toAnimation(player->source())->downgradeToNormalAnimation(); 400 toAnimation(player->source())->downgradeToNormalAnimation();
401 } 401 }
402 } 402 }
403 403
404 for (const auto& entry : update->newTransitions()) { 404 for (const auto& entry : update->newTransitions()) {
405 const CSSAnimationUpdate::NewTransition& newTransition = entry.value; 405 const CSSAnimationUpdate::NewTransition& newTransition = entry.value;
406 406
407 RunningTransition runningTransition; 407 RunningTransition runningTransition;
408 runningTransition.from = newTransition.from; 408 runningTransition.from = newTransition.from;
409 runningTransition.to = newTransition.to; 409 runningTransition.to = newTransition.to;
410 410
411 CSSPropertyID id = newTransition.id; 411 CSSPropertyID id = newTransition.id;
412 InertAnimation* inertAnimation = newTransition.animation.get(); 412 InertAnimation* inertAnimation = newTransition.animation.get();
413 OwnPtrWillBeRawPtr<TransitionEventDelegate> eventDelegate = adoptPtrWill BeNoop(new TransitionEventDelegate(element, newTransition.eventId)); 413 TransitionEventDelegate* eventDelegate = new TransitionEventDelegate(ele ment, newTransition.eventId);
414 414
415 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); 415 AnimationEffect* effect = inertAnimation->effect();
416 416
417 if (retargetedCompositorTransitions.contains(id)) { 417 if (retargetedCompositorTransitions.contains(id)) {
418 const std::pair<RefPtrWillBeMember<Animation>, double>& oldTransitio n = retargetedCompositorTransitions.get(id); 418 const std::pair<Member<Animation>, double>& oldTransition = retarget edCompositorTransitions.get(id);
419 RefPtrWillBeRawPtr<Animation> oldAnimation = oldTransition.first; 419 Animation* oldAnimation = oldTransition.first;
420 double oldStartTime = oldTransition.second; 420 double oldStartTime = oldTransition.second;
421 double inheritedTime = isNull(oldStartTime) ? 0 : element->document( ).timeline().currentTimeInternal() - oldStartTime; 421 double inheritedTime = isNull(oldStartTime) ? 0 : element->document( ).timeline().currentTimeInternal() - oldStartTime;
422 422
423 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey frameEffectModel(inertAnimation->effect()); 423 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey frameEffectModel(inertAnimation->effect());
424 const KeyframeVector& frames = oldEffect->getFrames(); 424 const KeyframeVector& frames = oldEffect->getFrames();
425 425
426 AnimatableValueKeyframeVector newFrames; 426 AnimatableValueKeyframeVector newFrames;
427 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get()) ); 427 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone()));
428 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get()) ); 428 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone()));
429 newFrames.append(toAnimatableValueKeyframe(frames[2]->clone().get()) ); 429 newFrames.append(toAnimatableValueKeyframe(frames[2]->clone()));
430 newFrames[0]->clearPropertyValue(id); 430 newFrames[0]->clearPropertyValue(id);
431 newFrames[1]->clearPropertyValue(id); 431 newFrames[1]->clearPropertyValue(id);
432 432
433 RefPtrWillBeRawPtr<InertAnimation> inertAnimationForSampling = Inert Animation::create(oldAnimation->effect(), oldAnimation->specifiedTiming(), false , inheritedTime); 433 InertAnimation* inertAnimationForSampling = InertAnimation::create(o ldAnimation->effect(), oldAnimation->specifiedTiming(), false, inheritedTime);
434 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation >>> sample = nullptr; 434 HeapVector<Member<Interpolation>>* sample = nullptr;
435 inertAnimationForSampling->sample(sample); 435 inertAnimationForSampling->sample(sample);
436 if (sample && sample->size() == 1) { 436 if (sample && sample->size() == 1) {
437 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sa mple->at(0).get())->currentValue()); 437 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sa mple->at(0).get())->currentValue());
438 newFrames[1]->setPropertyValue(id, toLegacyStyleInterpolation(sa mple->at(0).get())->currentValue()); 438 newFrames[1]->setPropertyValue(id, toLegacyStyleInterpolation(sa mple->at(0).get())->currentValue());
439 effect = AnimatableValueKeyframeEffectModel::create(newFrames); 439 effect = AnimatableValueKeyframeEffectModel::create(newFrames);
440 } 440 }
441 } 441 }
442 442
443 RefPtrWillBeRawPtr<Animation> transition = Animation::create(element, ef fect, inertAnimation->specifiedTiming(), Animation::TransitionPriority, eventDel egate.release()); 443 Animation* transition = Animation::create(element, effect, inertAnimatio n->specifiedTiming(), Animation::TransitionPriority, eventDelegate);
444 transition->setName(inertAnimation->name()); 444 transition->setName(inertAnimation->name());
445 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin e().play(transition.get()); 445 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin e().play(transition);
446 player->update(TimingUpdateOnDemand); 446 player->update(TimingUpdateOnDemand);
447 runningTransition.player = player; 447 runningTransition.player = player;
448 m_transitions.set(id, runningTransition); 448 m_transitions.set(id, runningTransition);
449 ASSERT(id != CSSPropertyInvalid); 449 ASSERT(id != CSSPropertyInvalid);
450 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); 450 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id));
451 } 451 }
452 } 452 }
453 453
454 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, CSSPr opertyID eventId, const CSSTransitionData& transitionData, size_t transitionInde x, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMa p* activeTransitions, CSSAnimationUpdate* update, const Element* element) 454 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, CSSPr opertyID eventId, const CSSTransitionData& transitionData, size_t transitionInde x, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMa p* activeTransitions, CSSAnimationUpdate* update, const Element* element)
455 { 455 {
456 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; 456 AnimatableValue* to = nullptr;
457 if (activeTransitions) { 457 if (activeTransitions) {
458 TransitionMap::const_iterator activeTransitionIter = activeTransitions-> find(id); 458 TransitionMap::const_iterator activeTransitionIter = activeTransitions-> find(id);
459 if (activeTransitionIter != activeTransitions->end()) { 459 if (activeTransitionIter != activeTransitions->end()) {
460 to = CSSAnimatableValueFactory::create(id, style); 460 to = CSSAnimatableValueFactory::create(id, style);
461 const AnimatableValue* activeTo = activeTransitionIter->value.to; 461 const AnimatableValue* activeTo = activeTransitionIter->value.to;
462 if (to->equals(activeTo)) 462 if (to->equals(activeTo))
463 return; 463 return;
464 update->cancelTransition(id); 464 update->cancelTransition(id);
465 ASSERT(!element->elementAnimations() || !element->elementAnimations( )->isAnimationStyleChange()); 465 ASSERT(!element->elementAnimations() || !element->elementAnimations( )->isAnimationStyleChange());
466 } 466 }
467 } 467 }
468 468
469 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) 469 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style))
470 return; 470 return;
471 if (!to) 471 if (!to)
472 to = CSSAnimatableValueFactory::create(id, style); 472 to = CSSAnimatableValueFactory::create(id, style);
473 473
474 RefPtrWillBeRawPtr<AnimatableValue> from = CSSAnimatableValueFactory::create (id, oldStyle); 474 AnimatableValue* from = CSSAnimatableValueFactory::create(id, oldStyle);
475 // If we have multiple transitions on the same property, we will use the 475 // If we have multiple transitions on the same property, we will use the
476 // last one since we iterate over them in order. 476 // last one since we iterate over them in order.
477 if (AnimatableValue::usesDefaultInterpolation(to.get(), from.get())) 477 if (AnimatableValue::usesDefaultInterpolation(to, from))
478 return; 478 return;
479 479
480 Timing timing = transitionData.convertToTiming(transitionIndex); 480 Timing timing = transitionData.convertToTiming(transitionIndex);
481 if (timing.startDelay + timing.iterationDuration <= 0) 481 if (timing.startDelay + timing.iterationDuration <= 0)
482 return; 482 return;
483 483
484 AnimatableValueKeyframeVector keyframes; 484 AnimatableValueKeyframeVector keyframes;
485 double startKeyframeOffset = 0; 485 double startKeyframeOffset = 0;
486 486
487 if (timing.startDelay > 0) { 487 if (timing.startDelay > 0) {
488 timing.iterationDuration += timing.startDelay; 488 timing.iterationDuration += timing.startDelay;
489 startKeyframeOffset = timing.startDelay / timing.iterationDuration; 489 startKeyframeOffset = timing.startDelay / timing.iterationDuration;
490 timing.startDelay = 0; 490 timing.startDelay = 0;
491 } 491 }
492 492
493 RefPtrWillBeRawPtr<AnimatableValueKeyframe> delayKeyframe = AnimatableValueK eyframe::create(); 493 AnimatableValueKeyframe* delayKeyframe = AnimatableValueKeyframe::create();
494 delayKeyframe->setPropertyValue(id, from.get()); 494 delayKeyframe->setPropertyValue(id, from);
495 delayKeyframe->setOffset(0); 495 delayKeyframe->setOffset(0);
496 keyframes.append(delayKeyframe); 496 keyframes.append(delayKeyframe);
497 497
498 RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueK eyframe::create(); 498 AnimatableValueKeyframe* startKeyframe = AnimatableValueKeyframe::create();
499 startKeyframe->setPropertyValue(id, from.get()); 499 startKeyframe->setPropertyValue(id, from);
500 startKeyframe->setOffset(startKeyframeOffset); 500 startKeyframe->setOffset(startKeyframeOffset);
501 startKeyframe->setEasing(timing.timingFunction.release()); 501 startKeyframe->setEasing(timing.timingFunction.release());
502 timing.timingFunction = LinearTimingFunction::shared(); 502 timing.timingFunction = LinearTimingFunction::shared();
503 keyframes.append(startKeyframe); 503 keyframes.append(startKeyframe);
504 504
505 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey frame::create(); 505 AnimatableValueKeyframe* endKeyframe = AnimatableValueKeyframe::create();
506 endKeyframe->setPropertyValue(id, to.get()); 506 endKeyframe->setPropertyValue(id, to);
507 endKeyframe->setOffset(1); 507 endKeyframe->setOffset(1);
508 keyframes.append(endKeyframe); 508 keyframes.append(endKeyframe);
509 509
510 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes); 510 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(keyframes);
511 update->startTransition(id, eventId, from.get(), to.get(), InertAnimation::c reate(effect, timing, false, 0)); 511 update->startTransition(id, eventId, from, to, InertAnimation::create(effect , timing, false, 0));
512 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni mationStyleChange()); 512 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni mationStyleChange());
513 } 513 }
514 514
515 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const Element* animatingElement, const ComputedStyle& style) 515 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const Element* animatingElement, const ComputedStyle& style)
516 { 516 {
517 if (!animatingElement) 517 if (!animatingElement)
518 return; 518 return;
519 519
520 ElementAnimations* elementAnimations = animatingElement->elementAnimations() ; 520 ElementAnimations* elementAnimations = animatingElement->elementAnimations() ;
521 const TransitionMap* activeTransitions = elementAnimations ? &elementAnimati ons->cssAnimations().m_transitions : nullptr; 521 const TransitionMap* activeTransitions = elementAnimations ? &elementAnimati ons->cssAnimations().m_transitions : nullptr;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 { 605 {
606 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr; 606 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr;
607 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr; 607 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr;
608 608
609 if (update->newAnimations().isEmpty() && update->suppressedAnimationAnimatio nPlayers().isEmpty()) { 609 if (update->newAnimations().isEmpty() && update->suppressedAnimationAnimatio nPlayers().isEmpty()) {
610 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack: :activeInterpolations(animationStack, 0, 0, Animation::DefaultPriority, timeline CurrentTime)); 610 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack: :activeInterpolations(animationStack, 0, 0, Animation::DefaultPriority, timeline CurrentTime));
611 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn imations); 611 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn imations);
612 return; 612 return;
613 } 613 }
614 614
615 WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newAnimations; 615 HeapVector<Member<InertAnimation>> newAnimations;
616 for (const auto& newAnimation : update->newAnimations()) 616 for (const auto& newAnimation : update->newAnimations())
617 newAnimations.append(newAnimation.animation.get()); 617 newAnimations.append(newAnimation.animation.get());
618 for (const auto& updatedAnimation : update->animationsWithUpdates()) 618 for (const auto& updatedAnimation : update->animationsWithUpdates())
619 newAnimations.append(updatedAnimation.animation.get()); // Animations wi th updates use a temporary InertAnimation for the current frame. 619 newAnimations.append(updatedAnimation.animation.get()); // Animations wi th updates use a temporary InertAnimation for the current frame.
620 620
621 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::act iveInterpolations(animationStack, &newAnimations, &update->suppressedAnimationAn imationPlayers(), Animation::DefaultPriority, timelineCurrentTime)); 621 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::act iveInterpolations(animationStack, &newAnimations, &update->suppressedAnimationAn imationPlayers(), Animation::DefaultPriority, timelineCurrentTime));
622 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat ions); 622 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat ions);
623 } 623 }
624 624
625 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* animatingElement, double timelineCurrentTime) 625 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* animatingElement, double timelineCurrentTime)
626 { 626 {
627 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr; 627 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr;
628 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr; 628 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr;
629 629
630 ActiveInterpolationMap activeInterpolationsForTransitions; 630 ActiveInterpolationMap activeInterpolationsForTransitions;
631 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE mpty()) { 631 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE mpty()) {
632 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); 632 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime);
633 } else { 633 } else {
634 WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newTransitions; 634 HeapVector<Member<InertAnimation>> newTransitions;
635 for (const auto& entry : update->newTransitions()) 635 for (const auto& entry : update->newTransitions())
636 newTransitions.append(entry.value.animation.get()); 636 newTransitions.append(entry.value.animation.get());
637 637
638 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAn imationPlayers; 638 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAn imationPlayers;
639 if (!update->cancelledTransitions().isEmpty()) { 639 if (!update->cancelledTransitions().isEmpty()) {
640 ASSERT(elementAnimations); 640 ASSERT(elementAnimations);
641 const TransitionMap& transitionMap = elementAnimations->cssAnimation s().m_transitions; 641 const TransitionMap& transitionMap = elementAnimations->cssAnimation s().m_transitions;
642 for (CSSPropertyID id : update->cancelledTransitions()) { 642 for (CSSPropertyID id : update->cancelledTransitions()) {
643 ASSERT(transitionMap.contains(id)); 643 ASSERT(transitionMap.contains(id));
644 cancelledAnimationPlayers.add(transitionMap.get(id).player.get() ); 644 cancelledAnimationPlayers.add(transitionMap.get(id).player.get() );
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 case CSSPropertyTransitionProperty: 782 case CSSPropertyTransitionProperty:
783 case CSSPropertyTransitionTimingFunction: 783 case CSSPropertyTransitionTimingFunction:
784 return false; 784 return false;
785 default: 785 default:
786 return true; 786 return true;
787 } 787 }
788 } 788 }
789 789
790 DEFINE_TRACE(CSSAnimations) 790 DEFINE_TRACE(CSSAnimations)
791 { 791 {
792 #if ENABLE(OILPAN)
793 visitor->trace(m_transitions); 792 visitor->trace(m_transitions);
794 visitor->trace(m_pendingUpdate); 793 visitor->trace(m_pendingUpdate);
795 visitor->trace(m_animations); 794 visitor->trace(m_animations);
796 visitor->trace(m_previousActiveInterpolationsForAnimations); 795 visitor->trace(m_previousActiveInterpolationsForAnimations);
797 #endif
798 } 796 }
799 797
800 DEFINE_TRACE(CSSAnimationUpdate) 798 DEFINE_TRACE(CSSAnimationUpdate)
801 { 799 {
802 #if ENABLE(OILPAN)
803 visitor->trace(m_newTransitions); 800 visitor->trace(m_newTransitions);
804 visitor->trace(m_activeInterpolationsForAnimations); 801 visitor->trace(m_activeInterpolationsForAnimations);
805 visitor->trace(m_activeInterpolationsForTransitions); 802 visitor->trace(m_activeInterpolationsForTransitions);
806 visitor->trace(m_newAnimations); 803 visitor->trace(m_newAnimations);
807 visitor->trace(m_suppressedAnimationPlayers);
808 visitor->trace(m_animationsWithUpdates); 804 visitor->trace(m_animationsWithUpdates);
809 visitor->trace(m_animationsWithStyleUpdates); 805 visitor->trace(m_animationsWithStyleUpdates);
806 #if ENABLE(OILPAN)
807 visitor->trace(m_suppressedAnimationPlayers);
810 #endif 808 #endif
811 } 809 }
812 810
813 } // namespace blink 811 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698