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

Side by Side Diff: ui/base/animation/animation_container.cc

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add fix for shutdown cut-off timing Created 8 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/animation/animation_container.h" 5 #include "ui/base/animation/animation_container.h"
6 6
7 #include "ui/base/animation/animation_container_element.h" 7 #include "ui/base/animation/animation_container_element.h"
8 #include "ui/base/animation/animation_container_observer.h" 8 #include "ui/base/animation/animation_container_observer.h"
9 9
10 using base::TimeDelta; 10 using base::TimeDelta;
11 using base::TimeTicks; 11 using base::TimeTicks;
12 12
13 namespace ui { 13 namespace ui {
14 14
15 AnimationContainer::AnimationContainer() 15 AnimationContainer::AnimationContainer()
16 : last_tick_time_(TimeTicks::Now()), 16 : last_tick_time_(TimeTicks::Now()),
17 observer_(NULL) { 17 observer_(NULL),
18 test_timing_enabled_(false) {
18 } 19 }
19 20
20 AnimationContainer::~AnimationContainer() { 21 AnimationContainer::~AnimationContainer() {
21 // The animations own us and stop themselves before being deleted. If 22 // The animations own us and stop themselves before being deleted. If
22 // elements_ is not empty, something is wrong. 23 // elements_ is not empty, something is wrong.
23 DCHECK(elements_.empty()); 24 DCHECK(elements_.empty());
24 } 25 }
25 26
26 void AnimationContainer::Start(AnimationContainerElement* element) { 27 void AnimationContainer::Start(AnimationContainerElement* element) {
27 DCHECK(elements_.count(element) == 0); // Start should only be invoked if the 28 DCHECK(elements_.count(element) == 0); // Start should only be invoked if the
28 // element isn't running. 29 // element isn't running.
29 30
30 if (elements_.empty()) { 31 if (elements_.empty()) {
31 last_tick_time_ = TimeTicks::Now(); 32 last_tick_time_ = GetCurrentTime();
32 SetMinTimerInterval(element->GetTimerInterval()); 33 SetMinTimerInterval(element->GetTimerInterval());
33 } else if (element->GetTimerInterval() < min_timer_interval_) { 34 } else if (element->GetTimerInterval() < min_timer_interval_) {
34 SetMinTimerInterval(element->GetTimerInterval()); 35 SetMinTimerInterval(element->GetTimerInterval());
35 } 36 }
36 37
37 element->SetStartTime(last_tick_time_); 38 element->SetStartTime(last_tick_time_);
38 elements_.insert(element); 39 elements_.insert(element);
39 } 40 }
40 41
41 void AnimationContainer::Stop(AnimationContainerElement* element) { 42 void AnimationContainer::Stop(AnimationContainerElement* element) {
(...skipping 12 matching lines...) Expand all
54 } 55 }
55 } 56 }
56 57
57 void AnimationContainer::Run() { 58 void AnimationContainer::Run() {
58 // We notify the observer after updating all the elements. If all the elements 59 // We notify the observer after updating all the elements. If all the elements
59 // are deleted as a result of updating then our ref count would go to zero and 60 // are deleted as a result of updating then our ref count would go to zero and
60 // we would be deleted before we notify our observer. We add a reference to 61 // we would be deleted before we notify our observer. We add a reference to
61 // ourself here to make sure we're still valid after running all the elements. 62 // ourself here to make sure we're still valid after running all the elements.
62 scoped_refptr<AnimationContainer> this_ref(this); 63 scoped_refptr<AnimationContainer> this_ref(this);
63 64
64 TimeTicks current_time = TimeTicks::Now(); 65 TimeTicks current_time = GetCurrentTime();
65 66
66 last_tick_time_ = current_time; 67 last_tick_time_ = current_time;
67 68
68 // Make a copy of the elements to iterate over so that if any elements are 69 // Make a copy of the elements to iterate over so that if any elements are
69 // removed as part of invoking Step there aren't any problems. 70 // removed as part of invoking Step there aren't any problems.
70 Elements elements = elements_; 71 Elements elements = elements_;
71 72
72 for (Elements::const_iterator i = elements.begin(); 73 for (Elements::const_iterator i = elements.begin();
73 i != elements.end(); ++i) { 74 i != elements.end(); ++i) {
74 // Make sure the element is still valid. 75 // Make sure the element is still valid.
(...skipping 19 matching lines...) Expand all
94 TimeDelta min; 95 TimeDelta min;
95 Elements::const_iterator i = elements_.begin(); 96 Elements::const_iterator i = elements_.begin();
96 min = (*i)->GetTimerInterval(); 97 min = (*i)->GetTimerInterval();
97 for (++i; i != elements_.end(); ++i) { 98 for (++i; i != elements_.end(); ++i) {
98 if ((*i)->GetTimerInterval() < min) 99 if ((*i)->GetTimerInterval() < min)
99 min = (*i)->GetTimerInterval(); 100 min = (*i)->GetTimerInterval();
100 } 101 }
101 return min; 102 return min;
102 } 103 }
103 104
105 TimeTicks AnimationContainer::GetCurrentTime() {
106 if (test_timing_enabled_)
107 return test_time_;
108 return TimeTicks::Now();
109 }
110
104 } // namespace ui 111 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698