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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/location.h" | 6 #include "base/location.h" |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "ui/gfx/animation/slide_animation.h" | 9 #include "ui/gfx/animation/slide_animation.h" |
10 #include "ui/message_center/message_center_style.h" | 10 #include "ui/message_center/message_center_style.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 void MessageListView::ResetRepositionSession() { | 180 void MessageListView::ResetRepositionSession() { |
181 // Don't call DoUpdateIfPossible(), but let Layout() do the task without | 181 // Don't call DoUpdateIfPossible(), but let Layout() do the task without |
182 // animation. Reset will cause the change of the bubble size itself, and | 182 // animation. Reset will cause the change of the bubble size itself, and |
183 // animation from the old location will look weird. | 183 // animation from the old location will look weird. |
184 if (reposition_top_ >= 0) { | 184 if (reposition_top_ >= 0) { |
185 has_deferred_task_ = false; | 185 has_deferred_task_ = false; |
186 // cancel cause OnBoundsAnimatorDone which deletes |deleted_when_done_|. | 186 // cancel cause OnBoundsAnimatorDone which deletes |deleted_when_done_|. |
187 animator_.Cancel(); | 187 animator_.Cancel(); |
188 base::STLDeleteContainerPointers(deleting_views_.begin(), | 188 for (auto view : deleting_views_) |
189 deleting_views_.end()); | 189 delete view; |
190 deleting_views_.clear(); | 190 deleting_views_.clear(); |
191 adding_views_.clear(); | 191 adding_views_.clear(); |
192 } | 192 } |
193 | 193 |
194 reposition_top_ = -1; | 194 reposition_top_ = -1; |
195 fixed_height_ = 0; | 195 fixed_height_ = 0; |
196 } | 196 } |
197 | 197 |
198 void MessageListView::ClearAllClosableNotifications( | 198 void MessageListView::ClearAllClosableNotifications( |
199 const gfx::Rect& visible_scroll_rect) { | 199 const gfx::Rect& visible_scroll_rect) { |
(...skipping 11 matching lines...) Expand all Loading... |
211 if (clearing_all_views_.empty()) { | 211 if (clearing_all_views_.empty()) { |
212 message_center_view()->OnAllNotificationsCleared(); | 212 message_center_view()->OnAllNotificationsCleared(); |
213 } else { | 213 } else { |
214 DoUpdateIfPossible(); | 214 DoUpdateIfPossible(); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 void MessageListView::OnBoundsAnimatorProgressed( | 218 void MessageListView::OnBoundsAnimatorProgressed( |
219 views::BoundsAnimator* animator) { | 219 views::BoundsAnimator* animator) { |
220 DCHECK_EQ(&animator_, animator); | 220 DCHECK_EQ(&animator_, animator); |
221 for (std::set<views::View*>::iterator iter = deleted_when_done_.begin(); | 221 for (auto view : deleted_when_done_) { |
222 iter != deleted_when_done_.end(); ++iter) { | 222 const gfx::SlideAnimation* animation = animator->GetAnimationForView(view); |
223 const gfx::SlideAnimation* animation = animator->GetAnimationForView(*iter); | |
224 if (animation) | 223 if (animation) |
225 (*iter)->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); | 224 view->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); |
226 } | 225 } |
227 } | 226 } |
228 | 227 |
229 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 228 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
230 base::STLDeleteContainerPointers(deleted_when_done_.begin(), | 229 for (auto view : deleted_when_done_) |
231 deleted_when_done_.end()); | 230 delete view; |
232 deleted_when_done_.clear(); | 231 deleted_when_done_.clear(); |
233 | 232 |
234 if (clear_all_started_) { | 233 if (clear_all_started_) { |
235 clear_all_started_ = false; | 234 clear_all_started_ = false; |
236 message_center_view()->OnAllNotificationsCleared(); | 235 message_center_view()->OnAllNotificationsCleared(); |
237 } | 236 } |
238 | 237 |
239 if (has_deferred_task_) { | 238 if (has_deferred_task_) { |
240 has_deferred_task_ = false; | 239 has_deferred_task_ = false; |
241 DoUpdateIfPossible(); | 240 DoUpdateIfPossible(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 int vertical_gap_to_target_from_top = GetInsets().height(); | 371 int vertical_gap_to_target_from_top = GetInsets().height(); |
373 for (int i = 0; i < target_index; i++) { | 372 for (int i = 0; i < target_index; i++) { |
374 views::View* child = child_at(i); | 373 views::View* child = child_at(i); |
375 int height = child->GetHeightForWidth(child_area.width()); | 374 int height = child->GetHeightForWidth(child_area.width()); |
376 height_cache[child] = height; | 375 height_cache[child] = height; |
377 if (deleting_views_.find(child) == deleting_views_.end()) | 376 if (deleting_views_.find(child) == deleting_views_.end()) |
378 vertical_gap_to_target_from_top += height + padding; | 377 vertical_gap_to_target_from_top += height + padding; |
379 } | 378 } |
380 | 379 |
381 // If the calculated length is changed from |repositon_top_|, it means that | 380 // If the calculated length is changed from |repositon_top_|, it means that |
382 // some of items above the targe are updated and their height are changed. | 381 // some of items above the target are updated and their height are changed. |
383 // Adjust the vertical length above the target. | 382 // Adjust the vertical length above the target. |
384 if (reposition_top_ != vertical_gap_to_target_from_top) { | 383 if (reposition_top_ != vertical_gap_to_target_from_top) { |
385 fixed_height_ -= reposition_top_ - vertical_gap_to_target_from_top; | 384 fixed_height_ -= reposition_top_ - vertical_gap_to_target_from_top; |
386 reposition_top_ = vertical_gap_to_target_from_top; | 385 reposition_top_ = vertical_gap_to_target_from_top; |
387 } | 386 } |
388 | 387 |
389 // Match the top with |reposition_top_|. | 388 // Match the top with |reposition_top_|. |
390 int y = reposition_top_; | 389 int y = reposition_top_; |
391 // Layout the target and the items below the target. | 390 // Layout the target and the items below the target. |
392 for (int i = target_index; i < child_count(); i++) { | 391 for (int i = target_index; i < child_count(); i++) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 base::TimeDelta::FromMilliseconds( | 465 base::TimeDelta::FromMilliseconds( |
467 kAnimateClearingNextNotificationDelayMS)); | 466 kAnimateClearingNextNotificationDelayMS)); |
468 } | 467 } |
469 } | 468 } |
470 | 469 |
471 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { | 470 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { |
472 SetRepositionTarget(target_rect); | 471 SetRepositionTarget(target_rect); |
473 } | 472 } |
474 | 473 |
475 } // namespace message_center | 474 } // namespace message_center |
OLD | NEW |