OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/AnimationStack.h" | 6 #include "core/animation/AnimationStack.h" |
7 | 7 |
8 #include "core/animation/AnimationClock.h" | 8 #include "core/animation/AnimationClock.h" |
9 #include "core/animation/AnimationTimeline.h" | 9 #include "core/animation/AnimationTimeline.h" |
10 #include "core/animation/ElementAnimations.h" | 10 #include "core/animation/ElementAnimations.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 player->update(TimingUpdateOnDemand); | 32 player->update(TimingUpdateOnDemand); |
33 return player; | 33 return player; |
34 } | 34 } |
35 | 35 |
36 void updateTimeline(double time) | 36 void updateTimeline(double time) |
37 { | 37 { |
38 document->animationClock().updateTime(time); | 38 document->animationClock().updateTime(time); |
39 timeline->serviceAnimations(TimingUpdateForAnimationFrame); | 39 timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
40 } | 40 } |
41 | 41 |
42 const WillBeHeapVector<OwnPtrWillBeMember<SampledEffect>>& effects() | 42 const HeapVector<Member<SampledEffect>>& effects() |
43 { | 43 { |
44 return element->ensureElementAnimations().defaultStack().m_effects; | 44 return element->ensureElementAnimations().defaultStack().m_effects; |
45 } | 45 } |
46 | 46 |
47 PassRefPtrWillBeRawPtr<AnimationEffect> makeAnimationEffect(CSSPropertyID id
, PassRefPtrWillBeRawPtr<AnimatableValue> value) | 47 AnimationEffect* makeAnimationEffect(CSSPropertyID id, AnimatableValue* valu
e) |
48 { | 48 { |
49 AnimatableValueKeyframeVector keyframes(2); | 49 AnimatableValueKeyframeVector keyframes(2); |
50 keyframes[0] = AnimatableValueKeyframe::create(); | 50 keyframes[0] = AnimatableValueKeyframe::create(); |
51 keyframes[0]->setOffset(0.0); | 51 keyframes[0]->setOffset(0.0); |
52 keyframes[0]->setPropertyValue(id, value.get()); | 52 keyframes[0]->setPropertyValue(id, value); |
53 keyframes[1] = AnimatableValueKeyframe::create(); | 53 keyframes[1] = AnimatableValueKeyframe::create(); |
54 keyframes[1]->setOffset(1.0); | 54 keyframes[1]->setOffset(1.0); |
55 keyframes[1]->setPropertyValue(id, value.get()); | 55 keyframes[1]->setPropertyValue(id, value); |
56 return AnimatableValueKeyframeEffectModel::create(keyframes); | 56 return AnimatableValueKeyframeEffectModel::create(keyframes); |
57 } | 57 } |
58 | 58 |
59 PassRefPtrWillBeRawPtr<InertAnimation> makeInertAnimation(PassRefPtrWillBeRa
wPtr<AnimationEffect> effect) | 59 InertAnimation* makeInertAnimation(AnimationEffect* effect) |
60 { | 60 { |
61 Timing timing; | 61 Timing timing; |
62 timing.fillMode = Timing::FillModeBoth; | 62 timing.fillMode = Timing::FillModeBoth; |
63 return InertAnimation::create(effect, timing, false, 0); | 63 return InertAnimation::create(effect, timing, false, 0); |
64 } | 64 } |
65 | 65 |
66 PassRefPtrWillBeRawPtr<Animation> makeAnimation(PassRefPtrWillBeRawPtr<Anima
tionEffect> effect, double duration = 10) | 66 Animation* makeAnimation(AnimationEffect* effect, double duration = 10) |
67 { | 67 { |
68 Timing timing; | 68 Timing timing; |
69 timing.fillMode = Timing::FillModeBoth; | 69 timing.fillMode = Timing::FillModeBoth; |
70 timing.iterationDuration = duration; | 70 timing.iterationDuration = duration; |
71 return Animation::create(element.get(), effect, timing); | 71 return Animation::create(element.get(), effect, timing); |
72 } | 72 } |
73 | 73 |
74 AnimatableValue* interpolationValue(const ActiveInterpolationMap& activeInte
rpolations, CSSPropertyID id) | 74 AnimatableValue* interpolationValue(const ActiveInterpolationMap& activeInte
rpolations, CSSPropertyID id) |
75 { | 75 { |
76 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle(
id)); | 76 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle(
id)); |
77 return toLegacyStyleInterpolation(interpolation).currentValue().get(); | 77 return toLegacyStyleInterpolation(interpolation).currentValue(); |
78 } | 78 } |
79 | 79 |
80 RefPtrWillBePersistent<Document> document; | 80 RefPtrWillBePersistent<Document> document; |
81 RefPtrWillBePersistent<AnimationTimeline> timeline; | 81 Persistent<AnimationTimeline> timeline; |
82 RefPtrWillBePersistent<Element> element; | 82 RefPtrWillBePersistent<Element> element; |
83 }; | 83 }; |
84 | 84 |
85 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted) | 85 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted) |
86 { | 86 { |
87 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 10); | 87 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))), 10); |
88 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(2))).get(), 15); | 88 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(2))), 15); |
89 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(3))).get(), 5); | 89 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(3))), 5); |
90 ActiveInterpolationMap result = AnimationStack::activeInterpolations(&elemen
t->elementAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); | 90 ActiveInterpolationMap result = AnimationStack::activeInterpolations(&elemen
t->elementAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); |
91 EXPECT_EQ(1u, result.size()); | 91 EXPECT_EQ(1u, result.size()); |
92 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab
leDouble::create(3).get())); | 92 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab
leDouble::create(3))); |
93 } | 93 } |
94 | 94 |
95 TEST_F(AnimationAnimationStackTest, NewAnimations) | 95 TEST_F(AnimationAnimationStackTest, NewAnimations) |
96 { | 96 { |
97 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 15); | 97 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))), 15); |
98 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))).get(), 10); | 98 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))), 10); |
99 WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newAnimations; | 99 HeapVector<Member<InertAnimation>> newAnimations; |
100 RefPtrWillBeRawPtr<InertAnimation> inert1 = makeInertAnimation(makeAnimation
Effect(CSSPropertyFontSize, AnimatableDouble::create(3))); | 100 InertAnimation* inert1 = makeInertAnimation(makeAnimationEffect(CSSPropertyF
ontSize, AnimatableDouble::create(3))); |
101 RefPtrWillBeRawPtr<InertAnimation> inert2 = makeInertAnimation(makeAnimation
Effect(CSSPropertyZIndex, AnimatableDouble::create(4))); | 101 InertAnimation* inert2 = makeInertAnimation(makeAnimationEffect(CSSPropertyZ
Index, AnimatableDouble::create(4))); |
102 newAnimations.append(inert1.get()); | 102 newAnimations.append(inert1); |
103 newAnimations.append(inert2.get()); | 103 newAnimations.append(inert2); |
104 ActiveInterpolationMap result = AnimationStack::activeInterpolations(&elemen
t->elementAnimations()->defaultStack(), &newAnimations, 0, Animation::DefaultPri
ority, 10); | 104 ActiveInterpolationMap result = AnimationStack::activeInterpolations(&elemen
t->elementAnimations()->defaultStack(), &newAnimations, 0, Animation::DefaultPri
ority, 10); |
105 EXPECT_EQ(2u, result.size()); | 105 EXPECT_EQ(2u, result.size()); |
106 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab
leDouble::create(3).get())); | 106 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab
leDouble::create(3))); |
107 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex)->equals(Animatable
Double::create(4).get())); | 107 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex)->equals(Animatable
Double::create(4))); |
108 } | 108 } |
109 | 109 |
110 TEST_F(AnimationAnimationStackTest, CancelledAnimationPlayers) | 110 TEST_F(AnimationAnimationStackTest, CancelledAnimationPlayers) |
111 { | 111 { |
112 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAnimat
ionPlayers; | 112 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAnimat
ionPlayers; |
113 RefPtrWillBeRawPtr<AnimationPlayer> player = play(makeAnimation(makeAnimatio
nEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 0); | 113 RefPtrWillBeRawPtr<AnimationPlayer> player = play(makeAnimation(makeAnimatio
nEffect(CSSPropertyFontSize, AnimatableDouble::create(1))), 0); |
114 cancelledAnimationPlayers.add(player.get()); | 114 cancelledAnimationPlayers.add(player.get()); |
115 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))).get(), 0); | 115 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))), 0); |
116 ActiveInterpolationMap result = AnimationStack::activeInterpolations(&elemen
t->elementAnimations()->defaultStack(), 0, &cancelledAnimationPlayers, Animation
::DefaultPriority, 0); | 116 ActiveInterpolationMap result = AnimationStack::activeInterpolations(&elemen
t->elementAnimations()->defaultStack(), 0, &cancelledAnimationPlayers, Animation
::DefaultPriority, 0); |
117 EXPECT_EQ(1u, result.size()); | 117 EXPECT_EQ(1u, result.size()); |
118 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex)->equals(Animatable
Double::create(2).get())); | 118 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex)->equals(Animatable
Double::create(2))); |
119 } | 119 } |
120 | 120 |
121 } | 121 } |
OLD | NEW |