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

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: Better fix Created 8 years, 3 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 // aura::WindowObserver overrides: 653 // aura::WindowObserver overrides:
655 virtual void OnWindowDestroying(Window* window) OVERRIDE { 654 virtual void OnWindowDestroying(Window* window) OVERRIDE {
656 if (layer_) 655 if (layer_)
657 layer_->GetAnimator()->StopAnimating(); 656 layer_->GetAnimator()->StopAnimating();
658 // Delete is scheduled in OnImplicitAnimationsCompleted(). 657 // Delete is scheduled in OnImplicitAnimationsCompleted().
659 Cleanup(); 658 Cleanup();
660 } 659 }
661 660
662 // ui::ImplicitAnimationObserver overrides: 661 // ui::ImplicitAnimationObserver overrides:
663 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 662 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
664 // ImplicitAnimationObserver's base class uses the object after 663 delete this;
665 // calling this function, so we cannot delete |this|. The |layer_|
666 // may be gone by the next message loop run when shutting down, so
667 // clean them up now.
668 if (!delayed_old_layer_deletion_in_cross_fade_for_test_)
669 Cleanup();
670 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
671 } 664 }
672 665
673 private: 666 private:
674 // Can be called multiple times if the window is closed or the compositor 667 // Can be called multiple times if the window is closed or the compositor
675 // fails in the middle of the animation. 668 // fails in the middle of the animation.
676 void Cleanup() { 669 void Cleanup() {
677 if (window_) { 670 if (window_) {
678 window_->RemoveObserver(this); 671 window_->RemoveObserver(this);
679 window_ = NULL; 672 window_ = NULL;
680 } 673 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 } 960 }
968 if (visible) { 961 if (visible) {
969 return AnimateShowWindow(window); 962 return AnimateShowWindow(window);
970 } else { 963 } else {
971 // Don't start hiding the window again if it's already being hidden. 964 // Don't start hiding the window again if it's already being hidden.
972 return window->layer()->GetTargetOpacity() != 0.0f && 965 return window->layer()->GetTargetOpacity() != 0.0f &&
973 AnimateHideWindow(window); 966 AnimateHideWindow(window);
974 } 967 }
975 } 968 }
976 969
977 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) {
978 delayed_old_layer_deletion_in_cross_fade_for_test_ = value;
979 }
980
981 } // namespace internal 970 } // namespace internal
982 } // namespace ash 971 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698