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

Side by Side Diff: Source/core/page/animation/CompositeAnimation.cpp

Issue 14391005: Rename Animation -> PrimitiveAnimation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update to long paths Created 7 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // in the next loop and then toss the ones that didn't get marked. 82 // in the next loop and then toss the ones that didn't get marked.
83 CSSPropertyTransitionsMap::const_iterator end = m_transitions.end(); 83 CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
84 for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); i t != end; ++it) 84 for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); i t != end; ++it)
85 it->value->setActive(false); 85 it->value->setActive(false);
86 86
87 RefPtr<RenderStyle> modifiedCurrentStyle; 87 RefPtr<RenderStyle> modifiedCurrentStyle;
88 88
89 // Check to see if we need to update the active transitions 89 // Check to see if we need to update the active transitions
90 if (targetStyle->transitions()) { 90 if (targetStyle->transitions()) {
91 for (size_t i = 0; i < targetStyle->transitions()->size(); ++i) { 91 for (size_t i = 0; i < targetStyle->transitions()->size(); ++i) {
92 const Animation* anim = targetStyle->transitions()->animation(i); 92 const CSSAnimationData* anim = targetStyle->transitions()->animation (i);
93 bool isActiveTransition = anim->duration() || anim->delay() > 0; 93 bool isActiveTransition = anim->duration() || anim->delay() > 0;
94 94
95 Animation::AnimationMode mode = anim->animationMode(); 95 CSSAnimationData::AnimationMode mode = anim->animationMode();
96 if (mode == Animation::AnimateNone) 96 if (mode == CSSAnimationData::AnimateNone)
97 continue; 97 continue;
98 98
99 CSSPropertyID prop = anim->property(); 99 CSSPropertyID prop = anim->property();
100 100
101 bool all = mode == Animation::AnimateAll; 101 bool all = mode == CSSAnimationData::AnimateAll;
102 102
103 // Handle both the 'all' and single property cases. For the single p rop case, we make only one pass 103 // Handle both the 'all' and single property cases. For the single p rop case, we make only one pass
104 // through the loop. 104 // through the loop.
105 for (int propertyIndex = 0; propertyIndex < CSSPropertyAnimation::ge tNumProperties(); ++propertyIndex) { 105 for (int propertyIndex = 0; propertyIndex < CSSPropertyAnimation::ge tNumProperties(); ++propertyIndex) {
106 if (all) { 106 if (all) {
107 // Get the next property which is not a shorthand. 107 // Get the next property which is not a shorthand.
108 bool isShorthand; 108 bool isShorthand;
109 prop = CSSPropertyAnimation::getPropertyAtIndex(propertyInde x, isShorthand); 109 prop = CSSPropertyAnimation::getPropertyAtIndex(propertyInde x, isShorthand);
110 if (isShorthand) 110 if (isShorthand)
111 continue; 111 continue;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // We need to start a transition if it is active and the pro perties don't match 156 // We need to start a transition if it is active and the pro perties don't match
157 equal = !isActiveTransition || CSSPropertyAnimation::propert iesEqual(prop, fromStyle, targetStyle); 157 equal = !isActiveTransition || CSSPropertyAnimation::propert iesEqual(prop, fromStyle, targetStyle);
158 } 158 }
159 159
160 // We can be in this loop with an inactive transition (!isActive Transition). We need 160 // We can be in this loop with an inactive transition (!isActive Transition). We need
161 // to do that to check to see if we are canceling a transition. But we don't want to 161 // to do that to check to see if we are canceling a transition. But we don't want to
162 // start one of the inactive transitions. So short circuit that here. (See 162 // start one of the inactive transitions. So short circuit that here. (See
163 // <https://bugs.webkit.org/show_bug.cgi?id=24787> 163 // <https://bugs.webkit.org/show_bug.cgi?id=24787>
164 if (!equal && isActiveTransition) { 164 if (!equal && isActiveTransition) {
165 // Add the new transition 165 // Add the new transition
166 m_transitions.set(prop, ImplicitAnimation::create(const_cast <Animation*>(anim), prop, renderer, this, modifiedCurrentStyle ? modifiedCurrent Style.get() : fromStyle)); 166 m_transitions.set(prop, ImplicitAnimation::create(const_cast <CSSAnimationData*>(anim), prop, renderer, this, modifiedCurrentStyle ? modified CurrentStyle.get() : fromStyle));
167 } 167 }
168 168
169 // We only need one pass for the single prop case 169 // We only need one pass for the single prop case
170 if (!all) 170 if (!all)
171 break; 171 break;
172 } 172 }
173 } 173 }
174 } 174 }
175 175
176 // Make a list of transitions to be removed 176 // Make a list of transitions to be removed
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 // Toss the animation order map. 214 // Toss the animation order map.
215 m_keyframeAnimationOrderMap.clear(); 215 m_keyframeAnimationOrderMap.clear();
216 216
217 DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::Con structFromLiteral)); 217 DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::Con structFromLiteral));
218 218
219 // Now mark any still active animations as active and add any new animat ions. 219 // Now mark any still active animations as active and add any new animat ions.
220 if (targetStyle->animations()) { 220 if (targetStyle->animations()) {
221 int numAnims = targetStyle->animations()->size(); 221 int numAnims = targetStyle->animations()->size();
222 for (int i = 0; i < numAnims; ++i) { 222 for (int i = 0; i < numAnims; ++i) {
223 const Animation* anim = targetStyle->animations()->animation(i); 223 const CSSAnimationData* anim = targetStyle->animations()->animat ion(i);
224 AtomicString animationName(anim->name()); 224 AtomicString animationName(anim->name());
225 225
226 if (!anim->isValidAnimation()) 226 if (!anim->isValidAnimation())
227 continue; 227 continue;
228 228
229 // See if there is a current animation for this name. 229 // See if there is a current animation for this name.
230 RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.ge t(animationName.impl()); 230 RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.ge t(animationName.impl());
231 231
232 if (keyframeAnim) { 232 if (keyframeAnim) {
233 // If this animation is postActive, skip it so it gets remov ed at the end of this function. 233 // If this animation is postActive, skip it so it gets remov ed at the end of this function.
234 if (keyframeAnim->postActive()) 234 if (keyframeAnim->postActive())
235 continue; 235 continue;
236 236
237 // This one is still active. 237 // This one is still active.
238 238
239 // Animations match, but play states may differ. Update if n eeded. 239 // Animations match, but play states may differ. Update if n eeded.
240 keyframeAnim->updatePlayState(anim->playState()); 240 keyframeAnim->updatePlayState(anim->playState());
241 241
242 // Set the saved animation to this new one, just in case the play state has changed. 242 // Set the saved animation to this new one, just in case the play state has changed.
243 keyframeAnim->setAnimation(anim); 243 keyframeAnim->setAnimation(anim);
244 keyframeAnim->setIndex(i); 244 keyframeAnim->setIndex(i);
245 } else if ((anim->duration() || anim->delay()) && anim->iteratio nCount() && animationName != none) { 245 } else if ((anim->duration() || anim->delay()) && anim->iteratio nCount() && animationName != none) {
246 keyframeAnim = KeyframeAnimation::create(const_cast<Animatio n*>(anim), renderer, i, this, targetStyle); 246 keyframeAnim = KeyframeAnimation::create(const_cast<CSSAnima tionData*>(anim), renderer, i, this, targetStyle);
247 m_keyframeAnimations.set(keyframeAnim->name().impl(), keyfra meAnim); 247 m_keyframeAnimations.set(keyframeAnim->name().impl(), keyfra meAnim);
248 } 248 }
249 249
250 // Add this to the animation order map. 250 // Add this to the animation order map.
251 if (keyframeAnim) 251 if (keyframeAnim)
252 m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl ()); 252 m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl ());
253 } 253 }
254 } 254 }
255 } 255 }
256 256
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 bool CompositeAnimation::pauseAnimationAtTime(const AtomicString& name, double t ) 477 bool CompositeAnimation::pauseAnimationAtTime(const AtomicString& name, double t )
478 { 478 {
479 m_keyframeAnimations.checkConsistency(); 479 m_keyframeAnimations.checkConsistency();
480 480
481 RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name.impl( )); 481 RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name.impl( ));
482 if (!keyframeAnim || !keyframeAnim->running()) 482 if (!keyframeAnim || !keyframeAnim->running())
483 return false; 483 return false;
484 484
485 double count = keyframeAnim->m_animation->iterationCount(); 485 double count = keyframeAnim->m_animation->iterationCount();
486 if ((t >= 0.0) && ((count == Animation::IterationCountInfinite) || (t <= cou nt * keyframeAnim->duration()))) { 486 if ((t >= 0.0) && ((count == CSSAnimationData::IterationCountInfinite) || (t <= count * keyframeAnim->duration()))) {
487 keyframeAnim->freezeAtTime(t); 487 keyframeAnim->freezeAtTime(t);
488 return true; 488 return true;
489 } 489 }
490 490
491 return false; 491 return false;
492 } 492 }
493 493
494 bool CompositeAnimation::pauseTransitionAtTime(CSSPropertyID property, double t) 494 bool CompositeAnimation::pauseTransitionAtTime(CSSPropertyID property, double t)
495 { 495 {
496 if ((property < firstCSSProperty) || (property >= firstCSSProperty + numCSSP roperties)) 496 if ((property < firstCSSProperty) || (property >= firstCSSProperty + numCSSP roperties))
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 ImplicitAnimation* anim = it->value.get(); 541 ImplicitAnimation* anim = it->value.get();
542 if (anim->running()) 542 if (anim->running())
543 ++count; 543 ++count;
544 } 544 }
545 } 545 }
546 546
547 return count; 547 return count;
548 } 548 }
549 549
550 } // namespace WebCore 550 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/animation/AnimationBase.cpp ('k') | Source/core/page/animation/ImplicitAnimation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698