| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ui/gfx/compositor/layer_animation_observer.h" | |
| 6 | |
| 7 #include "ui/gfx/compositor/layer_animation_sequence.h" | |
| 8 | |
| 9 namespace ui { | |
| 10 | |
| 11 //////////////////////////////////////////////////////////////////////////////// | |
| 12 // LayerAnimationObserver | |
| 13 | |
| 14 LayerAnimationObserver::LayerAnimationObserver() { | |
| 15 } | |
| 16 | |
| 17 LayerAnimationObserver::~LayerAnimationObserver() { | |
| 18 StopObserving(); | |
| 19 } | |
| 20 | |
| 21 bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const { | |
| 22 return false; | |
| 23 } | |
| 24 | |
| 25 void LayerAnimationObserver::OnAttachedToSequence( | |
| 26 LayerAnimationSequence* sequence) { | |
| 27 } | |
| 28 | |
| 29 void LayerAnimationObserver::OnDetachedFromSequence( | |
| 30 LayerAnimationSequence* sequence) { | |
| 31 } | |
| 32 | |
| 33 void LayerAnimationObserver::StopObserving() { | |
| 34 while (!attached_sequences_.empty()) { | |
| 35 LayerAnimationSequence* sequence = *attached_sequences_.begin(); | |
| 36 sequence->RemoveObserver(this); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 void LayerAnimationObserver::AttachedToSequence( | |
| 41 LayerAnimationSequence* sequence) { | |
| 42 DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end()); | |
| 43 attached_sequences_.insert(sequence); | |
| 44 OnAttachedToSequence(sequence); | |
| 45 } | |
| 46 | |
| 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); | |
| 53 } | |
| 54 | |
| 55 //////////////////////////////////////////////////////////////////////////////// | |
| 56 // ImplicitAnimationObserver | |
| 57 | |
| 58 ImplicitAnimationObserver::ImplicitAnimationObserver() | |
| 59 : active_(false) { | |
| 60 } | |
| 61 | |
| 62 ImplicitAnimationObserver::~ImplicitAnimationObserver() {} | |
| 63 | |
| 64 void ImplicitAnimationObserver::SetActive(bool active) { | |
| 65 active_ = active; | |
| 66 CheckCompleted(); | |
| 67 } | |
| 68 | |
| 69 void ImplicitAnimationObserver::StopObservingImplicitAnimations() { | |
| 70 SetActive(false); | |
| 71 StopObserving(); | |
| 72 } | |
| 73 | |
| 74 void ImplicitAnimationObserver::OnLayerAnimationEnded( | |
| 75 LayerAnimationSequence* sequence) { | |
| 76 sequence->RemoveObserver(this); | |
| 77 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | |
| 78 CheckCompleted(); | |
| 79 } | |
| 80 | |
| 81 void ImplicitAnimationObserver::OnLayerAnimationAborted( | |
| 82 LayerAnimationSequence* sequence) { | |
| 83 sequence->RemoveObserver(this); | |
| 84 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | |
| 85 CheckCompleted(); | |
| 86 } | |
| 87 | |
| 88 void ImplicitAnimationObserver::OnLayerAnimationScheduled( | |
| 89 LayerAnimationSequence* sequence) { | |
| 90 } | |
| 91 | |
| 92 void ImplicitAnimationObserver::OnAttachedToSequence( | |
| 93 LayerAnimationSequence* sequence) { | |
| 94 } | |
| 95 | |
| 96 void ImplicitAnimationObserver::OnDetachedFromSequence( | |
| 97 LayerAnimationSequence* sequence) { | |
| 98 DCHECK(attached_sequences().find(sequence) == attached_sequences().end()); | |
| 99 CheckCompleted(); | |
| 100 } | |
| 101 | |
| 102 void ImplicitAnimationObserver::CheckCompleted() { | |
| 103 if (active_ && attached_sequences().empty()) { | |
| 104 OnImplicitAnimationsCompleted(); | |
| 105 active_ = false; | |
| 106 } | |
| 107 } | |
| 108 | |
| 109 } // namespace ui | |
| OLD | NEW |