| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "core/animation/css/CSSAnimations.h" | 31 #include "core/animation/css/CSSAnimations.h" |
| 32 | 32 |
| 33 #include "core/StylePropertyShorthand.h" | 33 #include "core/StylePropertyShorthand.h" |
| 34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
| 35 #include "core/animation/CompositorAnimations.h" | 35 #include "core/animation/CompositorAnimations.h" |
| 36 #include "core/animation/DocumentTimeline.h" | 36 #include "core/animation/DocumentTimeline.h" |
| 37 #include "core/animation/ElementAnimations.h" | 37 #include "core/animation/ElementAnimations.h" |
| 38 #include "core/animation/InertEffect.h" | 38 #include "core/animation/InertEffect.h" |
| 39 #include "core/animation/Interpolation.h" | 39 #include "core/animation/Interpolation.h" |
| 40 #include "core/animation/KeyframeEffect.h" |
| 40 #include "core/animation/KeyframeEffectModel.h" | 41 #include "core/animation/KeyframeEffectModel.h" |
| 42 #include "core/animation/KeyframeEffectReadOnly.h" |
| 41 #include "core/animation/LegacyStyleInterpolation.h" | 43 #include "core/animation/LegacyStyleInterpolation.h" |
| 42 #include "core/animation/css/CSSAnimatableValueFactory.h" | 44 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 43 #include "core/css/CSSKeyframeRule.h" | 45 #include "core/css/CSSKeyframeRule.h" |
| 44 #include "core/css/CSSPropertyEquality.h" | 46 #include "core/css/CSSPropertyEquality.h" |
| 45 #include "core/css/CSSPropertyMetadata.h" | 47 #include "core/css/CSSPropertyMetadata.h" |
| 46 #include "core/css/CSSValueList.h" | 48 #include "core/css/CSSValueList.h" |
| 47 #include "core/css/resolver/CSSToStyleMap.h" | 49 #include "core/css/resolver/CSSToStyleMap.h" |
| 48 #include "core/css/resolver/StyleResolver.h" | 50 #include "core/css/resolver/StyleResolver.h" |
| 49 #include "core/dom/Element.h" | 51 #include "core/dom/Element.h" |
| 50 #include "core/dom/PseudoElement.h" | 52 #include "core/dom/PseudoElement.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 DCHECK(i == cancelledIndices.size() - 1 || cancelledIndices[i] < cancell
edIndices[i + 1]); | 425 DCHECK(i == cancelledIndices.size() - 1 || cancelledIndices[i] < cancell
edIndices[i + 1]); |
| 424 Animation& animation = *m_runningAnimations[cancelledIndices[i]]->animat
ion; | 426 Animation& animation = *m_runningAnimations[cancelledIndices[i]]->animat
ion; |
| 425 animation.cancel(); | 427 animation.cancel(); |
| 426 animation.update(TimingUpdateOnDemand); | 428 animation.update(TimingUpdateOnDemand); |
| 427 m_runningAnimations.remove(cancelledIndices[i]); | 429 m_runningAnimations.remove(cancelledIndices[i]); |
| 428 } | 430 } |
| 429 | 431 |
| 430 for (const auto& entry : m_pendingUpdate.newAnimations()) { | 432 for (const auto& entry : m_pendingUpdate.newAnimations()) { |
| 431 const InertEffect* inertAnimation = entry.effect.get(); | 433 const InertEffect* inertAnimation = entry.effect.get(); |
| 432 AnimationEventDelegate* eventDelegate = new AnimationEventDelegate(eleme
nt, entry.name); | 434 AnimationEventDelegate* eventDelegate = new AnimationEventDelegate(eleme
nt, entry.name); |
| 433 KeyframeEffect* effect = KeyframeEffect::create(element, inertAnimation-
>model(), inertAnimation->specifiedTiming(), KeyframeEffect::DefaultPriority, ev
entDelegate); | 435 KeyframeEffect* effect = KeyframeEffect::create(element, inertAnimation-
>model(), inertAnimation->specifiedTiming(), KeyframeEffectReadOnly::DefaultPrio
rity, eventDelegate); |
| 434 Animation* animation = element->document().timeline().play(effect); | 436 Animation* animation = element->document().timeline().play(effect); |
| 435 animation->setId(entry.name); | 437 animation->setId(entry.name); |
| 436 if (inertAnimation->paused()) | 438 if (inertAnimation->paused()) |
| 437 animation->pause(); | 439 animation->pause(); |
| 438 animation->update(TimingUpdateOnDemand); | 440 animation->update(TimingUpdateOnDemand); |
| 439 | 441 |
| 440 m_runningAnimations.append(new RunningAnimation(animation, entry)); | 442 m_runningAnimations.append(new RunningAnimation(animation, entry)); |
| 441 } | 443 } |
| 442 | 444 |
| 443 // Transitions that are run on the compositor only update main-thread state | 445 // Transitions that are run on the compositor only update main-thread state |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 InertEffect* inertAnimationForSampling = InertEffect::create(oldAnim
ation->model(), oldAnimation->specifiedTiming(), false, inheritedTime); | 508 InertEffect* inertAnimationForSampling = InertEffect::create(oldAnim
ation->model(), oldAnimation->specifiedTiming(), false, inheritedTime); |
| 507 Vector<RefPtr<Interpolation>> sample; | 509 Vector<RefPtr<Interpolation>> sample; |
| 508 inertAnimationForSampling->sample(sample); | 510 inertAnimationForSampling->sample(sample); |
| 509 if (sample.size() == 1) { | 511 if (sample.size() == 1) { |
| 510 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple.at(0).get())->currentValue()); | 512 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple.at(0).get())->currentValue()); |
| 511 newFrames[1]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple.at(0).get())->currentValue()); | 513 newFrames[1]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple.at(0).get())->currentValue()); |
| 512 model = AnimatableValueKeyframeEffectModel::create(newFrames); | 514 model = AnimatableValueKeyframeEffectModel::create(newFrames); |
| 513 } | 515 } |
| 514 } | 516 } |
| 515 | 517 |
| 516 KeyframeEffect* transition = KeyframeEffect::create(element, model, iner
tAnimation->specifiedTiming(), KeyframeEffect::TransitionPriority, eventDelegate
); | 518 KeyframeEffect* transition = KeyframeEffect::create(element, model, iner
tAnimation->specifiedTiming(), KeyframeEffectReadOnly::TransitionPriority, event
Delegate); |
| 517 Animation* animation = element->document().timeline().play(transition); | 519 Animation* animation = element->document().timeline().play(transition); |
| 518 animation->setId(getPropertyName(newTransition.id)); | 520 animation->setId(getPropertyName(newTransition.id)); |
| 519 // Set the current time as the start time for retargeted transitions | 521 // Set the current time as the start time for retargeted transitions |
| 520 if (retargetedCompositorTransitions.contains(id)) | 522 if (retargetedCompositorTransitions.contains(id)) |
| 521 animation->setStartTime(element->document().timeline().currentTime()
); | 523 animation->setStartTime(element->document().timeline().currentTime()
); |
| 522 animation->update(TimingUpdateOnDemand); | 524 animation->update(TimingUpdateOnDemand); |
| 523 runningTransition.animation = animation; | 525 runningTransition.animation = animation; |
| 524 m_transitions.set(id, runningTransition); | 526 m_transitions.set(id, runningTransition); |
| 525 DCHECK_NE(id, CSSPropertyInvalid); | 527 DCHECK_NE(id, CSSPropertyInvalid); |
| 526 | 528 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 { | 711 { |
| 710 return propertyHandle.isCSSProperty() || propertyHandle.isPresentationAttrib
ute(); | 712 return propertyHandle.isCSSProperty() || propertyHandle.isPresentationAttrib
ute(); |
| 711 } | 713 } |
| 712 | 714 |
| 713 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u
pdate, const Element* animatingElement) | 715 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u
pdate, const Element* animatingElement) |
| 714 { | 716 { |
| 715 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; | 717 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; |
| 716 AnimationStack* animationStack = elementAnimations ? &elementAnimations->ani
mationStack() : nullptr; | 718 AnimationStack* animationStack = elementAnimations ? &elementAnimations->ani
mationStack() : nullptr; |
| 717 | 719 |
| 718 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt
y()) { | 720 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt
y()) { |
| 719 ActiveInterpolationsMap activeInterpolationsForAnimations(AnimationStack
::activeInterpolations(animationStack, nullptr, nullptr, KeyframeEffect::Default
Priority, isStylePropertyHandle)); | 721 ActiveInterpolationsMap activeInterpolationsForAnimations(AnimationStack
::activeInterpolations(animationStack, nullptr, nullptr, KeyframeEffectReadOnly:
:DefaultPriority, isStylePropertyHandle)); |
| 720 update.adoptActiveInterpolationsForAnimations(activeInterpolationsForAni
mations); | 722 update.adoptActiveInterpolationsForAnimations(activeInterpolationsForAni
mations); |
| 721 return; | 723 return; |
| 722 } | 724 } |
| 723 | 725 |
| 724 HeapVector<Member<const InertEffect>> newEffects; | 726 HeapVector<Member<const InertEffect>> newEffects; |
| 725 for (const auto& newAnimation : update.newAnimations()) | 727 for (const auto& newAnimation : update.newAnimations()) |
| 726 newEffects.append(newAnimation.effect); | 728 newEffects.append(newAnimation.effect); |
| 727 for (const auto& updatedAnimation : update.animationsWithUpdates()) | 729 for (const auto& updatedAnimation : update.animationsWithUpdates()) |
| 728 newEffects.append(updatedAnimation.effect); // Animations with updates u
se a temporary InertEffect for the current frame. | 730 newEffects.append(updatedAnimation.effect); // Animations with updates u
se a temporary InertEffect for the current frame. |
| 729 | 731 |
| 730 ActiveInterpolationsMap activeInterpolationsForAnimations(AnimationStack::ac
tiveInterpolations(animationStack, &newEffects, &update.suppressedAnimations(),
KeyframeEffect::DefaultPriority, isStylePropertyHandle)); | 732 ActiveInterpolationsMap activeInterpolationsForAnimations(AnimationStack::ac
tiveInterpolations(animationStack, &newEffects, &update.suppressedAnimations(),
KeyframeEffectReadOnly::DefaultPriority, isStylePropertyHandle)); |
| 731 update.adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimati
ons); | 733 update.adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimati
ons); |
| 732 } | 734 } |
| 733 | 735 |
| 734 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate&
update, const Element* animatingElement) | 736 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate&
update, const Element* animatingElement) |
| 735 { | 737 { |
| 736 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; | 738 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; |
| 737 AnimationStack* animationStack = elementAnimations ? &elementAnimations->ani
mationStack() : nullptr; | 739 AnimationStack* animationStack = elementAnimations ? &elementAnimations->ani
mationStack() : nullptr; |
| 738 | 740 |
| 739 ActiveInterpolationsMap activeInterpolationsForTransitions; | 741 ActiveInterpolationsMap activeInterpolationsForTransitions; |
| 740 if (update.newTransitions().isEmpty() && update.cancelledTransitions().isEmp
ty()) { | 742 if (update.newTransitions().isEmpty() && update.cancelledTransitions().isEmp
ty()) { |
| 741 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, nullptr, nullptr, KeyframeEffect::TransitionPriority, isStyleP
ropertyHandle); | 743 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, nullptr, nullptr, KeyframeEffectReadOnly::TransitionPriority,
isStylePropertyHandle); |
| 742 } else { | 744 } else { |
| 743 HeapVector<Member<const InertEffect>> newTransitions; | 745 HeapVector<Member<const InertEffect>> newTransitions; |
| 744 for (const auto& entry : update.newTransitions()) | 746 for (const auto& entry : update.newTransitions()) |
| 745 newTransitions.append(entry.value.effect.get()); | 747 newTransitions.append(entry.value.effect.get()); |
| 746 | 748 |
| 747 HeapHashSet<Member<const Animation>> cancelledAnimations; | 749 HeapHashSet<Member<const Animation>> cancelledAnimations; |
| 748 if (!update.cancelledTransitions().isEmpty()) { | 750 if (!update.cancelledTransitions().isEmpty()) { |
| 749 DCHECK(elementAnimations); | 751 DCHECK(elementAnimations); |
| 750 const TransitionMap& transitionMap = elementAnimations->cssAnimation
s().m_transitions; | 752 const TransitionMap& transitionMap = elementAnimations->cssAnimation
s().m_transitions; |
| 751 for (CSSPropertyID id : update.cancelledTransitions()) { | 753 for (CSSPropertyID id : update.cancelledTransitions()) { |
| 752 DCHECK(transitionMap.contains(id)); | 754 DCHECK(transitionMap.contains(id)); |
| 753 cancelledAnimations.add(transitionMap.get(id).animation.get()); | 755 cancelledAnimations.add(transitionMap.get(id).animation.get()); |
| 754 } | 756 } |
| 755 } | 757 } |
| 756 | 758 |
| 757 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimations, KeyframeEffect::Transit
ionPriority, isStylePropertyHandle); | 759 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimations, KeyframeEffectReadOnly:
:TransitionPriority, isStylePropertyHandle); |
| 758 } | 760 } |
| 759 | 761 |
| 760 // Properties being animated by animations don't get values from transitions
applied. | 762 // Properties being animated by animations don't get values from transitions
applied. |
| 761 if (!update.activeInterpolationsForAnimations().isEmpty() && !activeInterpol
ationsForTransitions.isEmpty()) { | 763 if (!update.activeInterpolationsForAnimations().isEmpty() && !activeInterpol
ationsForTransitions.isEmpty()) { |
| 762 for (const auto& entry : update.activeInterpolationsForAnimations()) | 764 for (const auto& entry : update.activeInterpolationsForAnimations()) |
| 763 activeInterpolationsForTransitions.remove(entry.key); | 765 activeInterpolationsForTransitions.remove(entry.key); |
| 764 } | 766 } |
| 765 update.adoptActiveInterpolationsForTransitions(activeInterpolationsForTransi
tions); | 767 update.adoptActiveInterpolationsForTransitions(activeInterpolationsForTransi
tions); |
| 766 } | 768 } |
| 767 | 769 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 } | 899 } |
| 898 | 900 |
| 899 DEFINE_TRACE(CSSAnimations) | 901 DEFINE_TRACE(CSSAnimations) |
| 900 { | 902 { |
| 901 visitor->trace(m_transitions); | 903 visitor->trace(m_transitions); |
| 902 visitor->trace(m_pendingUpdate); | 904 visitor->trace(m_pendingUpdate); |
| 903 visitor->trace(m_runningAnimations); | 905 visitor->trace(m_runningAnimations); |
| 904 } | 906 } |
| 905 | 907 |
| 906 } // namespace blink | 908 } // namespace blink |
| OLD | NEW |