Fix build break
[chromium-blink-merge.git] / ui / compositor / layer_animation_observer.cc
blob2d7402b5f1aee921dab7e68d8a1623b252299470
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/compositor/layer_animation_observer.h"
7 #include "ui/compositor/layer_animation_sequence.h"
9 namespace ui {
11 ////////////////////////////////////////////////////////////////////////////////
12 // LayerAnimationObserver
14 LayerAnimationObserver::LayerAnimationObserver() {
17 LayerAnimationObserver::~LayerAnimationObserver() {
18 StopObserving();
21 bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const {
22 return false;
25 void LayerAnimationObserver::OnAttachedToSequence(
26 LayerAnimationSequence* sequence) {
29 void LayerAnimationObserver::OnDetachedFromSequence(
30 LayerAnimationSequence* sequence) {
33 void LayerAnimationObserver::StopObserving() {
34 while (!attached_sequences_.empty()) {
35 LayerAnimationSequence* sequence = *attached_sequences_.begin();
36 sequence->RemoveObserver(this);
40 void LayerAnimationObserver::AttachedToSequence(
41 LayerAnimationSequence* sequence) {
42 DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end());
43 attached_sequences_.insert(sequence);
44 OnAttachedToSequence(sequence);
47 void LayerAnimationObserver::DetachedFromSequence(
48 LayerAnimationSequence* sequence, bool send_notification) {
49 if (attached_sequences_.find(sequence) != attached_sequences_.end())
50 attached_sequences_.erase(sequence);
51 if (send_notification)
52 OnDetachedFromSequence(sequence);
55 ////////////////////////////////////////////////////////////////////////////////
56 // ImplicitAnimationObserver
58 ImplicitAnimationObserver::ImplicitAnimationObserver()
59 : active_(false),
60 destroyed_(NULL),
61 first_sequence_scheduled_(false) {
64 ImplicitAnimationObserver::~ImplicitAnimationObserver() {
65 if (destroyed_)
66 *destroyed_ = true;
69 void ImplicitAnimationObserver::SetActive(bool active) {
70 active_ = active;
71 CheckCompleted();
74 void ImplicitAnimationObserver::StopObservingImplicitAnimations() {
75 SetActive(false);
76 StopObserving();
79 void ImplicitAnimationObserver::OnLayerAnimationEnded(
80 LayerAnimationSequence* sequence) {
81 bool destroyed = false;
82 destroyed_ = &destroyed;
83 sequence->RemoveObserver(this);
84 if (destroyed)
85 return;
86 destroyed_ = NULL;
87 DCHECK(attached_sequences().find(sequence) == attached_sequences().end());
88 CheckCompleted();
91 void ImplicitAnimationObserver::OnLayerAnimationAborted(
92 LayerAnimationSequence* sequence) {
93 sequence->RemoveObserver(this);
94 DCHECK(attached_sequences().find(sequence) == attached_sequences().end());
95 CheckCompleted();
98 void ImplicitAnimationObserver::OnLayerAnimationScheduled(
99 LayerAnimationSequence* sequence) {
100 if (!first_sequence_scheduled_) {
101 first_sequence_scheduled_ = true;
102 OnImplicitAnimationsScheduled();
106 void ImplicitAnimationObserver::OnAttachedToSequence(
107 LayerAnimationSequence* sequence) {
110 void ImplicitAnimationObserver::OnDetachedFromSequence(
111 LayerAnimationSequence* sequence) {
112 DCHECK(attached_sequences().find(sequence) == attached_sequences().end());
113 CheckCompleted();
116 void ImplicitAnimationObserver::CheckCompleted() {
117 if (active_ && attached_sequences().empty()) {
118 active_ = false;
119 OnImplicitAnimationsCompleted();
123 } // namespace ui