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

Unified Diff: cc/animation/animation_player.cc

Issue 2796013003: cc: Push Animation Finished State and Use Finished State for IsCompleted (Closed)
Patch Set: clear events before update state in unittest Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation_player.cc
diff --git a/cc/animation/animation_player.cc b/cc/animation/animation_player.cc
index 634d64948ae4637ce642ec66a4364a60e88cec81..3174dcbdab096b0c5b8c3269e6a638372bdbfa47 100644
--- a/cc/animation/animation_player.cc
+++ b/cc/animation/animation_player.cc
@@ -374,6 +374,10 @@ bool AnimationPlayer::NotifyAnimationFinished(const AnimationEvent& event) {
}
}
+ // This is for the case when an animation is already removed on main thread,
+ // but the impl version of it sent a finished event and is now waiting for
+ // deletion. We would need to delete that animation during push properties.
+ SetNeedsPushProperties();
return false;
}
@@ -795,6 +799,21 @@ void AnimationPlayer::MarkFinishedAnimations(base::TimeTicks monotonic_time) {
animations_[i]->IsFinishedAt(monotonic_time)) {
animations_[i]->SetRunState(Animation::FINISHED, monotonic_time);
animation_finished = true;
+ SetNeedsPushProperties();
+ }
+ if (!animations_[i]->affects_active_elements() &&
+ !animations_[i]->affects_pending_elements()) {
+ switch (animations_[i]->run_state()) {
+ case Animation::WAITING_FOR_TARGET_AVAILABILITY:
+ case Animation::STARTING:
+ case Animation::RUNNING:
+ case Animation::PAUSED:
+ animations_[i]->SetRunState(Animation::FINISHED, monotonic_time);
+ animation_finished = true;
+ break;
+ default:
+ break;
+ }
}
}
@@ -814,11 +833,6 @@ void AnimationPlayer::ActivateAnimations() {
animations_[i]->set_affects_active_elements(
animations_[i]->affects_pending_elements());
}
- auto affects_no_elements = [](const std::unique_ptr<Animation>& animation) {
- return !animation->affects_active_elements() &&
- !animation->affects_pending_elements();
- };
- base::EraseIf(animations_, affects_no_elements);
if (animation_activated)
element_animations_->UpdateClientAnimationState();
@@ -1151,7 +1165,9 @@ static bool IsCompleted(Animation* animation,
if (animation->is_impl_only()) {
return (animation->run_state() == Animation::WAITING_FOR_DELETION);
} else {
- return !main_thread_player->GetAnimationById(animation->id());
+ Animation* main_thread_animation =
+ main_thread_player->GetAnimationById(animation->id());
+ return !main_thread_animation || main_thread_animation->is_finished();
}
}
« no previous file with comments | « no previous file | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698