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

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

Issue 2802743002: [Web Payments] Fix view clipping when updating content. (Closed)
Patch Set: Let the hierarchy own the content view. 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
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_sheet_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/payment_request_sheet_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
6 6
7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
9 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 9 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
10 #include "components/payments/content/payment_request.h" 10 #include "components/payments/content/payment_request.h"
(...skipping 10 matching lines...) Expand all
21 21
22 PaymentRequestSheetController::PaymentRequestSheetController( 22 PaymentRequestSheetController::PaymentRequestSheetController(
23 PaymentRequestSpec* spec, 23 PaymentRequestSpec* spec,
24 PaymentRequestState* state, 24 PaymentRequestState* state,
25 PaymentRequestDialogView* dialog) 25 PaymentRequestDialogView* dialog)
26 : spec_(spec), state_(state), dialog_(dialog) {} 26 : spec_(spec), state_(state), dialog_(dialog) {}
27 27
28 PaymentRequestSheetController::~PaymentRequestSheetController() {} 28 PaymentRequestSheetController::~PaymentRequestSheetController() {}
29 29
30 std::unique_ptr<views::View> PaymentRequestSheetController::CreateView() { 30 std::unique_ptr<views::View> PaymentRequestSheetController::CreateView() {
31 // This will be owned by its encompassing ScrollView. 31 // This is owned by its parent.
32 content_view_ = new views::View; 32 content_view_ = new views::View;
33 33
34 FillContentView(content_view_); 34 FillContentView(content_view_);
35 35
36 return CreatePaymentView(); 36 return CreatePaymentView();
37 } 37 }
38 38
39 void PaymentRequestSheetController::UpdateContentView() { 39 void PaymentRequestSheetController::UpdateContentView() {
40 content_view_->RemoveAllChildViews(true); 40 content_view_->RemoveAllChildViews(true);
41 FillContentView(content_view_); 41 FillContentView(content_view_);
42 content_view_->Layout(); 42 content_view_->Layout();
43 pane_->SizeToPreferredSize();
43 } 44 }
44 45
45 std::unique_ptr<views::Button> 46 std::unique_ptr<views::Button>
46 PaymentRequestSheetController::CreatePrimaryButton() { 47 PaymentRequestSheetController::CreatePrimaryButton() {
47 return nullptr; 48 return nullptr;
48 } 49 }
49 50
50 base::string16 PaymentRequestSheetController::GetSecondaryButtonLabel() { 51 base::string16 PaymentRequestSheetController::GetSecondaryButtonLabel() {
51 return l10n_util::GetStringUTF16(IDS_CANCEL); 52 return l10n_util::GetStringUTF16(IDS_CANCEL);
52 } 53 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 layout->StartRow(0, 0); 99 layout->StartRow(0, 0);
99 // |header_view| will be deleted when |view| is. 100 // |header_view| will be deleted when |view| is.
100 layout->AddView( 101 layout->AddView(
101 CreateSheetHeaderView(ShouldShowHeaderBackArrow(), GetSheetTitle(), this) 102 CreateSheetHeaderView(ShouldShowHeaderBackArrow(), GetSheetTitle(), this)
102 .release()); 103 .release());
103 104
104 layout->StartRow(1, 0); 105 layout->StartRow(1, 0);
105 // |content_view| will go into a views::ScrollView so it needs to be sized now 106 // |content_view| will go into a views::ScrollView so it needs to be sized now
106 // otherwise it'll be sized to the ScrollView's viewport height, preventing 107 // otherwise it'll be sized to the ScrollView's viewport height, preventing
107 // the scroll bar from ever being shown. 108 // the scroll bar from ever being shown.
108 views::View* pane = new views::View; 109 pane_ = new views::View;
109 views::GridLayout* pane_layout = new views::GridLayout(pane); 110 views::GridLayout* pane_layout = new views::GridLayout(pane_);
110 views::ColumnSet* pane_columns = pane_layout->AddColumnSet(0); 111 views::ColumnSet* pane_columns = pane_layout->AddColumnSet(0);
111 pane_columns->AddColumn( 112 pane_columns->AddColumn(
112 views::GridLayout::Alignment::FILL, views::GridLayout::Alignment::LEADING, 113 views::GridLayout::Alignment::FILL, views::GridLayout::Alignment::LEADING,
113 0, views::GridLayout::SizeType::FIXED, kDialogWidth, kDialogWidth); 114 0, views::GridLayout::SizeType::FIXED, kDialogWidth, kDialogWidth);
114 pane->SetLayoutManager(pane_layout); 115 pane_->SetLayoutManager(pane_layout);
115 pane_layout->StartRow(0, 0); 116 pane_layout->StartRow(0, 0);
116 pane_layout->AddView(content_view_); 117 pane_layout->AddView(content_view_);
117 pane->SizeToPreferredSize(); 118 pane_->SizeToPreferredSize();
118 119
119 std::unique_ptr<views::ScrollView> scroll = 120 std::unique_ptr<views::ScrollView> scroll =
120 base::MakeUnique<views::ScrollView>(); 121 base::MakeUnique<views::ScrollView>();
121 scroll->EnableViewPortLayer(); 122 scroll->EnableViewPortLayer();
122 scroll->set_hide_horizontal_scrollbar(true); 123 scroll->set_hide_horizontal_scrollbar(true);
123 scroll->SetContents(pane); 124 scroll->SetContents(pane_);
124 layout->AddView(scroll.release()); 125 layout->AddView(scroll.release());
125 126
126 layout->StartRow(0, 0); 127 layout->StartRow(0, 0);
127 layout->AddView(CreateFooterView().release()); 128 layout->AddView(CreateFooterView().release());
128 129
129 return view; 130 return view;
130 } 131 }
131 132
132 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() { 133 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() {
133 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); 134 std::unique_ptr<views::View> container = base::MakeUnique<views::View>();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG)); 173 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG));
173 button->set_id(static_cast<int>(DialogViewID::CANCEL_BUTTON)); 174 button->set_id(static_cast<int>(DialogViewID::CANCEL_BUTTON));
174 trailing_buttons_container->AddChildView(button); 175 trailing_buttons_container->AddChildView(button);
175 176
176 layout->AddView(trailing_buttons_container.release()); 177 layout->AddView(trailing_buttons_container.release());
177 178
178 return container; 179 return container;
179 } 180 }
180 181
181 } // namespace payments 182 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_sheet_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698