Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 views::BoundsAnimator* animator) { | 295 views::BoundsAnimator* animator) { |
| 296 DCHECK_EQ(&animator_, animator); | 296 DCHECK_EQ(&animator_, animator); |
| 297 for (auto* view : deleted_when_done_) { | 297 for (auto* view : deleted_when_done_) { |
| 298 const gfx::SlideAnimation* animation = animator->GetAnimationForView(view); | 298 const gfx::SlideAnimation* animation = animator->GetAnimationForView(view); |
| 299 if (animation) | 299 if (animation) |
| 300 view->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); | 300 view->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 304 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
| 305 bool need_update = false; | |
| 306 | |
| 307 if (clear_all_started_) { | |
| 308 clear_all_started_ = false; | |
| 309 // TODO(yoshiki): we shouldn't touch views in OnAllNotificationsCleared(). | |
| 310 // Or rename it to like OnAllNotificationsClearing(). | |
| 311 for (auto& observer : observers_) | |
| 312 observer.OnAllNotificationsCleared(); | |
| 313 | |
| 314 if (!deleted_when_done_.empty()) | |
|
Eliot Courtney
2017/06/01 07:53:16
Could you add a comment about why we need to call
yoshiki
2017/06/01 08:31:48
Done.
| |
| 315 need_update = true; | |
| 316 } | |
| 317 | |
| 318 // Ensures that the views are not destroyed yet. | |
|
Eliot Courtney
2017/06/01 07:53:16
Since this is a DCHECK, maybe "None of these views
yoshiki
2017/06/01 08:31:48
Done.
| |
| 319 DCHECK(std::all_of(deleted_when_done_.begin(), deleted_when_done_.end(), | |
| 320 [this](views::View* view) { return Contains(view); })); | |
| 321 | |
| 305 for (auto* view : deleted_when_done_) | 322 for (auto* view : deleted_when_done_) |
| 306 delete view; | 323 delete view; |
| 307 deleted_when_done_.clear(); | 324 deleted_when_done_.clear(); |
| 308 | 325 |
| 309 if (clear_all_started_) { | 326 if (has_deferred_task_) { |
| 310 clear_all_started_ = false; | 327 has_deferred_task_ = false; |
| 311 for (auto& observer : observers_) | 328 need_update = true; |
| 312 observer.OnAllNotificationsCleared(); | |
| 313 } | 329 } |
| 314 | 330 |
| 315 if (has_deferred_task_) { | 331 if (need_update) |
| 316 has_deferred_task_ = false; | |
| 317 DoUpdateIfPossible(); | 332 DoUpdateIfPossible(); |
| 318 } | |
| 319 | 333 |
| 320 if (GetWidget()) | 334 if (GetWidget()) |
| 321 GetWidget()->SynthesizeMouseMoveEvent(); | 335 GetWidget()->SynthesizeMouseMoveEvent(); |
| 322 | 336 |
| 323 if (quit_message_loop_after_animation_for_test_) | 337 if (quit_message_loop_after_animation_for_test_) |
| 324 base::MessageLoop::current()->QuitWhenIdle(); | 338 base::MessageLoop::current()->QuitWhenIdle(); |
| 325 } | 339 } |
| 326 | 340 |
| 327 bool MessageListView::IsValidChild(const views::View* child) const { | 341 bool MessageListView::IsValidChild(const views::View* child) const { |
| 328 return child->visible() && | 342 return child->visible() && |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 base::TimeDelta::FromMilliseconds( | 586 base::TimeDelta::FromMilliseconds( |
| 573 kAnimateClearingNextNotificationDelayMS)); | 587 kAnimateClearingNextNotificationDelayMS)); |
| 574 } | 588 } |
| 575 } | 589 } |
| 576 | 590 |
| 577 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { | 591 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { |
| 578 SetRepositionTarget(target_rect); | 592 SetRepositionTarget(target_rect); |
| 579 } | 593 } |
| 580 | 594 |
| 581 } // namespace message_center | 595 } // namespace message_center |
| OLD | NEW |