Index: cc/animation/element_animations.cc |
diff --git a/cc/animation/element_animations.cc b/cc/animation/element_animations.cc |
index be4b9687d99075a6e8b8aa7cc5c3bdb9e74e164b..d05183b6e20e6640d321110927a9e0351e9afa89 100644 |
--- a/cc/animation/element_animations.cc |
+++ b/cc/animation/element_animations.cc |
@@ -67,6 +67,7 @@ void ElementAnimations::InitAffectedElementTypes() { |
void ElementAnimations::ClearAffectedElementTypes() { |
DCHECK(animation_host_); |
+ OnOpacityIsCurrentlyAnimatingChanged(false); |
if (has_element_in_active_list()) |
OnTransformIsPotentiallyAnimatingChanged(ElementListType::ACTIVE, false); |
set_has_element_in_active_list(false); |
@@ -154,6 +155,9 @@ void ElementAnimations::Animate(base::TimeTicks monotonic_time) { |
StartAnimations(monotonic_time); |
TickAnimations(monotonic_time); |
last_tick_time_ = monotonic_time; |
+ bool some_opacity_animation_is_now_running = !AllOpacityAnimationsEnded(); |
+ if (some_opacity_animation_is_now_running) |
+ OnOpacityIsCurrentlyAnimatingChanged(true); |
} |
void ElementAnimations::AccumulatePropertyUpdates( |
@@ -763,17 +767,21 @@ void ElementAnimations::PromoteStartedAnimations(base::TimeTicks monotonic_time, |
void ElementAnimations::MarkFinishedAnimations(base::TimeTicks monotonic_time) { |
bool finished_transform_animation = false; |
+ bool finished_opacity_animation = false; |
for (size_t i = 0; i < animations_.size(); ++i) { |
if (!animations_[i]->is_finished() && |
animations_[i]->IsFinishedAt(monotonic_time)) { |
animations_[i]->SetRunState(Animation::FINISHED, monotonic_time); |
- if (animations_[i]->target_property() == TargetProperty::TRANSFORM) { |
+ if (animations_[i]->target_property() == TargetProperty::TRANSFORM) |
finished_transform_animation = true; |
- } |
+ else if (animations_[i]->target_property() == TargetProperty::OPACITY) |
+ finished_opacity_animation = true; |
} |
} |
if (finished_transform_animation) |
UpdatePotentiallyAnimatingTransform(); |
+ if (finished_opacity_animation && AllOpacityAnimationsEnded()) |
+ OnOpacityIsCurrentlyAnimatingChanged(false); |
} |
void ElementAnimations::MarkAnimationsForDeletion( |
@@ -1110,6 +1118,15 @@ void ElementAnimations::UpdatePotentiallyAnimatingTransform() { |
changed_for_active_elements, changed_for_pending_elements); |
} |
+bool ElementAnimations::AllOpacityAnimationsEnded() { |
+ for (const auto& animation : animations_) { |
+ if (!animation->is_finished() && animation->InEffect(last_tick_time_) && |
+ animation->target_property() == TargetProperty::OPACITY) |
+ return false; |
+ } |
+ return true; |
+} |
+ |
bool ElementAnimations::HasActiveAnimation() const { |
for (size_t i = 0; i < animations_.size(); ++i) { |
if (!animations_[i]->is_finished()) |
@@ -1164,6 +1181,7 @@ void ElementAnimations::PauseAnimation(int animation_id, |
void ElementAnimations::RemoveAnimation(int animation_id) { |
bool removed_transform_animation = false; |
+ bool removed_opacity_animation = false; |
// Since we want to use the animations that we're going to remove, we need to |
// use a stable_parition here instead of remove_if. Remove_if leaves the |
// removed items in an unspecified state. |
@@ -1178,6 +1196,9 @@ void ElementAnimations::RemoveAnimation(int animation_id) { |
} else if ((*it)->target_property() == TargetProperty::TRANSFORM && |
!(*it)->is_finished()) { |
removed_transform_animation = true; |
+ } else if ((*it)->target_property() == TargetProperty::OPACITY && |
+ !(*it)->is_finished()) { |
+ removed_opacity_animation = true; |
} |
} |
@@ -1185,19 +1206,26 @@ void ElementAnimations::RemoveAnimation(int animation_id) { |
UpdateActivation(NORMAL_ACTIVATION); |
if (removed_transform_animation) |
UpdatePotentiallyAnimatingTransform(); |
+ if (removed_opacity_animation && AllOpacityAnimationsEnded()) |
+ OnOpacityIsCurrentlyAnimatingChanged(false); |
} |
void ElementAnimations::AbortAnimation(int animation_id) { |
bool aborted_transform_animation = false; |
+ bool aborted_opacity_animation = false; |
if (Animation* animation = GetAnimationById(animation_id)) { |
if (!animation->is_finished()) { |
animation->SetRunState(Animation::ABORTED, last_tick_time_); |
if (animation->target_property() == TargetProperty::TRANSFORM) |
aborted_transform_animation = true; |
+ else if (animation->target_property() == TargetProperty::OPACITY) |
+ aborted_opacity_animation = true; |
} |
} |
if (aborted_transform_animation) |
UpdatePotentiallyAnimatingTransform(); |
+ if (aborted_opacity_animation && AllOpacityAnimationsEnded()) |
+ OnOpacityIsCurrentlyAnimatingChanged(false); |
} |
void ElementAnimations::AbortAnimations(TargetProperty::Type target_property, |
@@ -1206,6 +1234,7 @@ void ElementAnimations::AbortAnimations(TargetProperty::Type target_property, |
DCHECK(target_property == TargetProperty::SCROLL_OFFSET); |
bool aborted_transform_animation = false; |
+ bool aborted_opacity_animation = false; |
for (size_t i = 0; i < animations_.size(); ++i) { |
if (animations_[i]->target_property() == target_property && |
!animations_[i]->is_finished()) { |
@@ -1219,10 +1248,14 @@ void ElementAnimations::AbortAnimations(TargetProperty::Type target_property, |
} |
if (target_property == TargetProperty::TRANSFORM) |
aborted_transform_animation = true; |
+ else if (target_property == TargetProperty::OPACITY) |
+ aborted_opacity_animation = true; |
} |
} |
if (aborted_transform_animation) |
UpdatePotentiallyAnimatingTransform(); |
+ if (aborted_opacity_animation && AllOpacityAnimationsEnded()) |
+ OnOpacityIsCurrentlyAnimatingChanged(false); |
} |
Animation* ElementAnimations::GetAnimation( |
@@ -1298,6 +1331,17 @@ void ElementAnimations::OnTransformIsPotentiallyAnimatingChanged( |
is_animating); |
} |
+void ElementAnimations::OnOpacityIsCurrentlyAnimatingChanged( |
+ bool is_currently_animating) { |
+ DCHECK(element_id()); |
+ DCHECK(animation_host()); |
+ if (animation_host()->mutator_host_client()) |
+ animation_host() |
+ ->mutator_host_client() |
+ ->ElementOpacityIsCurrentlyAnimatingChanged(element_id(), |
+ is_currently_animating); |
+} |
+ |
void ElementAnimations::NotifyPlayersAnimationStarted( |
base::TimeTicks monotonic_time, |
TargetProperty::Type target_property, |