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

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 11280188: Fix focus loss on partial lock. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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) 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_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/animation/animation_container.h" 10 #include "ui/base/animation/animation_container.h"
(...skipping 27 matching lines...) Expand all
38 // Returns the AnimationContainer we're added to. 38 // Returns the AnimationContainer we're added to.
39 ui::AnimationContainer* GetAnimationContainer() { 39 ui::AnimationContainer* GetAnimationContainer() {
40 static ui::AnimationContainer* container = NULL; 40 static ui::AnimationContainer* container = NULL;
41 if (!container) { 41 if (!container) {
42 container = new AnimationContainer(); 42 container = new AnimationContainer();
43 container->AddRef(); 43 container->AddRef();
44 } 44 }
45 return container; 45 return container;
46 } 46 }
47 47
48 class SuccessCallbackAnimationObserver : public LayerAnimationObserver {
49 public:
50 SuccessCallbackAnimationObserver(base::Closure callback)
51 : callback_(callback),
52 attached_(0) {
53 }
54
55 virtual void OnLayerAnimationEnded(LayerAnimationSequence* sequence) {
56 callback_.Run();
57 callback_.Reset();
58 }
59
60 virtual void OnLayerAnimationAborted(
61 LayerAnimationSequence* sequence) {}
62
63 virtual void OnLayerAnimationScheduled(
64 LayerAnimationSequence* sequence) {}
65
66 private:
67 virtual void OnAttachedToSequence(LayerAnimationSequence* sequence) {
68 attached_++;
69 }
70
71 virtual void OnDetachedFromSequence(LayerAnimationSequence* sequence) {
72 attached_--;
73 if (attached_ == 0)
74 delete this;
75 }
76
77 base::Closure callback_;
78 int attached_;
Daniel Erat 2012/11/27 18:32:11 nit: rename to num_attached_sequences_ or somethin
Ian Vollick 2012/11/27 18:35:07 DISALLOW_COPY_AND_ASSIGN
Denis Kuznetsov (DE-MUC) 2012/11/27 18:46:59 Done.
Denis Kuznetsov (DE-MUC) 2012/11/27 18:46:59 Done.
79 };
80
48 } // namespace 81 } // namespace
49 82
50 // static 83 // static
51 bool LayerAnimator::disable_animations_for_test_ = false; 84 bool LayerAnimator::disable_animations_for_test_ = false;
52 // static 85 // static
53 bool LayerAnimator::slow_animation_mode_ = false; 86 bool LayerAnimator::slow_animation_mode_ = false;
54 // static 87 // static
55 int LayerAnimator::slow_animation_scale_factor_ = 4; 88 int LayerAnimator::slow_animation_scale_factor_ = 4;
56 89
57 // LayerAnimator public -------------------------------------------------------- 90 // LayerAnimator public --------------------------------------------------------
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) { 284 for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) {
252 properties_to_pause.insert( 285 properties_to_pause.insert(
253 static_cast<LayerAnimationElement::AnimatableProperty>(p)); 286 static_cast<LayerAnimationElement::AnimatableProperty>(p));
254 } 287 }
255 va_end(marker); 288 va_end(marker);
256 ScheduleAnimation(new ui::LayerAnimationSequence( 289 ScheduleAnimation(new ui::LayerAnimationSequence(
257 ui::LayerAnimationElement::CreatePauseElement( 290 ui::LayerAnimationElement::CreatePauseElement(
258 properties_to_pause, duration))); 291 properties_to_pause, duration)));
259 } 292 }
260 293
294 void LayerAnimator::ScheduleSuccessCallbackForProperties(
295 base::Closure& callback,
296 LayerAnimationElement::AnimatableProperty property,
297 ...) {
298 ui::LayerAnimationElement::AnimatableProperties properties_to_pause;
299 va_list marker;
300 va_start(marker, property);
301 for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) {
302 properties_to_pause.insert(
Daniel Erat 2012/11/27 18:32:11 pause?
Denis Kuznetsov (DE-MUC) 2012/11/27 18:46:59 We create PauseElement (one that does not change a
303 static_cast<LayerAnimationElement::AnimatableProperty>(p));
304 }
305 va_end(marker);
306
307 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
308 ui::LayerAnimationElement::CreatePauseElement(
309 properties_to_pause, base::TimeDelta()));
310
311 sequence->AddObserver(new SuccessCallbackAnimationObserver(callback));
312
313 ScheduleAnimation(sequence);
314 }
315
Daniel Erat 2012/11/27 18:32:11 nit: delete extra blank line
Denis Kuznetsov (DE-MUC) 2012/11/27 18:46:59 Done.
316
261 bool LayerAnimator::IsAnimatingProperty( 317 bool LayerAnimator::IsAnimatingProperty(
262 LayerAnimationElement::AnimatableProperty property) const { 318 LayerAnimationElement::AnimatableProperty property) const {
263 for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin(); 319 for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
264 queue_iter != animation_queue_.end(); ++queue_iter) { 320 queue_iter != animation_queue_.end(); ++queue_iter) {
265 if ((*queue_iter)->properties().find(property) != 321 if ((*queue_iter)->properties().find(property) !=
266 (*queue_iter)->properties().end()) { 322 (*queue_iter)->properties().end()) {
267 return true; 323 return true;
268 } 324 }
269 } 325 }
270 return false; 326 return false;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 const bool abort = false; 589 const bool abort = false;
534 RemoveAllAnimationsWithACommonProperty(sequence, abort); 590 RemoveAllAnimationsWithACommonProperty(sequence, abort);
535 if (!weak_sequence_ptr) 591 if (!weak_sequence_ptr)
536 return; 592 return;
537 593
538 LayerAnimationSequence* removed = RemoveAnimation(sequence); 594 LayerAnimationSequence* removed = RemoveAnimation(sequence);
539 DCHECK(removed == NULL || removed == sequence); 595 DCHECK(removed == NULL || removed == sequence);
540 if (!weak_sequence_ptr) 596 if (!weak_sequence_ptr)
541 return; 597 return;
542 598
543 ProgressAnimation(sequence, sequence->duration()); 599 ProgressAnimationToEnd(sequence);
544 if (!weak_sequence_ptr) 600 if (!weak_sequence_ptr)
545 return; 601 return;
546 602
547 delete sequence; 603 delete sequence;
548 } 604 }
549 605
550 void LayerAnimator::ImmediatelyAnimateToNewTarget( 606 void LayerAnimator::ImmediatelyAnimateToNewTarget(
551 LayerAnimationSequence* sequence) { 607 LayerAnimationSequence* sequence) {
552 // Need to detect if our sequence gets destroyed. 608 // Need to detect if our sequence gets destroyed.
553 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr = 609 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 LayerAnimator::RunningAnimation::RunningAnimation( 805 LayerAnimator::RunningAnimation::RunningAnimation(
750 const base::WeakPtr<LayerAnimationSequence>& sequence, 806 const base::WeakPtr<LayerAnimationSequence>& sequence,
751 base::TimeTicks start_time) 807 base::TimeTicks start_time)
752 : sequence_(sequence), 808 : sequence_(sequence),
753 start_time_(start_time) { 809 start_time_(start_time) {
754 } 810 }
755 811
756 LayerAnimator::RunningAnimation::~RunningAnimation() { } 812 LayerAnimator::RunningAnimation::~RunningAnimation() { }
757 813
758 } // namespace ui 814 } // namespace ui
OLDNEW
« ui/compositor/layer_animator.h ('K') | « ui/compositor/layer_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698