| Index: ui/views/corewm/window_animations.cc
|
| diff --git a/ui/views/corewm/window_animations.cc b/ui/views/corewm/window_animations.cc
|
| index 4eb2caeceaf1ad2054890b00bd36f4a765c35840..b2e255fde3765d39489bc43ca48b461a6a1e85ba 100644
|
| --- a/ui/views/corewm/window_animations.cc
|
| +++ b/ui/views/corewm/window_animations.cc
|
| @@ -109,6 +109,11 @@ int GetWindowVisibilityAnimationType(aura::Window* window) {
|
| return type;
|
| }
|
|
|
| +class HidingWindowAnimationObserver;
|
| +DEFINE_WINDOW_PROPERTY_KEY(HidingWindowAnimationObserver*,
|
| + kHidingWindowAnimationObserverKey,
|
| + NULL);
|
| +
|
| // Observes a hide animation.
|
| // A window can be hidden for a variety of reasons. Sometimes, Hide() will be
|
| // called and life is simple. Sometimes, the window is actually bound to a
|
| @@ -125,13 +130,24 @@ class HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,
|
| public aura::WindowObserver {
|
| public:
|
| explicit HidingWindowAnimationObserver(aura::Window* window)
|
| - : window_(window) {
|
| + : window_(window),
|
| + layers_detached_(false) {
|
| window_->AddObserver(this);
|
| + window->SetProperty(kHidingWindowAnimationObserverKey, this);
|
| }
|
| virtual ~HidingWindowAnimationObserver() {
|
| STLDeleteElements(&layers_);
|
| }
|
|
|
| + ui::Layer* DetachAndRecreateLayers() {
|
| + ui::Layer* old_layer = views::corewm::RecreateWindowLayers(window_, true);
|
| + // Make the new layer unvisible immediately.
|
| + window_->layer()->SetVisible(false);
|
| + layers_.push_back(old_layer);
|
| + layers_detached_ = true;
|
| + return old_layer;
|
| + }
|
| +
|
| private:
|
| // Overridden from ui::ImplicitAnimationObserver:
|
| virtual void OnImplicitAnimationsCompleted() OVERRIDE {
|
| @@ -142,6 +158,7 @@ class HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,
|
| if (animation_host)
|
| animation_host->OnWindowHidingAnimationCompleted();
|
| window_->RemoveObserver(this);
|
| + window_->ClearProperty(kHidingWindowAnimationObserverKey);
|
| }
|
| delete this;
|
| }
|
| @@ -149,15 +166,16 @@ class HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,
|
| // Overridden from aura::WindowObserver:
|
| virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
|
| DCHECK_EQ(window, window_);
|
| - DCHECK(layers_.empty());
|
| - AcquireAllLayers(window_);
|
| -
|
| - // If the Widget has views with layers, then it is necessary to take
|
| - // ownership of those layers too.
|
| - views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window_);
|
| - const views::Widget* const_widget = widget;
|
| - if (widget && const_widget->GetRootView() && widget->GetContentsView())
|
| - AcquireAllViewLayers(widget->GetContentsView());
|
| + DCHECK(layers_.empty() || layers_detached_);
|
| + if (!layers_detached_) {
|
| + AcquireAllLayers(window_);
|
| + // If the Widget has views with layers, then it is necessary to take
|
| + // ownership of those layers too.
|
| + views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window_);
|
| + const views::Widget* const_widget = widget;
|
| + if (widget && const_widget->GetRootView() && widget->GetContentsView())
|
| + AcquireAllViewLayers(widget->GetContentsView());
|
| + }
|
| window_->RemoveObserver(this);
|
| window_ = NULL;
|
| }
|
| @@ -186,6 +204,7 @@ class HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,
|
|
|
| aura::Window* window_;
|
| std::vector<ui::Layer*> layers_;
|
| + bool layers_detached_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserver);
|
| };
|
| @@ -546,6 +565,12 @@ ui::ImplicitAnimationObserver* CreateHidingWindowAnimationObserver(
|
| return new HidingWindowAnimationObserver(window);
|
| }
|
|
|
| +ui::Layer* DetachHidingAnimationLayer(aura::Window* window) {
|
| + HidingWindowAnimationObserver* observer =
|
| + window->GetProperty(kHidingWindowAnimationObserverKey);
|
| + return observer ? observer->DetachAndRecreateLayers() : NULL;
|
| +}
|
| +
|
| bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) {
|
| if (WindowAnimationsDisabled(window))
|
| return false;
|
|
|