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

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

Issue 10882043: Revert 153291 - 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 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;
53 } 54 }
54 55
55 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType, 56 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType,
56 kWindowVisibilityAnimationTypeKey, 57 kWindowVisibilityAnimationTypeKey,
57 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 58 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
58 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0); 59 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);
59 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition, 60 DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition,
60 kWindowVisibilityAnimationTransitionKey, 61 kWindowVisibilityAnimationTransitionKey,
61 ANIMATE_BOTH); 62 ANIMATE_BOTH);
62 DEFINE_WINDOW_PROPERTY_KEY(float, 63 DEFINE_WINDOW_PROPERTY_KEY(float,
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // aura::WindowObserver overrides: 657 // aura::WindowObserver overrides:
657 virtual void OnWindowDestroying(Window* window) OVERRIDE { 658 virtual void OnWindowDestroying(Window* window) OVERRIDE {
658 if (layer_) 659 if (layer_)
659 layer_->GetAnimator()->StopAnimating(); 660 layer_->GetAnimator()->StopAnimating();
660 // Delete is scheduled in OnImplicitAnimationsCompleted(). 661 // Delete is scheduled in OnImplicitAnimationsCompleted().
661 Cleanup(); 662 Cleanup();
662 } 663 }
663 664
664 // ui::ImplicitAnimationObserver overrides: 665 // ui::ImplicitAnimationObserver overrides:
665 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 666 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
666 delete this; 667 // ImplicitAnimationObserver's base class uses the object after
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);
667 } 674 }
668 675
669 private: 676 private:
670 // Can be called multiple times if the window is closed or the compositor 677 // Can be called multiple times if the window is closed or the compositor
671 // fails in the middle of the animation. 678 // fails in the middle of the animation.
672 void Cleanup() { 679 void Cleanup() {
673 if (window_) { 680 if (window_) {
674 window_->RemoveObserver(this); 681 window_->RemoveObserver(this);
675 window_ = NULL; 682 window_ = NULL;
676 } 683 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 } 975 }
969 if (visible) { 976 if (visible) {
970 return AnimateShowWindow(window); 977 return AnimateShowWindow(window);
971 } else { 978 } else {
972 // Don't start hiding the window again if it's already being hidden. 979 // Don't start hiding the window again if it's already being hidden.
973 return window->layer()->GetTargetOpacity() != 0.0f && 980 return window->layer()->GetTargetOpacity() != 0.0f &&
974 AnimateHideWindow(window); 981 AnimateHideWindow(window);
975 } 982 }
976 } 983 }
977 984
985 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) {
986 delayed_old_layer_deletion_in_cross_fade_for_test_ = value;
987 }
988
978 } // namespace internal 989 } // namespace internal
979 } // namespace ash 990 } // 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