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

Unified Diff: ui/wm/core/window_animations.cc

Issue 343753007: Fix a leak in wm::AnimateOnChildWindowVisibilityChanged(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: The test and the fix. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/wm/core/window_animations_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/window_animations.cc
diff --git a/ui/wm/core/window_animations.cc b/ui/wm/core/window_animations.cc
index a79db3a15d6c45a76d6cdb78a8e3e7dc2db5035a..e536eadc1c848cf9c2d3f028549f5b6d245a0742 100644
--- a/ui/wm/core/window_animations.cc
+++ b/ui/wm/core/window_animations.cc
@@ -58,7 +58,8 @@ const float kWindowAnimation_Vertical_TranslateY = 15.f;
// The subclass will determine when the animation is completed.
class HidingWindowAnimationObserverBase : public aura::WindowObserver {
public:
- HidingWindowAnimationObserverBase(aura::Window* window) : window_(window) {
+ explicit HidingWindowAnimationObserverBase(aura::Window* window)
+ : window_(window) {
window_->AddObserver(this);
}
virtual ~HidingWindowAnimationObserverBase() {
@@ -396,31 +397,29 @@ class RotateHidingWindowAnimationObserver
: public HidingWindowAnimationObserverBase,
public ui::LayerAnimationObserver {
public:
- RotateHidingWindowAnimationObserver(aura::Window* window)
- : HidingWindowAnimationObserverBase(window), last_sequence_(NULL) {}
+ explicit RotateHidingWindowAnimationObserver(aura::Window* window)
+ : HidingWindowAnimationObserverBase(window) {}
virtual ~RotateHidingWindowAnimationObserver() {}
- void set_last_sequence(ui::LayerAnimationSequence* last_sequence) {
- last_sequence_ = last_sequence;
+ void SetLastSequence(ui::LayerAnimationSequence* sequence) {
+ DCHECK(sequence);
+ sequence->AddObserver(this);
+ DetachAndRecreateLayers();
}
// ui::LayerAnimationObserver:
virtual void OnLayerAnimationEnded(
ui::LayerAnimationSequence* sequence) OVERRIDE {
- if (last_sequence_ == sequence)
- OnAnimationCompleted();
+ OnAnimationCompleted();
}
virtual void OnLayerAnimationAborted(
ui::LayerAnimationSequence* sequence) OVERRIDE {
- if (last_sequence_ == sequence)
- OnAnimationCompleted();
+ OnAnimationCompleted();
}
virtual void OnLayerAnimationScheduled(
ui::LayerAnimationSequence* sequence) OVERRIDE {}
private:
- ui::LayerAnimationSequence* last_sequence_;
-
DISALLOW_COPY_AND_ASSIGN(RotateHidingWindowAnimationObserver);
};
@@ -481,11 +480,11 @@ void AddLayerAnimationsForRotate(aura::Window* window, bool show) {
rotation.release(), duration));
ui::LayerAnimationSequence* last_sequence =
new ui::LayerAnimationSequence(transition.release());
+
+ if (observer)
+ observer->SetLastSequence(last_sequence);
sky 2014/07/09 20:32:12 If you do this here, doesn't that mean the animati
please use gerrit instead 2014/07/09 20:53:55 Hm, I think you're right. The problem I'm encounte
+
window->layer()->GetAnimator()->ScheduleAnimation(last_sequence);
- if (observer) {
- observer->set_last_sequence(last_sequence);
- observer->DetachAndRecreateLayers();
- }
}
void AnimateShowWindow_Rotate(aura::Window* window) {
« no previous file with comments | « no previous file | ui/wm/core/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698