Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: cc/animation/element_animations.cc

Issue 2340923003: CC Animation: Rework iterations over players to use the range-based for loop. (Closed)
Patch Set: Rebase. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "cc/animation/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "cc/animation/animation_delegate.h" 13 #include "cc/animation/animation_delegate.h"
14 #include "cc/animation/animation_events.h" 14 #include "cc/animation/animation_events.h"
15 #include "cc/animation/animation_host.h" 15 #include "cc/animation/animation_host.h"
16 #include "cc/animation/animation_player.h" 16 #include "cc/animation/animation_player.h"
17 #include "cc/animation/keyframed_animation_curve.h" 17 #include "cc/animation/keyframed_animation_curve.h"
18 #include "cc/output/filter_operations.h" 18 #include "cc/output/filter_operations.h"
19 #include "cc/trees/mutator_host_client.h" 19 #include "cc/trees/mutator_host_client.h"
20 #include "ui/gfx/geometry/box_f.h" 20 #include "ui/gfx/geometry/box_f.h"
21 21
22 namespace cc { 22 namespace cc {
23 23
24 scoped_refptr<ElementAnimations> ElementAnimations::Create() { 24 scoped_refptr<ElementAnimations> ElementAnimations::Create() {
25 return make_scoped_refptr(new ElementAnimations()); 25 return make_scoped_refptr(new ElementAnimations());
26 } 26 }
27 27
28 ElementAnimations::ElementAnimations() 28 ElementAnimations::ElementAnimations()
29 : players_list_(new PlayersList()), 29 : animation_host_(),
30 animation_host_(),
31 element_id_(), 30 element_id_(),
32 is_active_(false), 31 is_active_(false),
33 has_element_in_active_list_(false), 32 has_element_in_active_list_(false),
34 has_element_in_pending_list_(false), 33 has_element_in_pending_list_(false),
35 scroll_offset_animation_was_interrupted_(false), 34 scroll_offset_animation_was_interrupted_(false),
36 needs_push_properties_(false), 35 needs_push_properties_(false),
37 needs_update_impl_client_state_(false) {} 36 needs_update_impl_client_state_(false) {}
38 37
39 ElementAnimations::~ElementAnimations() {} 38 ElementAnimations::~ElementAnimations() {}
40 39
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (list_type == ElementListType::ACTIVE) 115 if (list_type == ElementListType::ACTIVE)
117 set_has_element_in_active_list(false); 116 set_has_element_in_active_list(false);
118 else 117 else
119 set_has_element_in_pending_list(false); 118 set_has_element_in_pending_list(false);
120 119
121 if (!has_element_in_any_list()) 120 if (!has_element_in_any_list())
122 animation_host_->DidDeactivateElementAnimations(this); 121 animation_host_->DidDeactivateElementAnimations(this);
123 } 122 }
124 123
125 void ElementAnimations::AddPlayer(AnimationPlayer* player) { 124 void ElementAnimations::AddPlayer(AnimationPlayer* player) {
126 players_list_->AddObserver(player); 125 players_list_.AddObserver(player);
127 } 126 }
128 127
129 void ElementAnimations::RemovePlayer(AnimationPlayer* player) { 128 void ElementAnimations::RemovePlayer(AnimationPlayer* player) {
130 players_list_->RemoveObserver(player); 129 players_list_.RemoveObserver(player);
131 } 130 }
132 131
133 bool ElementAnimations::IsEmpty() const { 132 bool ElementAnimations::IsEmpty() const {
134 return !players_list_->might_have_observers(); 133 return !players_list_.might_have_observers();
135 } 134 }
136 135
137 void ElementAnimations::SetNeedsPushProperties() { 136 void ElementAnimations::SetNeedsPushProperties() {
138 needs_push_properties_ = true; 137 needs_push_properties_ = true;
139 } 138 }
140 139
141 void ElementAnimations::PushPropertiesTo( 140 void ElementAnimations::PushPropertiesTo(
142 scoped_refptr<ElementAnimations> element_animations_impl) { 141 scoped_refptr<ElementAnimations> element_animations_impl) {
143 DCHECK_NE(this, element_animations_impl); 142 DCHECK_NE(this, element_animations_impl);
144 143
(...skipping 12 matching lines...) Expand all
157 156
158 element_animations_impl->UpdateActivation(ActivationType::NORMAL); 157 element_animations_impl->UpdateActivation(ActivationType::NORMAL);
159 UpdateActivation(ActivationType::NORMAL); 158 UpdateActivation(ActivationType::NORMAL);
160 } 159 }
161 160
162 void ElementAnimations::Animate(base::TimeTicks monotonic_time) { 161 void ElementAnimations::Animate(base::TimeTicks monotonic_time) {
163 DCHECK(!monotonic_time.is_null()); 162 DCHECK(!monotonic_time.is_null());
164 if (!has_element_in_active_list() && !has_element_in_pending_list()) 163 if (!has_element_in_active_list() && !has_element_in_pending_list())
165 return; 164 return;
166 165
167 { 166 for (auto& player : players_list_) {
168 // TODO(crbug.com/634916): Shouldn't manually iterate through the list if 167 if (player.needs_to_start_animations())
169 // base::ObserverList has a callback mechanism. 168 player.StartAnimations(monotonic_time);
170 ElementAnimations::PlayersList::Iterator it(players_list_.get());
171 AnimationPlayer* player;
172 while ((player = it.GetNext()) != nullptr) {
173 if (player->needs_to_start_animations())
174 player->StartAnimations(monotonic_time);
175 }
176 } 169 }
177 { 170
178 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 171 for (auto& player : players_list_)
179 AnimationPlayer* player; 172 player.TickAnimations(monotonic_time);
180 while ((player = it.GetNext()) != nullptr) 173
181 player->TickAnimations(monotonic_time);
182 }
183 last_tick_time_ = monotonic_time; 174 last_tick_time_ = monotonic_time;
184 UpdateClientAnimationState(); 175 UpdateClientAnimationState();
185 } 176 }
186 177
187 void ElementAnimations::UpdateState(bool start_ready_animations, 178 void ElementAnimations::UpdateState(bool start_ready_animations,
188 AnimationEvents* events) { 179 AnimationEvents* events) {
189 if (!has_element_in_active_list()) 180 if (!has_element_in_active_list())
190 return; 181 return;
191 182
192 // Animate hasn't been called, this happens if an element has been added 183 // Animate hasn't been called, this happens if an element has been added
193 // between the Commit and Draw phases. 184 // between the Commit and Draw phases.
194 if (last_tick_time_ == base::TimeTicks()) 185 if (last_tick_time_ == base::TimeTicks())
195 return; 186 return;
196 187
197 if (start_ready_animations) { 188 if (start_ready_animations) {
198 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 189 for (auto& player : players_list_)
199 AnimationPlayer* player; 190 player.PromoteStartedAnimations(last_tick_time_, events);
200 while ((player = it.GetNext()) != nullptr)
201 player->PromoteStartedAnimations(last_tick_time_, events);
202 } 191 }
203 192
204 { 193 for (auto& player : players_list_)
205 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 194 player.MarkFinishedAnimations(last_tick_time_);
206 AnimationPlayer* player; 195
207 while ((player = it.GetNext()) != nullptr) 196 for (auto& player : players_list_)
208 player->MarkFinishedAnimations(last_tick_time_); 197 player.MarkAnimationsForDeletion(last_tick_time_, events);
209 }
210 {
211 ElementAnimations::PlayersList::Iterator it(players_list_.get());
212 AnimationPlayer* player;
213 while ((player = it.GetNext()) != nullptr)
214 player->MarkAnimationsForDeletion(last_tick_time_, events);
215 }
216 198
217 if (start_ready_animations) { 199 if (start_ready_animations) {
218 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 200 for (auto& player : players_list_) {
219 AnimationPlayer* player; 201 if (player.needs_to_start_animations()) {
220 while ((player = it.GetNext()) != nullptr) { 202 player.StartAnimations(last_tick_time_);
221 if (player->needs_to_start_animations()) { 203 player.PromoteStartedAnimations(last_tick_time_, events);
222 player->StartAnimations(last_tick_time_);
223 player->PromoteStartedAnimations(last_tick_time_, events);
224 } 204 }
225 } 205 }
226 } 206 }
227 207
228 UpdateActivation(ActivationType::NORMAL); 208 UpdateActivation(ActivationType::NORMAL);
229 } 209 }
230 210
231 void ElementAnimations::ActivateAnimations() { 211 void ElementAnimations::ActivateAnimations() {
232 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 212 for (auto& player : players_list_)
233 AnimationPlayer* player; 213 player.ActivateAnimations();
234 while ((player = it.GetNext()) != nullptr)
235 player->ActivateAnimations();
236 214
237 scroll_offset_animation_was_interrupted_ = false; 215 scroll_offset_animation_was_interrupted_ = false;
238 UpdateActivation(ActivationType::NORMAL); 216 UpdateActivation(ActivationType::NORMAL);
239 } 217 }
240 218
241 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { 219 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) {
242 DCHECK(!event.is_impl_only); 220 DCHECK(!event.is_impl_only);
243 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 221 for (auto& player : players_list_) {
244 AnimationPlayer* player; 222 if (player.NotifyAnimationStarted(event))
245 while ((player = it.GetNext()) != nullptr) {
246 if (player->NotifyAnimationStarted(event))
247 break; 223 break;
248 } 224 }
249 } 225 }
250 226
251 void ElementAnimations::NotifyAnimationFinished(const AnimationEvent& event) { 227 void ElementAnimations::NotifyAnimationFinished(const AnimationEvent& event) {
252 DCHECK(!event.is_impl_only); 228 DCHECK(!event.is_impl_only);
253 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 229 for (auto& player : players_list_) {
254 AnimationPlayer* player; 230 if (player.NotifyAnimationFinished(event))
255 while ((player = it.GetNext()) != nullptr) {
256 if (player->NotifyAnimationFinished(event))
257 break; 231 break;
258 } 232 }
259 } 233 }
260 234
261 void ElementAnimations::NotifyAnimationTakeover(const AnimationEvent& event) { 235 void ElementAnimations::NotifyAnimationTakeover(const AnimationEvent& event) {
262 DCHECK(!event.is_impl_only); 236 DCHECK(!event.is_impl_only);
263 DCHECK(event.target_property == TargetProperty::SCROLL_OFFSET); 237 DCHECK(event.target_property == TargetProperty::SCROLL_OFFSET);
264 238
265 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 239 for (auto& player : players_list_)
266 AnimationPlayer* player; 240 player.NotifyAnimationTakeover(event);
267 while ((player = it.GetNext()) != nullptr)
268 player->NotifyAnimationTakeover(event);
269 } 241 }
270 242
271 void ElementAnimations::NotifyAnimationAborted(const AnimationEvent& event) { 243 void ElementAnimations::NotifyAnimationAborted(const AnimationEvent& event) {
272 DCHECK(!event.is_impl_only); 244 DCHECK(!event.is_impl_only);
273 245
274 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 246 for (auto& player : players_list_) {
275 AnimationPlayer* player; 247 if (player.NotifyAnimationAborted(event))
276 while ((player = it.GetNext()) != nullptr) {
277 if (player->NotifyAnimationAborted(event))
278 break; 248 break;
279 } 249 }
280 250
281 UpdateClientAnimationState(); 251 UpdateClientAnimationState();
282 } 252 }
283 253
284 void ElementAnimations::NotifyAnimationPropertyUpdate( 254 void ElementAnimations::NotifyAnimationPropertyUpdate(
285 const AnimationEvent& event) { 255 const AnimationEvent& event) {
286 DCHECK(!event.is_impl_only); 256 DCHECK(!event.is_impl_only);
287 bool notify_active_elements = true; 257 bool notify_active_elements = true;
288 bool notify_pending_elements = true; 258 bool notify_pending_elements = true;
289 switch (event.target_property) { 259 switch (event.target_property) {
290 case TargetProperty::OPACITY: 260 case TargetProperty::OPACITY:
291 NotifyClientOpacityAnimated(event.opacity, notify_active_elements, 261 NotifyClientOpacityAnimated(event.opacity, notify_active_elements,
292 notify_pending_elements); 262 notify_pending_elements);
293 break; 263 break;
294 case TargetProperty::TRANSFORM: 264 case TargetProperty::TRANSFORM:
295 NotifyClientTransformAnimated(event.transform, notify_active_elements, 265 NotifyClientTransformAnimated(event.transform, notify_active_elements,
296 notify_pending_elements); 266 notify_pending_elements);
297 break; 267 break;
298 default: 268 default:
299 NOTREACHED(); 269 NOTREACHED();
300 } 270 }
301 } 271 }
302 272
303 bool ElementAnimations::HasFilterAnimationThatInflatesBounds() const { 273 bool ElementAnimations::HasFilterAnimationThatInflatesBounds() const {
304 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 274 for (auto& player : players_list_) {
305 AnimationPlayer* player; 275 if (player.HasFilterAnimationThatInflatesBounds())
306 while ((player = it.GetNext()) != nullptr) {
307 if (player->HasFilterAnimationThatInflatesBounds())
308 return true; 276 return true;
309 } 277 }
310 return false; 278 return false;
311 } 279 }
312 280
313 bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const { 281 bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const {
314 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 282 for (auto& player : players_list_) {
315 AnimationPlayer* player; 283 if (player.HasTransformAnimationThatInflatesBounds())
316 while ((player = it.GetNext()) != nullptr) {
317 if (player->HasTransformAnimationThatInflatesBounds())
318 return true; 284 return true;
319 } 285 }
320 return false; 286 return false;
321 } 287 }
322 288
323 bool ElementAnimations::FilterAnimationBoundsForBox(const gfx::BoxF& box, 289 bool ElementAnimations::FilterAnimationBoundsForBox(const gfx::BoxF& box,
324 gfx::BoxF* bounds) const { 290 gfx::BoxF* bounds) const {
325 // TODO(avallee): Implement. 291 // TODO(avallee): Implement.
326 return false; 292 return false;
327 } 293 }
328 294
329 bool ElementAnimations::TransformAnimationBoundsForBox( 295 bool ElementAnimations::TransformAnimationBoundsForBox(
330 const gfx::BoxF& box, 296 const gfx::BoxF& box,
331 gfx::BoxF* bounds) const { 297 gfx::BoxF* bounds) const {
332 *bounds = gfx::BoxF(); 298 *bounds = gfx::BoxF();
333 299
334 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 300 for (auto& player : players_list_) {
335 AnimationPlayer* player;
336 while ((player = it.GetNext()) != nullptr) {
337 gfx::BoxF player_bounds; 301 gfx::BoxF player_bounds;
338 bool success = player->TransformAnimationBoundsForBox(box, &player_bounds); 302 bool success = player.TransformAnimationBoundsForBox(box, &player_bounds);
339 if (!success) 303 if (!success)
340 return false; 304 return false;
341 bounds->Union(player_bounds); 305 bounds->Union(player_bounds);
342 } 306 }
343 return true; 307 return true;
344 } 308 }
345 309
346 bool ElementAnimations::HasOnlyTranslationTransforms( 310 bool ElementAnimations::HasOnlyTranslationTransforms(
347 ElementListType list_type) const { 311 ElementListType list_type) const {
348 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 312 for (auto& player : players_list_) {
349 AnimationPlayer* player; 313 if (!player.HasOnlyTranslationTransforms(list_type))
350 while ((player = it.GetNext()) != nullptr) {
351 if (!player->HasOnlyTranslationTransforms(list_type))
352 return false; 314 return false;
353 } 315 }
354 return true; 316 return true;
355 } 317 }
356 318
357 bool ElementAnimations::AnimationsPreserveAxisAlignment() const { 319 bool ElementAnimations::AnimationsPreserveAxisAlignment() const {
358 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 320 for (auto& player : players_list_) {
359 AnimationPlayer* player; 321 if (!player.AnimationsPreserveAxisAlignment())
360 while ((player = it.GetNext()) != nullptr) {
361 if (!player->AnimationsPreserveAxisAlignment())
362 return false; 322 return false;
363 } 323 }
364 return true; 324 return true;
365 } 325 }
366 326
367 bool ElementAnimations::AnimationStartScale(ElementListType list_type, 327 bool ElementAnimations::AnimationStartScale(ElementListType list_type,
368 float* start_scale) const { 328 float* start_scale) const {
369 *start_scale = 0.f; 329 *start_scale = 0.f;
370 330
371 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 331 for (auto& player : players_list_) {
372 AnimationPlayer* player;
373 while ((player = it.GetNext()) != nullptr) {
374 float player_start_scale = 0.f; 332 float player_start_scale = 0.f;
375 bool success = player->AnimationStartScale(list_type, &player_start_scale); 333 bool success = player.AnimationStartScale(list_type, &player_start_scale);
376 if (!success) 334 if (!success)
377 return false; 335 return false;
378 // Union: a maximum. 336 // Union: a maximum.
379 *start_scale = std::max(*start_scale, player_start_scale); 337 *start_scale = std::max(*start_scale, player_start_scale);
380 } 338 }
381 339
382 return true; 340 return true;
383 } 341 }
384 342
385 bool ElementAnimations::MaximumTargetScale(ElementListType list_type, 343 bool ElementAnimations::MaximumTargetScale(ElementListType list_type,
386 float* max_scale) const { 344 float* max_scale) const {
387 *max_scale = 0.f; 345 *max_scale = 0.f;
388 346
389 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 347 for (auto& player : players_list_) {
390 AnimationPlayer* player;
391 while ((player = it.GetNext()) != nullptr) {
392 float player_max_scale = 0.f; 348 float player_max_scale = 0.f;
393 bool success = player->MaximumTargetScale(list_type, &player_max_scale); 349 bool success = player.MaximumTargetScale(list_type, &player_max_scale);
394 if (!success) 350 if (!success)
395 return false; 351 return false;
396 // Union: a maximum. 352 // Union: a maximum.
397 *max_scale = std::max(*max_scale, player_max_scale); 353 *max_scale = std::max(*max_scale, player_max_scale);
398 } 354 }
399 355
400 return true; 356 return true;
401 } 357 }
402 358
403 void ElementAnimations::SetNeedsUpdateImplClientState() { 359 void ElementAnimations::SetNeedsUpdateImplClientState() {
404 needs_update_impl_client_state_ = true; 360 needs_update_impl_client_state_ = true;
405 SetNeedsPushProperties(); 361 SetNeedsPushProperties();
406 } 362 }
407 363
408 void ElementAnimations::UpdateActivation(ActivationType type) { 364 void ElementAnimations::UpdateActivation(ActivationType type) {
409 bool force = type == ActivationType::FORCE; 365 bool force = type == ActivationType::FORCE;
410 if (animation_host_) { 366 if (animation_host_) {
411 bool was_active = is_active_; 367 bool was_active = is_active_;
412 is_active_ = false; 368 is_active_ = false;
413 369
414 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 370 for (auto& player : players_list_) {
415 AnimationPlayer* player; 371 if (player.HasNonDeletedAnimation()) {
416 while ((player = it.GetNext()) != nullptr) {
417 if (player->HasNonDeletedAnimation()) {
418 is_active_ = true; 372 is_active_ = true;
419 break; 373 break;
420 } 374 }
421 } 375 }
422 376
423 if (is_active_ && (!was_active || force)) { 377 if (is_active_ && (!was_active || force)) {
424 animation_host_->DidActivateElementAnimations(this); 378 animation_host_->DidActivateElementAnimations(this);
425 } else if (!is_active_ && (was_active || force)) { 379 } else if (!is_active_ && (was_active || force)) {
426 // Resetting last_tick_time_ here ensures that calling ::UpdateState 380 // Resetting last_tick_time_ here ensures that calling ::UpdateState
427 // before ::Animate doesn't start an animation. 381 // before ::Animate doesn't start an animation.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 DCHECK(animation_host()); 435 DCHECK(animation_host());
482 if (!animation_host()->mutator_host_client()) 436 if (!animation_host()->mutator_host_client())
483 return; 437 return;
484 438
485 PropertyAnimationState prev_pending = pending_state_; 439 PropertyAnimationState prev_pending = pending_state_;
486 PropertyAnimationState prev_active = active_state_; 440 PropertyAnimationState prev_active = active_state_;
487 441
488 pending_state_.Clear(); 442 pending_state_.Clear();
489 active_state_.Clear(); 443 active_state_.Clear();
490 444
491 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 445 for (auto& player : players_list_) {
492 AnimationPlayer* player;
493 while ((player = it.GetNext()) != nullptr) {
494 PropertyAnimationState player_pending_state, player_active_state; 446 PropertyAnimationState player_pending_state, player_active_state;
495 player->GetPropertyAnimationState(&player_pending_state, 447 player.GetPropertyAnimationState(&player_pending_state,
496 &player_active_state); 448 &player_active_state);
497 pending_state_ |= player_pending_state; 449 pending_state_ |= player_pending_state;
498 active_state_ |= player_active_state; 450 active_state_ |= player_active_state;
499 } 451 }
500 452
501 TargetProperties allowed_properties = GetPropertiesMaskForAnimationState(); 453 TargetProperties allowed_properties = GetPropertiesMaskForAnimationState();
502 PropertyAnimationState allowed_state; 454 PropertyAnimationState allowed_state;
503 allowed_state.currently_running = allowed_properties; 455 allowed_state.currently_running = allowed_properties;
504 allowed_state.potentially_animating = allowed_properties; 456 allowed_state.potentially_animating = allowed_properties;
505 457
506 pending_state_ &= allowed_state; 458 pending_state_ &= allowed_state;
507 active_state_ &= allowed_state; 459 active_state_ &= allowed_state;
508 460
509 DCHECK(pending_state_.IsValid()); 461 DCHECK(pending_state_.IsValid());
510 DCHECK(active_state_.IsValid()); 462 DCHECK(active_state_.IsValid());
511 463
512 if (has_element_in_active_list() && prev_active != active_state_) { 464 if (has_element_in_active_list() && prev_active != active_state_) {
513 PropertyAnimationState diff_active = prev_active ^ active_state_; 465 PropertyAnimationState diff_active = prev_active ^ active_state_;
514 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( 466 animation_host()->mutator_host_client()->ElementIsAnimatingChanged(
515 element_id(), ElementListType::ACTIVE, diff_active, active_state_); 467 element_id(), ElementListType::ACTIVE, diff_active, active_state_);
516 } 468 }
517 if (has_element_in_pending_list() && prev_pending != pending_state_) { 469 if (has_element_in_pending_list() && prev_pending != pending_state_) {
518 PropertyAnimationState diff_pending = prev_pending ^ pending_state_; 470 PropertyAnimationState diff_pending = prev_pending ^ pending_state_;
519 animation_host()->mutator_host_client()->ElementIsAnimatingChanged( 471 animation_host()->mutator_host_client()->ElementIsAnimatingChanged(
520 element_id(), ElementListType::PENDING, diff_pending, pending_state_); 472 element_id(), ElementListType::PENDING, diff_pending, pending_state_);
521 } 473 }
522 } 474 }
523 475
524 bool ElementAnimations::HasActiveAnimation() const { 476 bool ElementAnimations::HasActiveAnimation() const {
525 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 477 for (auto& player : players_list_) {
526 AnimationPlayer* player; 478 if (player.HasActiveAnimation())
527 while ((player = it.GetNext()) != nullptr) {
528 if (player->HasActiveAnimation())
529 return true; 479 return true;
530 } 480 }
531 481
532 return false; 482 return false;
533 } 483 }
534 484
535 bool ElementAnimations::HasAnyAnimation() const { 485 bool ElementAnimations::HasAnyAnimation() const {
536 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 486 for (auto& player : players_list_) {
537 AnimationPlayer* player; 487 if (player.has_any_animation())
538 while ((player = it.GetNext()) != nullptr) {
539 if (player->has_any_animation())
540 return true; 488 return true;
541 } 489 }
542 490
543 return false; 491 return false;
544 } 492 }
545 493
546 bool ElementAnimations::HasAnyAnimationTargetingProperty( 494 bool ElementAnimations::HasAnyAnimationTargetingProperty(
547 TargetProperty::Type property) const { 495 TargetProperty::Type property) const {
548 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 496 for (auto& player : players_list_) {
549 AnimationPlayer* player; 497 if (player.GetAnimation(property))
550 while ((player = it.GetNext()) != nullptr) {
551 if (player->GetAnimation(property))
552 return true; 498 return true;
553 } 499 }
554 return false; 500 return false;
555 } 501 }
556 502
557 bool ElementAnimations::IsPotentiallyAnimatingProperty( 503 bool ElementAnimations::IsPotentiallyAnimatingProperty(
558 TargetProperty::Type target_property, 504 TargetProperty::Type target_property,
559 ElementListType list_type) const { 505 ElementListType list_type) const {
560 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 506 for (auto& player : players_list_) {
561 AnimationPlayer* player; 507 if (player.IsPotentiallyAnimatingProperty(target_property, list_type))
562 while ((player = it.GetNext()) != nullptr) {
563 if (player->IsPotentiallyAnimatingProperty(target_property, list_type))
564 return true; 508 return true;
565 } 509 }
566 510
567 return false; 511 return false;
568 } 512 }
569 513
570 bool ElementAnimations::IsCurrentlyAnimatingProperty( 514 bool ElementAnimations::IsCurrentlyAnimatingProperty(
571 TargetProperty::Type target_property, 515 TargetProperty::Type target_property,
572 ElementListType list_type) const { 516 ElementListType list_type) const {
573 ElementAnimations::PlayersList::Iterator it(players_list_.get()); 517 for (auto& player : players_list_) {
574 AnimationPlayer* player; 518 if (player.IsCurrentlyAnimatingProperty(target_property, list_type))
575 while ((player = it.GetNext()) != nullptr) {
576 if (player->IsCurrentlyAnimatingProperty(target_property, list_type))
577 return true; 519 return true;
578 } 520 }
579 521
580 return false; 522 return false;
581 } 523 }
582 524
583 void ElementAnimations::SetScrollOffsetAnimationWasInterrupted() { 525 void ElementAnimations::SetScrollOffsetAnimationWasInterrupted() {
584 scroll_offset_animation_was_interrupted_ = true; 526 scroll_offset_animation_was_interrupted_ = true;
585 } 527 }
586 528
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 if (animation_host()) { 567 if (animation_host()) {
626 DCHECK(animation_host()->mutator_host_client()); 568 DCHECK(animation_host()->mutator_host_client());
627 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( 569 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation(
628 element_id()); 570 element_id());
629 } 571 }
630 572
631 return gfx::ScrollOffset(); 573 return gfx::ScrollOffset();
632 } 574 }
633 575
634 } // namespace cc 576 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698