| Index: cc/animation/element_animations.cc
|
| diff --git a/cc/animation/element_animations.cc b/cc/animation/element_animations.cc
|
| index 6b29c31808aae2c0727c223173244244c39ee0f8..ae6fd01e4caaaaa97d92bb289d03b5a46d5f92ce 100644
|
| --- a/cc/animation/element_animations.cc
|
| +++ b/cc/animation/element_animations.cc
|
| @@ -26,8 +26,7 @@ scoped_refptr<ElementAnimations> ElementAnimations::Create() {
|
| }
|
|
|
| ElementAnimations::ElementAnimations()
|
| - : players_list_(new PlayersList()),
|
| - animation_host_(),
|
| + : animation_host_(),
|
| element_id_(),
|
| is_active_(false),
|
| has_element_in_active_list_(false),
|
| @@ -123,15 +122,15 @@ void ElementAnimations::ElementUnregistered(ElementId element_id,
|
| }
|
|
|
| void ElementAnimations::AddPlayer(AnimationPlayer* player) {
|
| - players_list_->AddObserver(player);
|
| + players_list_.AddObserver(player);
|
| }
|
|
|
| void ElementAnimations::RemovePlayer(AnimationPlayer* player) {
|
| - players_list_->RemoveObserver(player);
|
| + players_list_.RemoveObserver(player);
|
| }
|
|
|
| bool ElementAnimations::IsEmpty() const {
|
| - return !players_list_->might_have_observers();
|
| + return !players_list_.might_have_observers();
|
| }
|
|
|
| void ElementAnimations::SetNeedsPushProperties() {
|
| @@ -164,22 +163,14 @@ void ElementAnimations::Animate(base::TimeTicks monotonic_time) {
|
| if (!has_element_in_active_list() && !has_element_in_pending_list())
|
| return;
|
|
|
| - {
|
| - // TODO(crbug.com/634916): Shouldn't manually iterate through the list if
|
| - // base::ObserverList has a callback mechanism.
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->needs_to_start_animations())
|
| - player->StartAnimations(monotonic_time);
|
| - }
|
| - }
|
| - {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr)
|
| - player->TickAnimations(monotonic_time);
|
| + for (auto& player : players_list_) {
|
| + if (player.needs_to_start_animations())
|
| + player.StartAnimations(monotonic_time);
|
| }
|
| +
|
| + for (auto& player : players_list_)
|
| + player.TickAnimations(monotonic_time);
|
| +
|
| last_tick_time_ = monotonic_time;
|
| UpdateClientAnimationState();
|
| }
|
| @@ -195,32 +186,21 @@ void ElementAnimations::UpdateState(bool start_ready_animations,
|
| return;
|
|
|
| if (start_ready_animations) {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr)
|
| - player->PromoteStartedAnimations(last_tick_time_, events);
|
| + for (auto& player : players_list_)
|
| + player.PromoteStartedAnimations(last_tick_time_, events);
|
| }
|
|
|
| - {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr)
|
| - player->MarkFinishedAnimations(last_tick_time_);
|
| - }
|
| - {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr)
|
| - player->MarkAnimationsForDeletion(last_tick_time_, events);
|
| - }
|
| + for (auto& player : players_list_)
|
| + player.MarkFinishedAnimations(last_tick_time_);
|
| +
|
| + for (auto& player : players_list_)
|
| + player.MarkAnimationsForDeletion(last_tick_time_, events);
|
|
|
| if (start_ready_animations) {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->needs_to_start_animations()) {
|
| - player->StartAnimations(last_tick_time_);
|
| - player->PromoteStartedAnimations(last_tick_time_, events);
|
| + for (auto& player : players_list_) {
|
| + if (player.needs_to_start_animations()) {
|
| + player.StartAnimations(last_tick_time_);
|
| + player.PromoteStartedAnimations(last_tick_time_, events);
|
| }
|
| }
|
| }
|
| @@ -229,10 +209,8 @@ void ElementAnimations::UpdateState(bool start_ready_animations,
|
| }
|
|
|
| void ElementAnimations::ActivateAnimations() {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr)
|
| - player->ActivateAnimations();
|
| + for (auto& player : players_list_)
|
| + player.ActivateAnimations();
|
|
|
| scroll_offset_animation_was_interrupted_ = false;
|
| UpdateActivation(ActivationType::NORMAL);
|
| @@ -240,20 +218,16 @@ void ElementAnimations::ActivateAnimations() {
|
|
|
| void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) {
|
| DCHECK(!event.is_impl_only);
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->NotifyAnimationStarted(event))
|
| + for (auto& player : players_list_) {
|
| + if (player.NotifyAnimationStarted(event))
|
| break;
|
| }
|
| }
|
|
|
| void ElementAnimations::NotifyAnimationFinished(const AnimationEvent& event) {
|
| DCHECK(!event.is_impl_only);
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->NotifyAnimationFinished(event))
|
| + for (auto& player : players_list_) {
|
| + if (player.NotifyAnimationFinished(event))
|
| break;
|
| }
|
| }
|
| @@ -262,19 +236,15 @@ void ElementAnimations::NotifyAnimationTakeover(const AnimationEvent& event) {
|
| DCHECK(!event.is_impl_only);
|
| DCHECK(event.target_property == TargetProperty::SCROLL_OFFSET);
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr)
|
| - player->NotifyAnimationTakeover(event);
|
| + for (auto& player : players_list_)
|
| + player.NotifyAnimationTakeover(event);
|
| }
|
|
|
| void ElementAnimations::NotifyAnimationAborted(const AnimationEvent& event) {
|
| DCHECK(!event.is_impl_only);
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->NotifyAnimationAborted(event))
|
| + for (auto& player : players_list_) {
|
| + if (player.NotifyAnimationAborted(event))
|
| break;
|
| }
|
|
|
| @@ -301,20 +271,16 @@ void ElementAnimations::NotifyAnimationPropertyUpdate(
|
| }
|
|
|
| bool ElementAnimations::HasFilterAnimationThatInflatesBounds() const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->HasFilterAnimationThatInflatesBounds())
|
| + for (auto& player : players_list_) {
|
| + if (player.HasFilterAnimationThatInflatesBounds())
|
| return true;
|
| }
|
| return false;
|
| }
|
|
|
| bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->HasTransformAnimationThatInflatesBounds())
|
| + for (auto& player : players_list_) {
|
| + if (player.HasTransformAnimationThatInflatesBounds())
|
| return true;
|
| }
|
| return false;
|
| @@ -331,11 +297,9 @@ bool ElementAnimations::TransformAnimationBoundsForBox(
|
| gfx::BoxF* bounds) const {
|
| *bounds = gfx::BoxF();
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| + for (auto& player : players_list_) {
|
| gfx::BoxF player_bounds;
|
| - bool success = player->TransformAnimationBoundsForBox(box, &player_bounds);
|
| + bool success = player.TransformAnimationBoundsForBox(box, &player_bounds);
|
| if (!success)
|
| return false;
|
| bounds->Union(player_bounds);
|
| @@ -345,20 +309,16 @@ bool ElementAnimations::TransformAnimationBoundsForBox(
|
|
|
| bool ElementAnimations::HasOnlyTranslationTransforms(
|
| ElementListType list_type) const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (!player->HasOnlyTranslationTransforms(list_type))
|
| + for (auto& player : players_list_) {
|
| + if (!player.HasOnlyTranslationTransforms(list_type))
|
| return false;
|
| }
|
| return true;
|
| }
|
|
|
| bool ElementAnimations::AnimationsPreserveAxisAlignment() const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (!player->AnimationsPreserveAxisAlignment())
|
| + for (auto& player : players_list_) {
|
| + if (!player.AnimationsPreserveAxisAlignment())
|
| return false;
|
| }
|
| return true;
|
| @@ -368,11 +328,9 @@ bool ElementAnimations::AnimationStartScale(ElementListType list_type,
|
| float* start_scale) const {
|
| *start_scale = 0.f;
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| + for (auto& player : players_list_) {
|
| float player_start_scale = 0.f;
|
| - bool success = player->AnimationStartScale(list_type, &player_start_scale);
|
| + bool success = player.AnimationStartScale(list_type, &player_start_scale);
|
| if (!success)
|
| return false;
|
| // Union: a maximum.
|
| @@ -386,11 +344,9 @@ bool ElementAnimations::MaximumTargetScale(ElementListType list_type,
|
| float* max_scale) const {
|
| *max_scale = 0.f;
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| + for (auto& player : players_list_) {
|
| float player_max_scale = 0.f;
|
| - bool success = player->MaximumTargetScale(list_type, &player_max_scale);
|
| + bool success = player.MaximumTargetScale(list_type, &player_max_scale);
|
| if (!success)
|
| return false;
|
| // Union: a maximum.
|
| @@ -411,10 +367,8 @@ void ElementAnimations::UpdateActivation(ActivationType type) {
|
| bool was_active = is_active_;
|
| is_active_ = false;
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->HasNonDeletedAnimation()) {
|
| + for (auto& player : players_list_) {
|
| + if (player.HasNonDeletedAnimation()) {
|
| is_active_ = true;
|
| break;
|
| }
|
| @@ -488,12 +442,10 @@ void ElementAnimations::UpdateClientAnimationState() {
|
| pending_state_.Clear();
|
| active_state_.Clear();
|
|
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| + for (auto& player : players_list_) {
|
| PropertyAnimationState player_pending_state, player_active_state;
|
| - player->GetPropertyAnimationState(&player_pending_state,
|
| - &player_active_state);
|
| + player.GetPropertyAnimationState(&player_pending_state,
|
| + &player_active_state);
|
| pending_state_ |= player_pending_state;
|
| active_state_ |= player_active_state;
|
| }
|
| @@ -522,10 +474,8 @@ void ElementAnimations::UpdateClientAnimationState() {
|
| }
|
|
|
| bool ElementAnimations::HasActiveAnimation() const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->HasActiveAnimation())
|
| + for (auto& player : players_list_) {
|
| + if (player.HasActiveAnimation())
|
| return true;
|
| }
|
|
|
| @@ -533,10 +483,8 @@ bool ElementAnimations::HasActiveAnimation() const {
|
| }
|
|
|
| bool ElementAnimations::HasAnyAnimation() const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->has_any_animation())
|
| + for (auto& player : players_list_) {
|
| + if (player.has_any_animation())
|
| return true;
|
| }
|
|
|
| @@ -545,10 +493,8 @@ bool ElementAnimations::HasAnyAnimation() const {
|
|
|
| bool ElementAnimations::HasAnyAnimationTargetingProperty(
|
| TargetProperty::Type property) const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->GetAnimation(property))
|
| + for (auto& player : players_list_) {
|
| + if (player.GetAnimation(property))
|
| return true;
|
| }
|
| return false;
|
| @@ -557,10 +503,8 @@ bool ElementAnimations::HasAnyAnimationTargetingProperty(
|
| bool ElementAnimations::IsPotentiallyAnimatingProperty(
|
| TargetProperty::Type target_property,
|
| ElementListType list_type) const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->IsPotentiallyAnimatingProperty(target_property, list_type))
|
| + for (auto& player : players_list_) {
|
| + if (player.IsPotentiallyAnimatingProperty(target_property, list_type))
|
| return true;
|
| }
|
|
|
| @@ -570,10 +514,8 @@ bool ElementAnimations::IsPotentiallyAnimatingProperty(
|
| bool ElementAnimations::IsCurrentlyAnimatingProperty(
|
| TargetProperty::Type target_property,
|
| ElementListType list_type) const {
|
| - ElementAnimations::PlayersList::Iterator it(players_list_.get());
|
| - AnimationPlayer* player;
|
| - while ((player = it.GetNext()) != nullptr) {
|
| - if (player->IsCurrentlyAnimatingProperty(target_property, list_type))
|
| + for (auto& player : players_list_) {
|
| + if (player.IsCurrentlyAnimatingProperty(target_property, list_type))
|
| return true;
|
| }
|
|
|
|
|