Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/views/payments/view_stack.h" | 5 #include "chrome/browser/ui/views/payments/view_stack.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ViewStack::Pop() { | 54 void ViewStack::Pop() { |
| 55 gfx::Rect destination = bounds(); | 55 gfx::Rect destination = bounds(); |
| 56 destination.set_origin(gfx::Point(width(), 0)); | 56 destination.set_origin(gfx::Point(width(), 0)); |
| 57 | 57 |
| 58 slide_out_animator_->AnimateViewTo( | 58 slide_out_animator_->AnimateViewTo( |
| 59 stack_.back().get(), destination); | 59 stack_.back().get(), destination); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ViewStack::PopMany(int n) { | |
| 63 DCHECK_LT(static_cast<size_t>(n), size()); // The stack can never be empty. | |
|
Mathieu
2017/04/13 16:55:23
how does Pop handle popping the last view?
anthonyvd
2017/04/13 20:22:58
It doesn't. The view would animate out but hit "DC
| |
| 64 | |
| 65 // Erase N - 1 elements now, the last one will be erased when its animation | |
| 66 // completes | |
| 67 stack_.erase(stack_.end() - n, stack_.end() - 1); | |
| 68 | |
| 69 Pop(); | |
| 70 } | |
| 71 | |
| 72 size_t ViewStack::size() const { | |
| 73 return stack_.size(); | |
| 74 } | |
| 75 | |
| 62 bool ViewStack::CanProcessEventsWithinSubtree() const { | 76 bool ViewStack::CanProcessEventsWithinSubtree() const { |
| 63 return !slide_in_animator_->IsAnimating() && | 77 return !slide_in_animator_->IsAnimating() && |
| 64 !slide_out_animator_->IsAnimating(); | 78 !slide_out_animator_->IsAnimating(); |
| 65 } | 79 } |
| 66 | 80 |
| 67 void ViewStack::Layout() { | 81 void ViewStack::Layout() { |
| 68 views::View::Layout(); | 82 views::View::Layout(); |
| 69 | 83 |
| 70 // If this view's bounds changed since the beginning of an animation, the | 84 // If this view's bounds changed since the beginning of an animation, the |
| 71 // animator's targets have to be changed as well. | 85 // animator's targets have to be changed as well. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 93 } | 107 } |
| 94 | 108 |
| 95 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 109 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
| 96 // This should only be called from slide_out_animator_ when the views going | 110 // This should only be called from slide_out_animator_ when the views going |
| 97 // out are done animating. | 111 // out are done animating. |
| 98 DCHECK_EQ(animator, slide_out_animator_.get()); | 112 DCHECK_EQ(animator, slide_out_animator_.get()); |
| 99 | 113 |
| 100 stack_.pop_back(); | 114 stack_.pop_back(); |
| 101 DCHECK(!stack_.empty()) << "State stack should never be empty"; | 115 DCHECK(!stack_.empty()) << "State stack should never be empty"; |
| 102 } | 116 } |
| OLD | NEW |