| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/message_center/views/toast_contents_view.h" | 5 #include "ui/message_center/views/toast_contents_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 collection_->IncrementDeferCounter(); | 207 collection_->IncrementDeferCounter(); |
| 208 fade_animation_->Stop(); | 208 fade_animation_->Stop(); |
| 209 | 209 |
| 210 closing_animation_ = (is_closing_ ? fade_animation_.get() : NULL); | 210 closing_animation_ = (is_closing_ ? fade_animation_.get() : NULL); |
| 211 fade_animation_->Reset(1); | 211 fade_animation_->Reset(1); |
| 212 fade_animation_->Hide(); | 212 fade_animation_->Hide(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ToastContentsView::OnBoundsAnimationEndedOrCancelled( | 215 void ToastContentsView::OnBoundsAnimationEndedOrCancelled( |
| 216 const ui::Animation* animation) { | 216 const ui::Animation* animation) { |
| 217 if (is_closing_ && closing_animation_ == animation && GetWidget()) |
| 218 GetWidget()->Close(); |
| 219 |
| 220 // This cannot be called before GetWidget()->Close(). Decrementing defer count |
| 221 // will invoke update, which may invoke another close animation with |
| 222 // incrementing defer counter. Close() after such process will cause a |
| 223 // mismatch between increment/decrement. See crbug.com/238477 |
| 217 if (collection_) | 224 if (collection_) |
| 218 collection_->DecrementDeferCounter(); | 225 collection_->DecrementDeferCounter(); |
| 219 | |
| 220 if (is_closing_ && closing_animation_ == animation && GetWidget()) | |
| 221 GetWidget()->Close(); | |
| 222 } | 226 } |
| 223 | 227 |
| 224 // ui::AnimationDelegate | 228 // ui::AnimationDelegate |
| 225 void ToastContentsView::AnimationProgressed(const ui::Animation* animation) { | 229 void ToastContentsView::AnimationProgressed(const ui::Animation* animation) { |
| 226 if (animation == bounds_animation_.get()) { | 230 if (animation == bounds_animation_.get()) { |
| 227 gfx::Rect current(animation->CurrentValueBetween( | 231 gfx::Rect current(animation->CurrentValueBetween( |
| 228 animated_bounds_start_, animated_bounds_end_)); | 232 animated_bounds_start_, animated_bounds_end_)); |
| 229 GetWidget()->SetBounds(current); | 233 GetWidget()->SetBounds(current); |
| 230 } else if (animation == fade_animation_.get()) { | 234 } else if (animation == fade_animation_.get()) { |
| 231 unsigned char opacity = | 235 unsigned char opacity = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 289 } |
| 286 | 290 |
| 287 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { | 291 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { |
| 288 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, | 292 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, |
| 289 bounds.y(), | 293 bounds.y(), |
| 290 kClosedToastWidth, | 294 kClosedToastWidth, |
| 291 bounds.height()); | 295 bounds.height()); |
| 292 } | 296 } |
| 293 | 297 |
| 294 } // namespace message_center | 298 } // namespace message_center |
| OLD | NEW |