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

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

Issue 10869066: Attempt 2 at Fixes crash introduced @ 153047 (you can hit crash by maximizing a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: The fix 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 using aura::Window; 44 using aura::Window;
45 using base::TimeDelta; 45 using base::TimeDelta;
46 using ui::Layer; 46 using ui::Layer;
47 47
48 namespace ash { 48 namespace ash {
49 namespace internal { 49 namespace internal {
50 namespace { 50 namespace {
51 const float kWindowAnimation_Vertical_TranslateY = 15.f; 51 const float kWindowAnimation_Vertical_TranslateY = 15.f;
52 52
53 bool delayed_old_layer_deletion_in_cross_fade_for_test_ = false;
54 } 53 }
55 54
56 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType, 55 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType,
57 kWindowVisibilityAnimationTypeKey, 56 kWindowVisibilityAnimationTypeKey,
58 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 57 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
59 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0); 58 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);
60 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition, 59 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition,
61 kWindowVisibilityAnimationTransitionKey, 60 kWindowVisibilityAnimationTransitionKey,
62 ANIMATE_BOTH); 61 ANIMATE_BOTH);
63 DEFINE_WINDOW_PROPERTY_KEY(float, 62 DEFINE_WINDOW_PROPERTY_KEY(float,
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // aura::WindowObserver overrides: 656 // aura::WindowObserver overrides:
658 virtual void OnWindowDestroying(Window* window) OVERRIDE { 657 virtual void OnWindowDestroying(Window* window) OVERRIDE {
659 if (layer_) 658 if (layer_)
660 layer_->GetAnimator()->StopAnimating(); 659 layer_->GetAnimator()->StopAnimating();
661 // Delete is scheduled in OnImplicitAnimationsCompleted(). 660 // Delete is scheduled in OnImplicitAnimationsCompleted().
662 Cleanup(); 661 Cleanup();
663 } 662 }
664 663
665 // ui::ImplicitAnimationObserver overrides: 664 // ui::ImplicitAnimationObserver overrides:
666 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 665 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
667 // ImplicitAnimationObserver's base class uses the object after 666 delete this;
668 // calling this function, so we cannot delete |this|. The |layer_|
669 // may be gone by the next message loop run when shutting down, so
670 // clean them up now.
671 if (!delayed_old_layer_deletion_in_cross_fade_for_test_)
672 Cleanup();
673 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
674 } 667 }
675 668
676 private: 669 private:
677 // Can be called multiple times if the window is closed or the compositor 670 // Can be called multiple times if the window is closed or the compositor
678 // fails in the middle of the animation. 671 // fails in the middle of the animation.
679 void Cleanup() { 672 void Cleanup() {
680 if (window_) { 673 if (window_) {
681 window_->RemoveObserver(this); 674 window_->RemoveObserver(this);
682 window_ = NULL; 675 window_ = NULL;
683 } 676 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 } 968 }
976 if (visible) { 969 if (visible) {
977 return AnimateShowWindow(window); 970 return AnimateShowWindow(window);
978 } else { 971 } else {
979 // Don't start hiding the window again if it's already being hidden. 972 // Don't start hiding the window again if it's already being hidden.
980 return window->layer()->GetTargetOpacity() != 0.0f && 973 return window->layer()->GetTargetOpacity() != 0.0f &&
981 AnimateHideWindow(window); 974 AnimateHideWindow(window);
982 } 975 }
983 } 976 }
984 977
985 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) {
986 delayed_old_layer_deletion_in_cross_fade_for_test_ = value;
987 }
988
989 } // namespace internal 978 } // namespace internal
990 } // namespace ash 979 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698