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

Unified Diff: ui/gfx/compositor/layer_animation_sequence.cc

Issue 8395046: Allows observers to be notified when layer animations complete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 9 years, 2 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
Index: ui/gfx/compositor/layer_animation_sequence.cc
diff --git a/ui/gfx/compositor/layer_animation_sequence.cc b/ui/gfx/compositor/layer_animation_sequence.cc
index 8f34969d6801439cc6cc3e639da280662bec38e0..f2e362ba0a405c974943df6f291d6b087a36e1b4 100644
--- a/ui/gfx/compositor/layer_animation_sequence.cc
+++ b/ui/gfx/compositor/layer_animation_sequence.cc
@@ -10,6 +10,7 @@
#include "base/debug/trace_event.h"
#include "ui/gfx/compositor/layer_animation_delegate.h"
#include "ui/gfx/compositor/layer_animation_element.h"
+#include "ui/gfx/compositor/layer_animation_observer.h"
namespace ui {
@@ -65,6 +66,7 @@ void LayerAnimationSequence::Progress(base::TimeDelta elapsed,
if (!is_cyclic_ && elapsed == duration_) {
last_element_ = 0;
last_start_ = base::TimeDelta::FromMilliseconds(0);
+ NotifyEnded();
}
}
@@ -85,6 +87,7 @@ void LayerAnimationSequence::Abort() {
}
last_element_ = 0;
last_start_ = base::TimeDelta::FromMilliseconds(0);
+ NotifyAborted();
}
void LayerAnimationSequence::AddElement(LayerAnimationElement* element) {
@@ -106,4 +109,35 @@ bool LayerAnimationSequence::HasCommonProperty(
return intersection.size() > 0;
}
+void LayerAnimationSequence::AddObserver(LayerAnimationObserver* observer) {
+ if (!observers_.HasObserver(observer))
sky 2011/10/28 22:11:38 Don't do this, there's a DCHECK that you don't add
+ observers_.AddObserver(observer);
+}
+
+void LayerAnimationSequence::RemoveObserver(LayerAnimationObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void LayerAnimationSequence::OnScheduled() {
+ NotifyScheduled();
+}
+
+void LayerAnimationSequence::NotifyScheduled() {
+ FOR_EACH_OBSERVER(LayerAnimationObserver,
+ observers_,
+ OnLayerAnimationScheduled(this));
+}
+
+void LayerAnimationSequence::NotifyEnded() {
+ FOR_EACH_OBSERVER(LayerAnimationObserver,
+ observers_,
+ OnLayerAnimationEnded(this));
+}
+
+void LayerAnimationSequence::NotifyAborted() {
+ FOR_EACH_OBSERVER(LayerAnimationObserver,
+ observers_,
+ OnLayerAnimationAborted(this));
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698