OLD | NEW |
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (const StyleRuleKeyframes* keyframesRule = stack.at(i)->keyframeStyle
sForAnimation(animationName)) | 316 if (const StyleRuleKeyframes* keyframesRule = stack.at(i)->keyframeStyle
sForAnimation(animationName)) |
317 return keyframesRule; | 317 return keyframesRule; |
318 } | 318 } |
319 return 0; | 319 return 0; |
320 } | 320 } |
321 | 321 |
322 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(Elemen
t* element, const Element& parentElement, const RenderStyle& style, RenderStyle*
parentStyle, StyleResolver* resolver) | 322 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(Elemen
t* element, const Element& parentElement, const RenderStyle& style, RenderStyle*
parentStyle, StyleResolver* resolver) |
323 { | 323 { |
324 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAn
imationUpdate()); | 324 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAn
imationUpdate()); |
325 calculateAnimationUpdate(update.get(), element, parentElement, style, parent
Style, resolver); | 325 calculateAnimationUpdate(update.get(), element, parentElement, style, parent
Style, resolver); |
326 calculateAnimationActiveInterpolations(update.get(), element); | 326 calculateAnimationActiveInterpolations(update.get(), element, parentElement.
document().timeline().currentTime()); |
327 calculateTransitionUpdate(update.get(), element, style); | 327 calculateTransitionUpdate(update.get(), element, style); |
328 calculateTransitionActiveInterpolations(update.get(), element); | 328 calculateTransitionActiveInterpolations(update.get(), element, parentElement
.document().transitionTimeline().currentTime()); |
329 return update->isEmpty() ? nullptr : update.release(); | 329 return update->isEmpty() ? nullptr : update.release(); |
330 } | 330 } |
331 | 331 |
332 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element
* element, const Element& parentElement, const RenderStyle& style, RenderStyle*
parentStyle, StyleResolver* resolver) | 332 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element
* element, const Element& parentElement, const RenderStyle& style, RenderStyle*
parentStyle, StyleResolver* resolver) |
333 { | 333 { |
334 const ActiveAnimations* activeAnimations = element ? element->activeAnimatio
ns() : 0; | 334 const ActiveAnimations* activeAnimations = element ? element->activeAnimatio
ns() : 0; |
335 | 335 |
336 #if ASSERT_DISABLED | 336 #if ASSERT_DISABLED |
337 // If we're in an animation style change, no animations can have started, be
en cancelled or changed play state. | 337 // If we're in an animation style change, no animations can have started, be
en cancelled or changed play state. |
338 // When ASSERT is enabled, we verify this optimization. | 338 // When ASSERT is enabled, we verify this optimization. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 } | 645 } |
646 | 646 |
647 for (TransitionMap::iterator iter = m_transitions.begin(); iter != m_transit
ions.end(); ++iter) | 647 for (TransitionMap::iterator iter = m_transitions.begin(); iter != m_transit
ions.end(); ++iter) |
648 iter->value.transition->player()->cancel(); | 648 iter->value.transition->player()->cancel(); |
649 | 649 |
650 m_animations.clear(); | 650 m_animations.clear(); |
651 m_transitions.clear(); | 651 m_transitions.clear(); |
652 m_pendingUpdate = nullptr; | 652 m_pendingUpdate = nullptr; |
653 } | 653 } |
654 | 654 |
655 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u
pdate, const Element* element) | 655 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u
pdate, const Element* element, double timelineCurrentTime) |
656 { | 656 { |
657 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 657 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
658 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 658 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
659 | 659 |
660 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { | 660 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { |
661 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority)); | 661 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); |
662 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); | 662 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); |
663 return; | 663 return; |
664 } | 664 } |
665 | 665 |
666 Vector<InertAnimation*> newAnimations; | 666 Vector<InertAnimation*> newAnimations; |
667 for (size_t i = 0; i < update->newAnimations().size(); ++i) { | 667 for (size_t i = 0; i < update->newAnimations().size(); ++i) { |
668 HashSet<RefPtr<InertAnimation> > animations = update->newAnimations()[i]
.animations; | 668 HashSet<RefPtr<InertAnimation> > animations = update->newAnimations()[i]
.animations; |
669 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = a
nimations.begin(); animationsIter != animations.end(); ++animationsIter) | 669 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = a
nimations.begin(); animationsIter != animations.end(); ++animationsIter) |
670 newAnimations.append(animationsIter->get()); | 670 newAnimations.append(animationsIter->get()); |
671 } | 671 } |
672 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority)); | 672 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); |
673 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); | 673 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); |
674 } | 674 } |
675 | 675 |
676 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element) | 676 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) |
677 { | 677 { |
678 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 678 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
679 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 679 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
680 | 680 |
681 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; | 681 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; |
682 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { | 682 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { |
683 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority); | 683 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); |
684 } else { | 684 } else { |
685 Vector<InertAnimation*> newTransitions; | 685 Vector<InertAnimation*> newTransitions; |
686 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) | 686 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) |
687 newTransitions.append(iter->value.animation.get()); | 687 newTransitions.append(iter->value.animation.get()); |
688 | 688 |
689 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; | 689 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; |
690 if (!update->cancelledTransitions().isEmpty()) { | 690 if (!update->cancelledTransitions().isEmpty()) { |
691 ASSERT(activeAnimations); | 691 ASSERT(activeAnimations); |
692 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; | 692 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; |
693 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { | 693 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { |
694 ASSERT(transitionMap.contains(*iter)); | 694 ASSERT(transitionMap.contains(*iter)); |
695 cancelledAnimationPlayers.add(transitionMap.get(*iter).transitio
n->player()); | 695 cancelledAnimationPlayers.add(transitionMap.get(*iter).transitio
n->player()); |
696 } | 696 } |
697 } | 697 } |
698 | 698 |
699 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi
tionPriority); | 699 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi
tionPriority, timelineCurrentTime); |
700 } | 700 } |
701 | 701 |
702 // Properties being animated by animations don't get values from transitions
applied. | 702 // Properties being animated by animations don't get values from transitions
applied. |
703 if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpo
lationsForTransitions.isEmpty()) { | 703 if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpo
lationsForTransitions.isEmpty()) { |
704 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>
>::const_iterator iter = update->activeInterpolationsForAnimations().begin(); it
er != update->activeInterpolationsForAnimations().end(); ++iter) | 704 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>
>::const_iterator iter = update->activeInterpolationsForAnimations().begin(); it
er != update->activeInterpolationsForAnimations().end(); ++iter) |
705 activeInterpolationsForTransitions.remove(iter->key); | 705 activeInterpolationsForTransitions.remove(iter->key); |
706 } | 706 } |
707 update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTrans
itions); | 707 update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTrans
itions); |
708 } | 708 } |
709 | 709 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 } | 903 } |
904 | 904 |
905 void CSSAnimationUpdate::trace(Visitor* visitor) | 905 void CSSAnimationUpdate::trace(Visitor* visitor) |
906 { | 906 { |
907 visitor->trace(m_newTransitions); | 907 visitor->trace(m_newTransitions); |
908 visitor->trace(m_activeInterpolationsForAnimations); | 908 visitor->trace(m_activeInterpolationsForAnimations); |
909 visitor->trace(m_activeInterpolationsForTransitions); | 909 visitor->trace(m_activeInterpolationsForTransitions); |
910 } | 910 } |
911 | 911 |
912 } // namespace WebCore | 912 } // namespace WebCore |
OLD | NEW |