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

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

Issue 210703002: Web Animations: Sort Animations in the AnimationStack (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (const StyleRuleKeyframes* keyframesRule = stack.at(i)->keyframeStyle sForAnimation(animationName)) 317 if (const StyleRuleKeyframes* keyframesRule = stack.at(i)->keyframeStyle sForAnimation(animationName))
318 return keyframesRule; 318 return keyframesRule;
319 } 319 }
320 return 0; 320 return 0;
321 } 321 }
322 322
323 PassOwnPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(Element* element, const Element& parentElement, const RenderStyle& style, RenderStyle* parentStyle , StyleResolver* resolver) 323 PassOwnPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(Element* element, const Element& parentElement, const RenderStyle& style, RenderStyle* parentStyle , StyleResolver* resolver)
324 { 324 {
325 OwnPtr<CSSAnimationUpdate> update = adoptPtr(new CSSAnimationUpdate()); 325 OwnPtr<CSSAnimationUpdate> update = adoptPtr(new CSSAnimationUpdate());
326 calculateAnimationUpdate(update.get(), element, parentElement, style, parent Style, resolver); 326 calculateAnimationUpdate(update.get(), element, parentElement, style, parent Style, resolver);
327 calculateAnimationActiveInterpolations(update.get(), element); 327 calculateAnimationActiveInterpolations(update.get(), element, parentElement. document().timeline().currentTime());
328 calculateTransitionUpdate(update.get(), element, style); 328 calculateTransitionUpdate(update.get(), element, style);
329 calculateTransitionActiveInterpolations(update.get(), element); 329 calculateTransitionActiveInterpolations(update.get(), element, parentElement .document().transitionTimeline().currentTime());
330 return update->isEmpty() ? nullptr : update.release(); 330 return update->isEmpty() ? nullptr : update.release();
331 } 331 }
332 332
333 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element * element, const Element& parentElement, const RenderStyle& style, RenderStyle* parentStyle, StyleResolver* resolver) 333 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element * element, const Element& parentElement, const RenderStyle& style, RenderStyle* parentStyle, StyleResolver* resolver)
334 { 334 {
335 const ActiveAnimations* activeAnimations = element ? element->activeAnimatio ns() : 0; 335 const ActiveAnimations* activeAnimations = element ? element->activeAnimatio ns() : 0;
336 336
337 #if ASSERT_DISABLED 337 #if ASSERT_DISABLED
338 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state. 338 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state.
339 // When ASSERT is enabled, we verify this optimization. 339 // When ASSERT is enabled, we verify this optimization.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 647
648 for (TransitionMap::iterator iter = m_transitions.begin(); iter != m_transit ions.end(); ++iter) 648 for (TransitionMap::iterator iter = m_transitions.begin(); iter != m_transit ions.end(); ++iter)
649 iter->value.transition->player()->cancel(); 649 iter->value.transition->player()->cancel();
650 650
651 m_animations.clear(); 651 m_animations.clear();
652 m_transitions.clear(); 652 m_transitions.clear();
653 m_pendingUpdate = nullptr; 653 m_pendingUpdate = nullptr;
654 } 654 }
655 655
656 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u pdate, const Element* element) 656 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u pdate, const Element* element, double timelineCurrentTime)
657 { 657 {
658 ActiveAnimations* activeAnimations = element ? element->activeAnimations() : 0; 658 ActiveAnimations* activeAnimations = element ? element->activeAnimations() : 0;
659 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau ltStack() : 0; 659 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau ltStack() : 0;
660 660
661 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation Players().isEmpty()) { 661 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation Players().isEmpty()) {
662 HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForAn imations(AnimationStack::activeInterpolations(animationStack, 0, 0, Animation::D efaultPriority)); 662 HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForAn imations(AnimationStack::activeInterpolations(animationStack, 0, 0, Animation::D efaultPriority, timelineCurrentTime));
663 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn imations); 663 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn imations);
664 return; 664 return;
665 } 665 }
666 666
667 Vector<InertAnimation*> newAnimations; 667 Vector<InertAnimation*> newAnimations;
668 for (size_t i = 0; i < update->newAnimations().size(); ++i) { 668 for (size_t i = 0; i < update->newAnimations().size(); ++i) {
669 HashSet<RefPtr<InertAnimation> > animations = update->newAnimations()[i] .animations; 669 HashSet<RefPtr<InertAnimation> > animations = update->newAnimations()[i] .animations;
670 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = a nimations.begin(); animationsIter != animations.end(); ++animationsIter) 670 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = a nimations.begin(); animationsIter != animations.end(); ++animationsIter)
671 newAnimations.append(animationsIter->get()); 671 newAnimations.append(animationsIter->get());
672 } 672 }
673 HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForAnimat ions(AnimationStack::activeInterpolations(animationStack, &newAnimations, &updat e->cancelledAnimationAnimationPlayers(), Animation::DefaultPriority)); 673 HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForAnimat ions(AnimationStack::activeInterpolations(animationStack, &newAnimations, &updat e->cancelledAnimationAnimationPlayers(), Animation::DefaultPriority, timelineCur rentTime));
674 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat ions); 674 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat ions);
675 } 675 }
676 676
677 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* element) 677 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* element, double timelineCurrentTime)
678 { 678 {
679 ActiveAnimations* activeAnimations = element ? element->activeAnimations() : 0; 679 ActiveAnimations* activeAnimations = element ? element->activeAnimations() : 0;
680 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau ltStack() : 0; 680 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau ltStack() : 0;
681 681
682 HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForTransi tions; 682 HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForTransi tions;
683 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE mpty()) { 683 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE mpty()) {
684 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, 0, 0, Animation::TransitionPriority); 684 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime);
685 } else { 685 } else {
686 Vector<InertAnimation*> newTransitions; 686 Vector<InertAnimation*> newTransitions;
687 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update- >newTransitions().begin(); iter != update->newTransitions().end(); ++iter) 687 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update- >newTransitions().begin(); iter != update->newTransitions().end(); ++iter)
688 newTransitions.append(iter->value.animation.get()); 688 newTransitions.append(iter->value.animation.get());
689 689
690 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; 690 HashSet<const AnimationPlayer*> cancelledAnimationPlayers;
691 if (!update->cancelledTransitions().isEmpty()) { 691 if (!update->cancelledTransitions().isEmpty()) {
692 ASSERT(activeAnimations); 692 ASSERT(activeAnimations);
693 const TransitionMap& transitionMap = activeAnimations->cssAnimations ().m_transitions; 693 const TransitionMap& transitionMap = activeAnimations->cssAnimations ().m_transitions;
694 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { 694 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi tions().begin(); iter != update->cancelledTransitions().end(); ++iter) {
695 ASSERT(transitionMap.contains(*iter)); 695 ASSERT(transitionMap.contains(*iter));
696 cancelledAnimationPlayers.add(transitionMap.get(*iter).transitio n->player()); 696 cancelledAnimationPlayers.add(transitionMap.get(*iter).transitio n->player());
697 } 697 }
698 } 698 }
699 699
700 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi tionPriority); 700 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi tionPriority, timelineCurrentTime);
701 } 701 }
702 702
703 // Properties being animated by animations don't get values from transitions applied. 703 // Properties being animated by animations don't get values from transitions applied.
704 if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpo lationsForTransitions.isEmpty()) { 704 if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpo lationsForTransitions.isEmpty()) {
705 for (HashMap<CSSPropertyID, RefPtr<Interpolation> >::const_iterator iter = update->activeInterpolationsForAnimations().begin(); iter != update->activeIn terpolationsForAnimations().end(); ++iter) 705 for (HashMap<CSSPropertyID, RefPtr<Interpolation> >::const_iterator iter = update->activeInterpolationsForAnimations().begin(); iter != update->activeIn terpolationsForAnimations().end(); ++iter)
706 activeInterpolationsForTransitions.remove(iter->key); 706 activeInterpolationsForTransitions.remove(iter->key);
707 } 707 }
708 update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTrans itions); 708 update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTrans itions);
709 } 709 }
710 710
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 CSSPropertyID id = convertToCSSPropertyID(i); 890 CSSPropertyID id = convertToCSSPropertyID(i);
891 if (isAnimatableProperty(id)) 891 if (isAnimatableProperty(id))
892 properties.append(id); 892 properties.append(id);
893 } 893 }
894 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size()); 894 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size());
895 } 895 }
896 return propertyShorthand; 896 return propertyShorthand;
897 } 897 }
898 898
899 } // namespace WebCore 899 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698