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

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: Review fixes 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 num_attached_sequences_(0) {
53 }
54
55 // LayerAnimationObserver overrides:
56 virtual void OnLayerAnimationEnded(
57 LayerAnimationSequence* sequence) OVERRIDE {
58 callback_.Run();
59 callback_.Reset();
60 }
61
62 virtual void OnLayerAnimationAborted(
63 LayerAnimationSequence* sequence) OVERRIDE {}
64
65 virtual void OnLayerAnimationScheduled(
66 LayerAnimationSequence* sequence) OVERRIDE {}
67
68 private:
69 virtual void OnAttachedToSequence(LayerAnimationSequence* sequence) {
70 num_attached_sequences_++;
71 }
72
73 virtual void OnDetachedFromSequence(LayerAnimationSequence* sequence) {
74 num_attached_sequences_--;
75 if (num_attached_sequences_ == 0)
76 delete this;
77 }
78
79 base::Closure callback_;
80 int num_attached_sequences_;
81
82 DISALLOW_COPY_AND_ASSIGN(SuccessCallbackAnimationObserver);
83 };
84
48 } // namespace 85 } // namespace
49 86
50 // static 87 // static
51 bool LayerAnimator::disable_animations_for_test_ = false; 88 bool LayerAnimator::disable_animations_for_test_ = false;
52 // static 89 // static
53 bool LayerAnimator::slow_animation_mode_ = false; 90 bool LayerAnimator::slow_animation_mode_ = false;
54 // static 91 // static
55 int LayerAnimator::slow_animation_scale_factor_ = 4; 92 int LayerAnimator::slow_animation_scale_factor_ = 4;
56 93
57 // LayerAnimator public -------------------------------------------------------- 94 // 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)) { 288 for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) {
252 properties_to_pause.insert( 289 properties_to_pause.insert(
253 static_cast<LayerAnimationElement::AnimatableProperty>(p)); 290 static_cast<LayerAnimationElement::AnimatableProperty>(p));
254 } 291 }
255 va_end(marker); 292 va_end(marker);
256 ScheduleAnimation(new ui::LayerAnimationSequence( 293 ScheduleAnimation(new ui::LayerAnimationSequence(
257 ui::LayerAnimationElement::CreatePauseElement( 294 ui::LayerAnimationElement::CreatePauseElement(
258 properties_to_pause, duration))); 295 properties_to_pause, duration)));
259 } 296 }
260 297
298 void LayerAnimator::SetCompletionCallbackForProperties(
299 base::Closure& callback,
300 LayerAnimationElement::AnimatableProperty property,
301 ...) {
302 ui::LayerAnimationElement::AnimatableProperties properties_to_pause;
303 va_list marker;
304 va_start(marker, property);
305 for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) {
306 properties_to_pause.insert(
307 static_cast<LayerAnimationElement::AnimatableProperty>(p));
308 }
309 va_end(marker);
310
311 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
312 ui::LayerAnimationElement::CreatePauseElement(
313 properties_to_pause, base::TimeDelta()));
314
315 sequence->AddObserver(new SuccessCallbackAnimationObserver(callback));
316
317 ScheduleAnimation(sequence);
318 }
319
261 bool LayerAnimator::IsAnimatingProperty( 320 bool LayerAnimator::IsAnimatingProperty(
262 LayerAnimationElement::AnimatableProperty property) const { 321 LayerAnimationElement::AnimatableProperty property) const {
263 for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin(); 322 for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
264 queue_iter != animation_queue_.end(); ++queue_iter) { 323 queue_iter != animation_queue_.end(); ++queue_iter) {
265 if ((*queue_iter)->properties().find(property) != 324 if ((*queue_iter)->properties().find(property) !=
266 (*queue_iter)->properties().end()) { 325 (*queue_iter)->properties().end()) {
267 return true; 326 return true;
268 } 327 }
269 } 328 }
270 return false; 329 return false;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 const bool abort = false; 592 const bool abort = false;
534 RemoveAllAnimationsWithACommonProperty(sequence, abort); 593 RemoveAllAnimationsWithACommonProperty(sequence, abort);
535 if (!weak_sequence_ptr) 594 if (!weak_sequence_ptr)
536 return; 595 return;
537 596
538 LayerAnimationSequence* removed = RemoveAnimation(sequence); 597 LayerAnimationSequence* removed = RemoveAnimation(sequence);
539 DCHECK(removed == NULL || removed == sequence); 598 DCHECK(removed == NULL || removed == sequence);
540 if (!weak_sequence_ptr) 599 if (!weak_sequence_ptr)
541 return; 600 return;
542 601
543 ProgressAnimation(sequence, sequence->duration()); 602 ProgressAnimationToEnd(sequence);
544 if (!weak_sequence_ptr) 603 if (!weak_sequence_ptr)
545 return; 604 return;
546 605
547 delete sequence; 606 delete sequence;
548 } 607 }
549 608
550 void LayerAnimator::ImmediatelyAnimateToNewTarget( 609 void LayerAnimator::ImmediatelyAnimateToNewTarget(
551 LayerAnimationSequence* sequence) { 610 LayerAnimationSequence* sequence) {
552 // Need to detect if our sequence gets destroyed. 611 // Need to detect if our sequence gets destroyed.
553 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr = 612 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 LayerAnimator::RunningAnimation::RunningAnimation( 808 LayerAnimator::RunningAnimation::RunningAnimation(
750 const base::WeakPtr<LayerAnimationSequence>& sequence, 809 const base::WeakPtr<LayerAnimationSequence>& sequence,
751 base::TimeTicks start_time) 810 base::TimeTicks start_time)
752 : sequence_(sequence), 811 : sequence_(sequence),
753 start_time_(start_time) { 812 start_time_(start_time) {
754 } 813 }
755 814
756 LayerAnimator::RunningAnimation::~RunningAnimation() { } 815 LayerAnimator::RunningAnimation::~RunningAnimation() { }
757 816
758 } // namespace ui 817 } // namespace ui
OLDNEW
« ash/wm/workspace/workspace_animations.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