Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/ui/views/payments/view_stack.cc

Issue 2817533006: [Web Payments] Add PopMany and Size functions to ViewStack (Closed)
Patch Set: Remove unused Observer that caused use-after-free in tests. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
64
65 size_t pre_size = stack_.size();
66 // Erase N - 1 elements now, the last one will be erased when its animation
67 // completes
68 stack_.erase(stack_.end() - n, stack_.end() - 1);
69 DCHECK_EQ(pre_size - n + 1, stack_.size());
70
71 Pop();
72 }
73
74 size_t ViewStack::size() const {
75 return stack_.size();
76 }
77
62 bool ViewStack::CanProcessEventsWithinSubtree() const { 78 bool ViewStack::CanProcessEventsWithinSubtree() const {
63 return !slide_in_animator_->IsAnimating() && 79 return !slide_in_animator_->IsAnimating() &&
64 !slide_out_animator_->IsAnimating(); 80 !slide_out_animator_->IsAnimating();
65 } 81 }
66 82
67 void ViewStack::Layout() { 83 void ViewStack::Layout() {
68 views::View::Layout(); 84 views::View::Layout();
69 85
70 // If this view's bounds changed since the beginning of an animation, the 86 // If this view's bounds changed since the beginning of an animation, the
71 // animator's targets have to be changed as well. 87 // animator's targets have to be changed as well.
(...skipping 21 matching lines...) Expand all
93 } 109 }
94 110
95 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { 111 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
96 // This should only be called from slide_out_animator_ when the views going 112 // This should only be called from slide_out_animator_ when the views going
97 // out are done animating. 113 // out are done animating.
98 DCHECK_EQ(animator, slide_out_animator_.get()); 114 DCHECK_EQ(animator, slide_out_animator_.get());
99 115
100 stack_.pop_back(); 116 stack_.pop_back();
101 DCHECK(!stack_.empty()) << "State stack should never be empty"; 117 DCHECK(!stack_.empty()) << "State stack should never be empty";
102 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/view_stack.h ('k') | chrome/browser/ui/views/payments/view_stack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698