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 "core/animation/AnimationStack.h" | 5 #include "core/animation/AnimationStack.h" |
6 | 6 |
7 #include "core/animation/AnimationClock.h" | 7 #include "core/animation/AnimationClock.h" |
8 #include "core/animation/CompositorPendingAnimations.h" | 8 #include "core/animation/CompositorPendingAnimations.h" |
9 #include "core/animation/DocumentTimeline.h" | 9 #include "core/animation/DocumentTimeline.h" |
10 #include "core/animation/ElementAnimations.h" | 10 #include "core/animation/ElementAnimations.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))), | 91 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))), |
92 10); | 92 10); |
93 play(makeKeyframeEffect( | 93 play(makeKeyframeEffect( |
94 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(2))), | 94 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(2))), |
95 15); | 95 15); |
96 play(makeKeyframeEffect( | 96 play(makeKeyframeEffect( |
97 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))), | 97 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))), |
98 5); | 98 5); |
99 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( | 99 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( |
100 &element->elementAnimations()->animationStack(), 0, 0, | 100 &element->elementAnimations()->animationStack(), 0, 0, |
101 KeyframeEffect::DefaultPriority); | 101 KeyframeEffectReadOnly::DefaultPriority); |
102 EXPECT_EQ(1u, result.size()); | 102 EXPECT_EQ(1u, result.size()); |
103 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize) | 103 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize) |
104 ->equals(AnimatableDouble::create(3).get())); | 104 ->equals(AnimatableDouble::create(3).get())); |
105 } | 105 } |
106 | 106 |
107 TEST_F(AnimationAnimationStackTest, NewAnimations) { | 107 TEST_F(AnimationAnimationStackTest, NewAnimations) { |
108 play(makeKeyframeEffect( | 108 play(makeKeyframeEffect( |
109 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))), | 109 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))), |
110 15); | 110 15); |
111 play(makeKeyframeEffect( | 111 play(makeKeyframeEffect( |
112 makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(2))), | 112 makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(2))), |
113 10); | 113 10); |
114 HeapVector<Member<const InertEffect>> newAnimations; | 114 HeapVector<Member<const InertEffect>> newAnimations; |
115 InertEffect* inert1 = makeInertEffect( | 115 InertEffect* inert1 = makeInertEffect( |
116 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))); | 116 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))); |
117 InertEffect* inert2 = makeInertEffect( | 117 InertEffect* inert2 = makeInertEffect( |
118 makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(4))); | 118 makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(4))); |
119 newAnimations.append(inert1); | 119 newAnimations.append(inert1); |
120 newAnimations.append(inert2); | 120 newAnimations.append(inert2); |
121 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( | 121 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( |
122 &element->elementAnimations()->animationStack(), &newAnimations, 0, | 122 &element->elementAnimations()->animationStack(), &newAnimations, 0, |
123 KeyframeEffect::DefaultPriority); | 123 KeyframeEffectReadOnly::DefaultPriority); |
124 EXPECT_EQ(2u, result.size()); | 124 EXPECT_EQ(2u, result.size()); |
125 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize) | 125 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize) |
126 ->equals(AnimatableDouble::create(3).get())); | 126 ->equals(AnimatableDouble::create(3).get())); |
127 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex) | 127 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex) |
128 ->equals(AnimatableDouble::create(4).get())); | 128 ->equals(AnimatableDouble::create(4).get())); |
129 } | 129 } |
130 | 130 |
131 TEST_F(AnimationAnimationStackTest, CancelledAnimations) { | 131 TEST_F(AnimationAnimationStackTest, CancelledAnimations) { |
132 HeapHashSet<Member<const Animation>> cancelledAnimations; | 132 HeapHashSet<Member<const Animation>> cancelledAnimations; |
133 Animation* animation = | 133 Animation* animation = |
134 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, | 134 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, |
135 AnimatableDouble::create(1))), | 135 AnimatableDouble::create(1))), |
136 0); | 136 0); |
137 cancelledAnimations.add(animation); | 137 cancelledAnimations.add(animation); |
138 play(makeKeyframeEffect( | 138 play(makeKeyframeEffect( |
139 makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(2))), | 139 makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(2))), |
140 0); | 140 0); |
141 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( | 141 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( |
142 &element->elementAnimations()->animationStack(), 0, &cancelledAnimations, | 142 &element->elementAnimations()->animationStack(), 0, &cancelledAnimations, |
143 KeyframeEffect::DefaultPriority); | 143 KeyframeEffectReadOnly::DefaultPriority); |
144 EXPECT_EQ(1u, result.size()); | 144 EXPECT_EQ(1u, result.size()); |
145 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex) | 145 EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex) |
146 ->equals(AnimatableDouble::create(2).get())); | 146 ->equals(AnimatableDouble::create(2).get())); |
147 } | 147 } |
148 | 148 |
149 TEST_F(AnimationAnimationStackTest, ClearedEffectsRemoved) { | 149 TEST_F(AnimationAnimationStackTest, ClearedEffectsRemoved) { |
150 Animation* animation = | 150 Animation* animation = |
151 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, | 151 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, |
152 AnimatableDouble::create(1))), | 152 AnimatableDouble::create(1))), |
153 10); | 153 10); |
154 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( | 154 ActiveInterpolationsMap result = AnimationStack::activeInterpolations( |
155 &element->elementAnimations()->animationStack(), 0, 0, | 155 &element->elementAnimations()->animationStack(), 0, 0, |
156 KeyframeEffect::DefaultPriority); | 156 KeyframeEffectReadOnly::DefaultPriority); |
157 EXPECT_EQ(1u, result.size()); | 157 EXPECT_EQ(1u, result.size()); |
158 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize) | 158 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize) |
159 ->equals(AnimatableDouble::create(1).get())); | 159 ->equals(AnimatableDouble::create(1).get())); |
160 | 160 |
161 animation->setEffect(0); | 161 animation->setEffect(0); |
162 result = AnimationStack::activeInterpolations( | 162 result = AnimationStack::activeInterpolations( |
163 &element->elementAnimations()->animationStack(), 0, 0, | 163 &element->elementAnimations()->animationStack(), 0, 0, |
164 KeyframeEffect::DefaultPriority); | 164 KeyframeEffectReadOnly::DefaultPriority); |
165 EXPECT_EQ(0u, result.size()); | 165 EXPECT_EQ(0u, result.size()); |
166 } | 166 } |
167 | 167 |
168 TEST_F(AnimationAnimationStackTest, ForwardsFillDiscarding) { | 168 TEST_F(AnimationAnimationStackTest, ForwardsFillDiscarding) { |
169 play(makeKeyframeEffect( | 169 play(makeKeyframeEffect( |
170 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))), | 170 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))), |
171 2); | 171 2); |
172 play(makeKeyframeEffect( | 172 play(makeKeyframeEffect( |
173 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(2))), | 173 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(2))), |
174 6); | 174 6); |
175 play(makeKeyframeEffect( | 175 play(makeKeyframeEffect( |
176 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))), | 176 makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))), |
177 4); | 177 4); |
178 document->compositorPendingAnimations().update(); | 178 document->compositorPendingAnimations().update(); |
179 ActiveInterpolationsMap interpolations; | 179 ActiveInterpolationsMap interpolations; |
180 | 180 |
181 updateTimeline(11); | 181 updateTimeline(11); |
182 ThreadState::current()->collectAllGarbage(); | 182 ThreadState::current()->collectAllGarbage(); |
183 interpolations = AnimationStack::activeInterpolations( | 183 interpolations = AnimationStack::activeInterpolations( |
184 &element->elementAnimations()->animationStack(), nullptr, nullptr, | 184 &element->elementAnimations()->animationStack(), nullptr, nullptr, |
185 KeyframeEffect::DefaultPriority); | 185 KeyframeEffectReadOnly::DefaultPriority); |
186 EXPECT_EQ(1u, interpolations.size()); | 186 EXPECT_EQ(1u, interpolations.size()); |
187 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) | 187 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) |
188 ->equals(AnimatableDouble::create(3).get())); | 188 ->equals(AnimatableDouble::create(3).get())); |
189 EXPECT_EQ(3u, sampledEffectCount()); | 189 EXPECT_EQ(3u, sampledEffectCount()); |
190 | 190 |
191 updateTimeline(13); | 191 updateTimeline(13); |
192 ThreadState::current()->collectAllGarbage(); | 192 ThreadState::current()->collectAllGarbage(); |
193 interpolations = AnimationStack::activeInterpolations( | 193 interpolations = AnimationStack::activeInterpolations( |
194 &element->elementAnimations()->animationStack(), nullptr, nullptr, | 194 &element->elementAnimations()->animationStack(), nullptr, nullptr, |
195 KeyframeEffect::DefaultPriority); | 195 KeyframeEffectReadOnly::DefaultPriority); |
196 EXPECT_EQ(1u, interpolations.size()); | 196 EXPECT_EQ(1u, interpolations.size()); |
197 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) | 197 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) |
198 ->equals(AnimatableDouble::create(3).get())); | 198 ->equals(AnimatableDouble::create(3).get())); |
199 EXPECT_EQ(3u, sampledEffectCount()); | 199 EXPECT_EQ(3u, sampledEffectCount()); |
200 | 200 |
201 updateTimeline(15); | 201 updateTimeline(15); |
202 ThreadState::current()->collectAllGarbage(); | 202 ThreadState::current()->collectAllGarbage(); |
203 interpolations = AnimationStack::activeInterpolations( | 203 interpolations = AnimationStack::activeInterpolations( |
204 &element->elementAnimations()->animationStack(), nullptr, nullptr, | 204 &element->elementAnimations()->animationStack(), nullptr, nullptr, |
205 KeyframeEffect::DefaultPriority); | 205 KeyframeEffectReadOnly::DefaultPriority); |
206 EXPECT_EQ(1u, interpolations.size()); | 206 EXPECT_EQ(1u, interpolations.size()); |
207 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) | 207 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) |
208 ->equals(AnimatableDouble::create(3).get())); | 208 ->equals(AnimatableDouble::create(3).get())); |
209 EXPECT_EQ(2u, sampledEffectCount()); | 209 EXPECT_EQ(2u, sampledEffectCount()); |
210 | 210 |
211 updateTimeline(17); | 211 updateTimeline(17); |
212 ThreadState::current()->collectAllGarbage(); | 212 ThreadState::current()->collectAllGarbage(); |
213 interpolations = AnimationStack::activeInterpolations( | 213 interpolations = AnimationStack::activeInterpolations( |
214 &element->elementAnimations()->animationStack(), nullptr, nullptr, | 214 &element->elementAnimations()->animationStack(), nullptr, nullptr, |
215 KeyframeEffect::DefaultPriority); | 215 KeyframeEffectReadOnly::DefaultPriority); |
216 EXPECT_EQ(1u, interpolations.size()); | 216 EXPECT_EQ(1u, interpolations.size()); |
217 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) | 217 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize) |
218 ->equals(AnimatableDouble::create(3).get())); | 218 ->equals(AnimatableDouble::create(3).get())); |
219 EXPECT_EQ(1u, sampledEffectCount()); | 219 EXPECT_EQ(1u, sampledEffectCount()); |
220 } | 220 } |
221 | 221 |
222 } // namespace blink | 222 } // namespace blink |
OLD | NEW |