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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 RefPtr<Animation> oldAnimation = oldTransition.first; | 512 RefPtr<Animation> oldAnimation = oldTransition.first; |
513 double oldStartTime = oldTransition.second; | 513 double oldStartTime = oldTransition.second; |
514 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline()->currentTime() - oldStartTime; | 514 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline()->currentTime() - oldStartTime; |
515 oldAnimation->updateInheritedTime(inheritedTime); | 515 oldAnimation->updateInheritedTime(inheritedTime); |
516 KeyframeEffectModel* oldEffect = toKeyframeEffectModel(inertAnimatio
n->effect()); | 516 KeyframeEffectModel* oldEffect = toKeyframeEffectModel(inertAnimatio
n->effect()); |
517 const KeyframeEffectModel::KeyframeVector& frames = oldEffect->getFr
ames(); | 517 const KeyframeEffectModel::KeyframeVector& frames = oldEffect->getFr
ames(); |
518 KeyframeEffectModel::KeyframeVector newFrames; | 518 KeyframeEffectModel::KeyframeVector newFrames; |
519 newFrames.append(frames[0]->clone()); | 519 newFrames.append(frames[0]->clone()); |
520 newFrames[0]->clearPropertyValue(id); | 520 newFrames[0]->clearPropertyValue(id); |
521 ASSERT(oldAnimation->compositableValues()->size() == 1); | 521 ASSERT(oldAnimation->compositableValues()->size() == 1); |
522 const AnimationEffect::CompositableValue* compositableValue = oldAni
mation->compositableValues()->at(0).second.get(); | 522 const AnimatableValue* value = static_cast<LegacyStyleInterpolation
*>(oldAnimation->compositableValues()->at(0).get())->currentValue(); |
523 ASSERT(!compositableValue->dependsOnUnderlyingValue()); | 523 newFrames[0]->setPropertyValue(id, value); |
524 newFrames[0]->setPropertyValue(id, compositableValue->compositeOnto(
0).get()); | |
525 newFrames.append(frames[1]->clone()); | 524 newFrames.append(frames[1]->clone()); |
526 effect = KeyframeEffectModel::create(newFrames); | 525 effect = KeyframeEffectModel::create(newFrames); |
527 } | 526 } |
528 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specified(), Animation::TransitionPriority, eventDelegate.release()); | 527 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specified(), Animation::TransitionPriority, eventDelegate.release()); |
529 RefPtr<Player> player = element->document().transitionTimeline()->create
Player(transition.get()); | 528 RefPtr<Player> player = element->document().transitionTimeline()->create
Player(transition.get()); |
530 player->update(); | 529 player->update(); |
531 element->document().cssPendingAnimations().add(player.get()); | 530 element->document().cssPendingAnimations().add(player.get()); |
532 runningTransition.transition = transition.get(); | 531 runningTransition.transition = transition.get(); |
533 m_transitions.set(id, runningTransition); | 532 m_transitions.set(id, runningTransition); |
534 ASSERT(id != CSSPropertyInvalid); | 533 ASSERT(id != CSSPropertyInvalid); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 m_transitions.clear(); | 667 m_transitions.clear(); |
669 m_pendingUpdate = nullptr; | 668 m_pendingUpdate = nullptr; |
670 } | 669 } |
671 | 670 |
672 void CSSAnimations::calculateAnimationCompositableValues(CSSAnimationUpdate* upd
ate, const Element* element) | 671 void CSSAnimations::calculateAnimationCompositableValues(CSSAnimationUpdate* upd
ate, const Element* element) |
673 { | 672 { |
674 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 673 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
675 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 674 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
676 | 675 |
677 if (update->newAnimations().isEmpty() && update->cancelledAnimationPlayers()
.isEmpty()) { | 676 if (update->newAnimations().isEmpty() && update->cancelledAnimationPlayers()
.isEmpty()) { |
678 AnimationEffect::CompositableValueMap compositableValuesForAnimations(An
imationStack::compositableValues(animationStack, 0, 0, Animation::DefaultPriorit
y)); | 677 HashMap<CSSPropertyID, RefPtr<Interpolation> > compositableValuesForAnim
ations(AnimationStack::compositableValues(animationStack, 0, 0, Animation::Defau
ltPriority)); |
679 update->adoptCompositableValuesForAnimations(compositableValuesForAnimat
ions); | 678 update->adoptCompositableValuesForAnimations(compositableValuesForAnimat
ions); |
680 return; | 679 return; |
681 } | 680 } |
682 | 681 |
683 Vector<InertAnimation*> newAnimations; | 682 Vector<InertAnimation*> newAnimations; |
684 for (size_t i = 0; i < update->newAnimations().size(); ++i) { | 683 for (size_t i = 0; i < update->newAnimations().size(); ++i) { |
685 HashSet<RefPtr<InertAnimation> > animations = update->newAnimations()[i]
.animations; | 684 HashSet<RefPtr<InertAnimation> > animations = update->newAnimations()[i]
.animations; |
686 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = a
nimations.begin(); animationsIter != animations.end(); ++animationsIter) | 685 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = a
nimations.begin(); animationsIter != animations.end(); ++animationsIter) |
687 newAnimations.append(animationsIter->get()); | 686 newAnimations.append(animationsIter->get()); |
688 } | 687 } |
689 AnimationEffect::CompositableValueMap compositableValuesForAnimations(Animat
ionStack::compositableValues(animationStack, &newAnimations, &update->cancelledA
nimationPlayers(), Animation::DefaultPriority)); | 688 HashMap<CSSPropertyID, RefPtr<Interpolation> > compositableValuesForAnimatio
ns(AnimationStack::compositableValues(animationStack, &newAnimations, &update->c
ancelledAnimationPlayers(), Animation::DefaultPriority)); |
690 update->adoptCompositableValuesForAnimations(compositableValuesForAnimations
); | 689 update->adoptCompositableValuesForAnimations(compositableValuesForAnimations
); |
691 } | 690 } |
692 | 691 |
693 void CSSAnimations::calculateTransitionCompositableValues(CSSAnimationUpdate* up
date, const Element* element) | 692 void CSSAnimations::calculateTransitionCompositableValues(CSSAnimationUpdate* up
date, const Element* element) |
694 { | 693 { |
695 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 694 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
696 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 695 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
697 | 696 |
698 AnimationEffect::CompositableValueMap compositableValuesForTransitions; | 697 HashMap<CSSPropertyID, RefPtr<Interpolation> > compositableValuesForTransiti
ons; |
699 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { | 698 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { |
700 compositableValuesForTransitions = AnimationStack::compositableValues(an
imationStack, 0, 0, Animation::TransitionPriority); | 699 compositableValuesForTransitions = AnimationStack::compositableValues(an
imationStack, 0, 0, Animation::TransitionPriority); |
701 } else { | 700 } else { |
702 Vector<InertAnimation*> newTransitions; | 701 Vector<InertAnimation*> newTransitions; |
703 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) | 702 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) |
704 newTransitions.append(iter->value.animation.get()); | 703 newTransitions.append(iter->value.animation.get()); |
705 | 704 |
706 HashSet<const Player*> cancelledPlayers; | 705 HashSet<const Player*> cancelledPlayers; |
707 if (!update->cancelledTransitions().isEmpty()) { | 706 if (!update->cancelledTransitions().isEmpty()) { |
708 ASSERT(activeAnimations); | 707 ASSERT(activeAnimations); |
709 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; | 708 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; |
710 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { | 709 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { |
711 ASSERT(transitionMap.contains(*iter)); | 710 ASSERT(transitionMap.contains(*iter)); |
712 cancelledPlayers.add(transitionMap.get(*iter).transition->player
()); | 711 cancelledPlayers.add(transitionMap.get(*iter).transition->player
()); |
713 } | 712 } |
714 } | 713 } |
715 | 714 |
716 compositableValuesForTransitions = AnimationStack::compositableValues(an
imationStack, &newTransitions, &cancelledPlayers, Animation::TransitionPriority)
; | 715 compositableValuesForTransitions = AnimationStack::compositableValues(an
imationStack, &newTransitions, &cancelledPlayers, Animation::TransitionPriority)
; |
717 } | 716 } |
718 | 717 |
719 // Properties being animated by animations don't get values from transitions
applied. | 718 // Properties being animated by animations don't get values from transitions
applied. |
720 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal
uesForTransitions.isEmpty()) { | 719 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal
uesForTransitions.isEmpty()) { |
721 for (AnimationEffect::CompositableValueMap::const_iterator iter = update
->compositableValuesForAnimations().begin(); iter != update->compositableValuesF
orAnimations().end(); ++iter) | 720 for (HashMap<CSSPropertyID, RefPtr<Interpolation> >::const_iterator iter
= update->compositableValuesForAnimations().begin(); iter != update->compositab
leValuesForAnimations().end(); ++iter) |
722 compositableValuesForTransitions.remove(iter->key); | 721 compositableValuesForTransitions.remove(iter->key); |
723 } | 722 } |
724 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio
ns); | 723 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio
ns); |
725 } | 724 } |
726 | 725 |
727 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType
listenerType, const AtomicString& eventName, double elapsedTime) | 726 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType
listenerType, const AtomicString& eventName, double elapsedTime) |
728 { | 727 { |
729 if (m_target->document().hasListenerType(listenerType)) | 728 if (m_target->document().hasListenerType(listenerType)) |
730 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim
ationEvent::create(eventName, m_name, elapsedTime)); | 729 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim
ationEvent::create(eventName, m_name, elapsedTime)); |
731 } | 730 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 CSSPropertyID id = convertToCSSPropertyID(i); | 912 CSSPropertyID id = convertToCSSPropertyID(i); |
914 if (isAnimatableProperty(id)) | 913 if (isAnimatableProperty(id)) |
915 properties.append(id); | 914 properties.append(id); |
916 } | 915 } |
917 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 916 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
918 } | 917 } |
919 return propertyShorthand; | 918 return propertyShorthand; |
920 } | 919 } |
921 | 920 |
922 } // namespace WebCore | 921 } // namespace WebCore |
OLD | NEW |