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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/compositor/layer_type.h" |
8 #include "ui/views/layout/fill_layout.h" | 9 #include "ui/views/layout/fill_layout.h" |
9 | 10 |
10 ViewStack::ViewStack() | 11 ViewStack::ViewStack() |
11 : slide_in_animator_(base::MakeUnique<views::BoundsAnimator>(this)), | 12 : slide_in_animator_(base::MakeUnique<views::BoundsAnimator>(this)), |
12 slide_out_animator_(base::MakeUnique<views::BoundsAnimator>(this)) { | 13 slide_out_animator_(base::MakeUnique<views::BoundsAnimator>(this)) { |
13 SetLayoutManager(new views::FillLayout()); | 14 SetLayoutManager(new views::FillLayout()); |
14 | 15 |
15 slide_out_animator_->AddObserver(this); | 16 slide_out_animator_->AddObserver(this); |
16 // Paint to a layer and Mask to Bounds, otherwise descendant views that paint | 17 // Paint to a layer and Mask to Bounds, otherwise descendant views that paint |
17 // to a layer themselves will still paint while they're being animated out and | 18 // to a layer themselves will still paint while they're being animated out and |
18 // are out of bounds of their parent. | 19 // are out of bounds of their parent. |
19 SetPaintToLayer(true); | 20 SetPaintToLayer(ui::LAYER_TEXTURED); |
20 layer()->SetMasksToBounds(true); | 21 layer()->SetMasksToBounds(true); |
21 } | 22 } |
22 | 23 |
23 ViewStack::~ViewStack() {} | 24 ViewStack::~ViewStack() {} |
24 | 25 |
25 void ViewStack::Push(std::unique_ptr<views::View> view, bool animate) { | 26 void ViewStack::Push(std::unique_ptr<views::View> view, bool animate) { |
26 gfx::Rect destination = bounds(); | 27 gfx::Rect destination = bounds(); |
27 destination.set_origin(gfx::Point(0, 0)); | 28 destination.set_origin(gfx::Point(0, 0)); |
28 | 29 |
29 if (animate) { | 30 if (animate) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 91 } |
91 | 92 |
92 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 93 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
93 // This should only be called from slide_out_animator_ when the views going | 94 // This should only be called from slide_out_animator_ when the views going |
94 // out are done animating. | 95 // out are done animating. |
95 DCHECK_EQ(animator, slide_out_animator_.get()); | 96 DCHECK_EQ(animator, slide_out_animator_.get()); |
96 | 97 |
97 stack_.pop_back(); | 98 stack_.pop_back(); |
98 DCHECK(!stack_.empty()) << "State stack should never be empty"; | 99 DCHECK(!stack_.empty()) << "State stack should never be empty"; |
99 } | 100 } |
OLD | NEW |