OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ui/compositor/layer_animation_observer.h" | 5 #include "ui/compositor/layer_animation_observer.h" |
6 | 6 |
7 #include "ui/compositor/layer_animation_sequence.h" | 7 #include "ui/compositor/layer_animation_sequence.h" |
8 | 8 |
9 namespace ui { | 9 namespace ui { |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (attached_sequences_.find(sequence) != attached_sequences_.end()) | 49 if (attached_sequences_.find(sequence) != attached_sequences_.end()) |
50 attached_sequences_.erase(sequence); | 50 attached_sequences_.erase(sequence); |
51 if (send_notification) | 51 if (send_notification) |
52 OnDetachedFromSequence(sequence); | 52 OnDetachedFromSequence(sequence); |
53 } | 53 } |
54 | 54 |
55 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
56 // ImplicitAnimationObserver | 56 // ImplicitAnimationObserver |
57 | 57 |
58 ImplicitAnimationObserver::ImplicitAnimationObserver() | 58 ImplicitAnimationObserver::ImplicitAnimationObserver() |
59 : active_(false), | 59 : active_(false) { |
60 destroyed_(NULL) { | |
61 } | 60 } |
62 | 61 |
63 ImplicitAnimationObserver::~ImplicitAnimationObserver() { | 62 ImplicitAnimationObserver::~ImplicitAnimationObserver() {} |
64 if (destroyed_) | |
65 *destroyed_ = true; | |
66 } | |
67 | 63 |
68 void ImplicitAnimationObserver::SetActive(bool active) { | 64 void ImplicitAnimationObserver::SetActive(bool active) { |
69 active_ = active; | 65 active_ = active; |
70 CheckCompleted(); | 66 CheckCompleted(); |
71 } | 67 } |
72 | 68 |
73 void ImplicitAnimationObserver::StopObservingImplicitAnimations() { | 69 void ImplicitAnimationObserver::StopObservingImplicitAnimations() { |
74 SetActive(false); | 70 SetActive(false); |
75 StopObserving(); | 71 StopObserving(); |
76 } | 72 } |
77 | 73 |
78 void ImplicitAnimationObserver::OnLayerAnimationEnded( | 74 void ImplicitAnimationObserver::OnLayerAnimationEnded( |
79 LayerAnimationSequence* sequence) { | 75 LayerAnimationSequence* sequence) { |
80 bool destroyed = false; | |
81 destroyed_ = &destroyed; | |
82 sequence->RemoveObserver(this); | 76 sequence->RemoveObserver(this); |
83 if (destroyed) | |
84 return; | |
85 destroyed_ = NULL; | |
86 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | 77 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
87 CheckCompleted(); | 78 CheckCompleted(); |
88 } | 79 } |
89 | 80 |
90 void ImplicitAnimationObserver::OnLayerAnimationAborted( | 81 void ImplicitAnimationObserver::OnLayerAnimationAborted( |
91 LayerAnimationSequence* sequence) { | 82 LayerAnimationSequence* sequence) { |
92 sequence->RemoveObserver(this); | 83 sequence->RemoveObserver(this); |
93 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | 84 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); |
94 CheckCompleted(); | 85 CheckCompleted(); |
95 } | 86 } |
(...skipping 13 matching lines...) Expand all Loading... |
109 } | 100 } |
110 | 101 |
111 void ImplicitAnimationObserver::CheckCompleted() { | 102 void ImplicitAnimationObserver::CheckCompleted() { |
112 if (active_ && attached_sequences().empty()) { | 103 if (active_ && attached_sequences().empty()) { |
113 OnImplicitAnimationsCompleted(); | 104 OnImplicitAnimationsCompleted(); |
114 active_ = false; | 105 active_ = false; |
115 } | 106 } |
116 } | 107 } |
117 | 108 |
118 } // namespace ui | 109 } // namespace ui |
OLD | NEW |