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

Side by Side Diff: ash/common/wm/overview/window_selector_item.cc

Issue 2337383003: [ash-md] Corrects a crash when a window is destroyed after leaving overview (Closed)
Patch Set: [ash-md] Corrects a crash when a window is destroyed after leaving overview Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/wm/overview/window_selector_item.h" 5 #include "ash/common/wm/overview/window_selector_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 15 matching lines...) Expand all
26 #include "base/auto_reset.h" 26 #include "base/auto_reset.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "base/time/time.h" 29 #include "base/time/time.h"
30 #include "grit/ash_resources.h" 30 #include "grit/ash_resources.h"
31 #include "grit/ash_strings.h" 31 #include "grit/ash_strings.h"
32 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/compositor/layer_animation_sequence.h" 34 #include "ui/compositor/layer_animation_sequence.h"
35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
36 #include "ui/gfx/animation/slide_animation.h"
36 #include "ui/gfx/canvas.h" 37 #include "ui/gfx/canvas.h"
37 #include "ui/gfx/color_utils.h" 38 #include "ui/gfx/color_utils.h"
38 #include "ui/gfx/geometry/safe_integer_conversions.h" 39 #include "ui/gfx/geometry/safe_integer_conversions.h"
39 #include "ui/gfx/geometry/vector2d.h" 40 #include "ui/gfx/geometry/vector2d.h"
40 #include "ui/gfx/paint_vector_icon.h" 41 #include "ui/gfx/paint_vector_icon.h"
41 #include "ui/gfx/transform_util.h" 42 #include "ui/gfx/transform_util.h"
42 #include "ui/gfx/vector_icons_public.h" 43 #include "ui/gfx/vector_icons_public.h"
43 #include "ui/strings/grit/ui_strings.h" 44 #include "ui/strings/grit/ui_strings.h"
44 #include "ui/views/background.h" 45 #include "ui/views/background.h"
45 #include "ui/views/border.h" 46 #include "ui/views/border.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 item_window_(item_window), 191 item_window_(item_window),
191 corner_radius_(corner_radius), 192 corner_radius_(corner_radius),
192 initial_color_(background), 193 initial_color_(background),
193 target_color_(background), 194 target_color_(background),
194 current_value_(0), 195 current_value_(0),
195 layer_(nullptr), 196 layer_(nullptr),
196 animation_(new gfx::SlideAnimation(this)) {} 197 animation_(new gfx::SlideAnimation(this)) {}
197 198
198 ~RoundedContainerView() override { StopObservingLayerAnimations(); } 199 ~RoundedContainerView() override { StopObservingLayerAnimations(); }
199 200
200 void OnItemRestored() { item_ = nullptr; } 201 void OnItemRestored() {
202 item_ = nullptr;
203 item_window_ = nullptr;
204 }
201 205
202 // Starts observing layer animations so that actions can be taken when 206 // Starts observing layer animations so that actions can be taken when
203 // particular animations (opacity) complete. It should only be called once 207 // particular animations (opacity) complete. It should only be called once
204 // when the initial fade in animation is started. 208 // when the initial fade in animation is started.
205 void ObserveLayerAnimations(ui::Layer* layer) { 209 void ObserveLayerAnimations(ui::Layer* layer) {
206 DCHECK(!layer_); 210 DCHECK(!layer_);
207 layer_ = layer; 211 layer_ = layer;
208 layer_->GetAnimator()->AddObserver(this); 212 layer_->GetAnimator()->AddObserver(this);
209 } 213 }
210 214
211 // Stops observing layer animations 215 // Stops observing layer animations
212 void StopObservingLayerAnimations() { 216 void StopObservingLayerAnimations() {
213 if (!layer_) 217 if (!layer_)
214 return; 218 return;
215 layer_->GetAnimator()->RemoveObserver(this); 219 layer_->GetAnimator()->RemoveObserver(this);
216 layer_ = nullptr; 220 layer_ = nullptr;
217 } 221 }
218 222
223 // Used by tests to set animation state.
224 gfx::SlideAnimation* animation() { return animation_.get(); }
225
219 void set_color(SkColor target_color) { target_color_ = target_color; } 226 void set_color(SkColor target_color) { target_color_ = target_color; }
220 227
221 // Starts a color animation using |tween_type|. The animation will change the 228 // Starts a color animation using |tween_type|. The animation will change the
222 // color from |initial_color_| to |target_color_| over |duration| specified 229 // color from |initial_color_| to |target_color_| over |duration| specified
223 // in milliseconds. 230 // in milliseconds.
224 // This animation can start once the implicit layer fade-in opacity animation 231 // This animation can start once the implicit layer fade-in opacity animation
225 // is completed. It is used to transition color from the opaque original 232 // is completed. It is used to transition color from the opaque original
226 // window header color to |kLabelBackgroundColor| on entry into overview mode 233 // window header color to |kLabelBackgroundColor| on entry into overview mode
227 // and from |kLabelBackgroundColor| back to the original window header color 234 // and from |kLabelBackgroundColor| back to the original window header color
228 // on exit from the overview mode. 235 // on exit from the overview mode.
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 // overview mode is shut down. 896 // overview mode is shut down.
890 views::Widget* widget_ptr = widget.get(); 897 views::Widget* widget_ptr = widget.get();
891 std::unique_ptr<CleanupAnimationObserver> observer( 898 std::unique_ptr<CleanupAnimationObserver> observer(
892 new CleanupAnimationObserver(std::move(widget))); 899 new CleanupAnimationObserver(std::move(widget)));
893 animation_settings->AddObserver(observer.get()); 900 animation_settings->AddObserver(observer.get());
894 window_selector_->delegate()->AddDelayedAnimationObserver( 901 window_selector_->delegate()->AddDelayedAnimationObserver(
895 std::move(observer)); 902 std::move(observer));
896 widget_ptr->SetOpacity(0.f); 903 widget_ptr->SetOpacity(0.f);
897 } 904 }
898 905
906 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() {
907 return background_view_ ? background_view_->animation() : nullptr;
908 }
909
899 } // namespace ash 910 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698