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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 // Animate the new view to be right on top of this one. | 43 // Animate the new view to be right on top of this one. |
| 44 slide_in_animator_->AnimateViewTo(view.get(), destination); | 44 slide_in_animator_->AnimateViewTo(view.get(), destination); |
| 45 } else { | 45 } else { |
| 46 view->SetBoundsRect(destination); | 46 view->SetBoundsRect(destination); |
| 47 view->Layout(); | 47 view->Layout(); |
| 48 AddChildView(view.get()); | 48 AddChildView(view.get()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 view->set_owned_by_client(); | 51 view->set_owned_by_client(); |
| 52 | |
| 53 // If we're pushing on top of an existing view, that view should be marked as | |
| 54 // invisible. | |
| 55 if (size()) | |
|
anthonyvd
2017/06/16 15:48:21
Doesn't this make the view invisible before the an
| |
| 56 stack_.back()->SetVisible(false); | |
| 57 | |
| 52 // Add the new view to the stack so it can be popped later when navigating | 58 // Add the new view to the stack so it can be popped later when navigating |
| 53 // back to the previous screen. | 59 // back to the previous screen. |
| 54 stack_.push_back(std::move(view)); | 60 stack_.push_back(std::move(view)); |
| 55 RequestFocus(); | 61 RequestFocus(); |
| 56 } | 62 } |
| 57 | 63 |
| 58 void ViewStack::Pop() { | 64 void ViewStack::Pop() { |
| 65 DCHECK_LT(1u, size()); // There must be at least one view left after popping. | |
| 66 | |
| 59 gfx::Rect destination = bounds(); | 67 gfx::Rect destination = bounds(); |
| 60 destination.set_origin(gfx::Point(width(), 0)); | 68 destination.set_origin(gfx::Point(width(), 0)); |
| 61 | 69 |
| 70 // Set the second-to-last view as visible, since it is about to be revealed | |
| 71 // when the last view animates out. | |
| 72 stack_[size() - 2]->SetVisible(true); | |
| 73 | |
| 62 slide_out_animator_->AnimateViewTo( | 74 slide_out_animator_->AnimateViewTo( |
| 63 stack_.back().get(), destination); | 75 stack_.back().get(), destination); |
| 64 } | 76 } |
| 65 | 77 |
| 66 void ViewStack::PopMany(int n) { | 78 void ViewStack::PopMany(int n) { |
| 67 DCHECK_LT(static_cast<size_t>(n), size()); // The stack can never be empty. | 79 DCHECK_LT(static_cast<size_t>(n), size()); // The stack can never be empty. |
| 68 | 80 |
| 69 size_t pre_size = stack_.size(); | 81 size_t pre_size = stack_.size(); |
| 70 // Erase N - 1 elements now, the last one will be erased when its animation | 82 // Erase N - 1 elements now, the last one will be erased when its animation |
| 71 // completes | 83 // completes |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 134 |
| 123 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 135 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
| 124 // This should only be called from slide_out_animator_ when the views going | 136 // This should only be called from slide_out_animator_ when the views going |
| 125 // out are done animating. | 137 // out are done animating. |
| 126 DCHECK_EQ(animator, slide_out_animator_.get()); | 138 DCHECK_EQ(animator, slide_out_animator_.get()); |
| 127 | 139 |
| 128 stack_.pop_back(); | 140 stack_.pop_back(); |
| 129 DCHECK(!stack_.empty()) << "State stack should never be empty"; | 141 DCHECK(!stack_.empty()) << "State stack should never be empty"; |
| 130 RequestFocus(); | 142 RequestFocus(); |
| 131 } | 143 } |
| OLD | NEW |