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

Side by Side Diff: ash/wm/window_animations.cc

Issue 10874064: Fixes crash introduced @ 153047 (you can hit crash by maximizing a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/wm/window_animations.h" 5 #include "ash/wm/window_animations.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 using aura::Window; 43 using aura::Window;
44 using base::TimeDelta; 44 using base::TimeDelta;
45 using ui::Layer; 45 using ui::Layer;
46 46
47 namespace ash { 47 namespace ash {
48 namespace internal { 48 namespace internal {
49 namespace { 49 namespace {
50 const float kWindowAnimation_Vertical_TranslateY = 15.f; 50 const float kWindowAnimation_Vertical_TranslateY = 15.f;
51 51
52 bool delayed_old_layer_deletion_in_cross_fade_for_test_ = false;
53 } 52 }
54 53
55 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType, 54 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType,
56 kWindowVisibilityAnimationTypeKey, 55 kWindowVisibilityAnimationTypeKey,
57 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 56 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
58 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0); 57 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);
59 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition, 58 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition,
60 kWindowVisibilityAnimationTransitionKey, 59 kWindowVisibilityAnimationTransitionKey,
61 ANIMATE_BOTH); 60 ANIMATE_BOTH);
62 DEFINE_WINDOW_PROPERTY_KEY(float, 61 DEFINE_WINDOW_PROPERTY_KEY(float,
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // aura::WindowObserver overrides: 655 // aura::WindowObserver overrides:
657 virtual void OnWindowDestroying(Window* window) OVERRIDE { 656 virtual void OnWindowDestroying(Window* window) OVERRIDE {
658 if (layer_) 657 if (layer_)
659 layer_->GetAnimator()->StopAnimating(); 658 layer_->GetAnimator()->StopAnimating();
660 // Delete is scheduled in OnImplicitAnimationsCompleted(). 659 // Delete is scheduled in OnImplicitAnimationsCompleted().
661 Cleanup(); 660 Cleanup();
662 } 661 }
663 662
664 // ui::ImplicitAnimationObserver overrides: 663 // ui::ImplicitAnimationObserver overrides:
665 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 664 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
666 // ImplicitAnimationObserver's base class uses the object after 665 delete this;
667 // calling this function, so we cannot delete |this|. The |layer_|
668 // may be gone by the next message loop run when shutting down, so
669 // clean them up now.
670 if (!delayed_old_layer_deletion_in_cross_fade_for_test_)
671 Cleanup();
672 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
673 } 666 }
674 667
675 private: 668 private:
676 // Can be called multiple times if the window is closed or the compositor 669 // Can be called multiple times if the window is closed or the compositor
677 // fails in the middle of the animation. 670 // fails in the middle of the animation.
678 void Cleanup() { 671 void Cleanup() {
679 if (window_) { 672 if (window_) {
680 window_->RemoveObserver(this); 673 window_->RemoveObserver(this);
681 window_ = NULL; 674 window_ = NULL;
682 } 675 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 836 }
844 if (visible) { 837 if (visible) {
845 return AnimateShowWindow(window); 838 return AnimateShowWindow(window);
846 } else { 839 } else {
847 // Don't start hiding the window again if it's already being hidden. 840 // Don't start hiding the window again if it's already being hidden.
848 return window->layer()->GetTargetOpacity() != 0.0f && 841 return window->layer()->GetTargetOpacity() != 0.0f &&
849 AnimateHideWindow(window); 842 AnimateHideWindow(window);
850 } 843 }
851 } 844 }
852 845
853 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) {
854 delayed_old_layer_deletion_in_cross_fade_for_test_ = value;
855 }
856
857 } // namespace internal 846 } // namespace internal
858 } // namespace ash 847 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698