Skip to content

Commit

Permalink
Remove references to ui/views/layout/layout_constants.h
Browse files Browse the repository at this point in the history
Replace references to constants in ui/views/layout/layout_constants.h with their
equivalents using ChromeLayoutProvider.

The approach taken is to push the DISTANCE_UNRELATED_CONTROL_VERTICAL constant down to
views::LayoutProvider. Other approaches considered were to use DISTANCE_RELATED_CONTROL_VERTICAL
here which did not seem correct or define a local constant in the dialog_example.cc

BUG=691897

Review-Url: https://codereview.chromium.org/2934503002
Cr-Commit-Position: refs/heads/master@{#478427}
  • Loading branch information
ananta authored and Commit Bot committed Jun 9, 2017
1 parent 064bcb3 commit 478f3b2
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 42 deletions.
3 changes: 2 additions & 1 deletion chrome/browser/chromeos/enrollment_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ void EnrollmentDialogView::InitDialog() {
grid_layout->StartRow(0, 0);
grid_layout->AddView(label);
grid_layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
0,
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
grid_layout->Layout(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window,
dialog_body_contents->SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kVertical,
provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS),
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL)));
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL)));
dialog_body_contents->AddChildView(new AppInfoSummaryPanel(profile, app));
dialog_body_contents->AddChildView(new AppInfoPermissionsPanel(profile, app));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void AppInfoSummaryPanel::AddSubviews() {

views::View* vertical_stack =
CreateVerticalStack(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL));
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
AddChildView(vertical_stack);

AddDescriptionAndLinksControl(vertical_stack);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/autofill/save_card_bubble_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ std::unique_ptr<views::View> SaveCardBubbleViews::CreateMainContentView() {

view->SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kVertical, gfx::Insets(),
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL)));
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL)));

// Add the card type icon, last four digits and expiration date.
views::View* description_view = new views::View();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/collected_cookies_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ views::View* CollectedCookiesViews::CreateAllowedPane() {
GridLayout* layout = GridLayout::CreatePanel(pane);
int unrelated_vertical_distance =
ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL);
views::DISTANCE_UNRELATED_CONTROL_VERTICAL);

const int single_column_layout_id = 0;
views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
Expand Down Expand Up @@ -453,7 +453,7 @@ views::View* CollectedCookiesViews::CreateBlockedPane() {
GridLayout* layout = GridLayout::CreatePanel(pane);
int unrelated_vertical_distance =
ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL);
views::DISTANCE_UNRELATED_CONTROL_VERTICAL);

const int single_column_layout_id = 0;
views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/content_setting_bubble_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void ContentSettingBubbleContents::Init() {
const int related_control_vertical_spacing =
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
const int unrelated_control_vertical_spacing =
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);

const int kSingleColumnSetId = 0;
views::ColumnSet* column_set = layout->AddColumnSet(kSingleColumnSetId);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/crypto_module_password_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ void CryptoModulePasswordDialogView::Init(const std::string& hostname,

layout->StartRow(0, 0);
layout->AddView(reason_label_);
layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

layout->StartRow(0, 1);
layout->AddView(password_label_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView(
promotion_text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->StartRow(0, kLabelColumnSet);
layout->AddView(promotion_text_label_);
layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->StartRow(0, kDoubleButtonColumnSet);
layout->AddView(send_sms_button_);
layout->AddView(no_button_);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/extensions/chooser_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ views::ClientView* ChooserDialogView::CreateClientView(views::Widget* widget) {
new views::DialogClientView(widget, GetContentsView());
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
client->SetButtonRowInsets(gfx::Insets(
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL), 0, 0,
0));
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL),
0, 0, 0));
return client;
}

Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ui/views/harmony/chrome_layout_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int ChromeLayoutProvider::GetDistanceMetric(int metric) const {
case DISTANCE_BUTTON_MINIMUM_WIDTH:
return views::kMinimumButtonWidth;
case DISTANCE_CONTROL_LIST_VERTICAL:
return GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
return GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
case DISTANCE_DIALOG_BUTTON_TOP:
return 0;
case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL:
Expand All @@ -44,8 +44,6 @@ int ChromeLayoutProvider::GetDistanceMetric(int metric) const {
return views::kUnrelatedControlHorizontalSpacing;
case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE:
return views::kUnrelatedControlLargeHorizontalSpacing;
case DISTANCE_UNRELATED_CONTROL_VERTICAL:
return views::kUnrelatedControlVerticalSpacing;
case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE:
return views::kUnrelatedControlLargeVerticalSpacing;
default:
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/ui/views/harmony/chrome_layout_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ enum ChromeDistanceMetric {
DISTANCE_UNRELATED_CONTROL_HORIZONTAL,
// Larger horizontal spacing between unrelated controls.
DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE,
// Vertical spacing between controls that are logically unrelated.
DISTANCE_UNRELATED_CONTROL_VERTICAL,
// Larger vertical spacing between unrelated controls.
DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE,
};
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/harmony/harmony_layout_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int HarmonyLayoutProvider::GetDistanceMetric(int metric) const {
return kHarmonyLayoutUnit;
case DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE:
return kHarmonyLayoutUnit;
case DISTANCE_UNRELATED_CONTROL_VERTICAL:
case views::DISTANCE_UNRELATED_CONTROL_VERTICAL:
return kHarmonyLayoutUnit;
case DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE:
return kHarmonyLayoutUnit;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/login_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ LoginView::LoginView(const base::string16& authority,
layout->AddView(password_field_);

if (provider->UseExtraDialogPadding()) {
layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
}

if (login_model_data) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/profiles/profile_chooser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ views::View* ProfileChooserView::CreateAccountRemovalView() {
bool is_primary_account = primary_account == account_id_to_remove_;

const int unrelated_vertical_spacing =
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);

// Adds main text.
layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
Expand Down Expand Up @@ -1575,7 +1575,7 @@ views::View* ProfileChooserView::CreateSwitchUserView() {
columns->AddPaddingColumn(0, dialog_insets.right());

const int unrelated_vertical_spacing =
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);

// Adds main text.
layout->StartRowWithPadding(1, 1, 0, unrelated_vertical_spacing);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/sad_tab_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ views::Label* CreateFormattedLabel(const base::string16& message) {
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetLineHeight(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL));
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
return label;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ SadTabView::SadTabView(content::WebContents* web_contents,
views::GridLayout::LEADING);

layout->AddPaddingRow(2, provider->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL));
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

views::Widget::InitParams sad_tab_params(
views::Widget::InitParams::TYPE_CONTROL);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TabModalConfirmDialogViews::TabModalConfirmDialogViews(
views::MessageBoxView::InitParams init_params(delegate->GetDialogMessage());
init_params.inter_row_vertical_spacing =
ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL);
views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
message_box_view_ = new views::MessageBoxView(init_params);

base::string16 link_text(delegate->GetLinkText());
Expand Down
18 changes: 9 additions & 9 deletions chrome/browser/ui/views/translate/translate_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ views::View* TranslateBubbleView::CreateViewBeforeTranslate() {
}

layout->AddPaddingRow(0, provider->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL));
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

layout->StartRow(0, COLUMN_SET_ID_CONTENT);
views::LabelButton* accept_button =
Expand Down Expand Up @@ -706,8 +706,8 @@ views::View* TranslateBubbleView::CreateViewTranslating() {
AddIconToLayout(layout);
layout->AddView(label);

layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

layout->StartRow(0, COLUMN_SET_ID_CONTENT);
views::LabelButton* revert_button =
Expand Down Expand Up @@ -759,8 +759,8 @@ views::View* TranslateBubbleView::CreateViewAfterTranslate() {
layout->AddView(
CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));

layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

layout->StartRow(0, COLUMN_SET_ID_CONTENT);
views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
Expand Down Expand Up @@ -810,8 +810,8 @@ views::View* TranslateBubbleView::CreateViewError() {
layout->AddView(
CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));

layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

layout->StartRow(0, COLUMN_SET_ID_CONTENT);
views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
Expand Down Expand Up @@ -909,8 +909,8 @@ views::View* TranslateBubbleView::CreateViewAdvanced() {
layout->AddView(advanced_always_translate_checkbox_);
}

layout->AddPaddingRow(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));

layout->StartRow(0, COLUMN_SET_ID_BUTTONS);
// TODO(estade): this should use CreateExtraView().
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/try_chrome_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TryChromeDialogView::Result TryChromeDialogView::ShowDialog(
const int unrelated_space_horiz =
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL);
const int unrelated_space_vert =
provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
const int button_spacing_horiz =
provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/uninstall_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void UninstallView::SetupControls() {

const int checkbox_indent = provider->GetDistanceMetric(
DISTANCE_SUBSECTION_HORIZONTAL_INDENT);
const int unrelated_vertical_spacing = provider->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL);
const int unrelated_vertical_spacing =
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
const int related_vertical_spacing = provider->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_VERTICAL);
const int related_horizontal_spacing = provider->GetDistanceMetric(
Expand Down
9 changes: 5 additions & 4 deletions ui/views/examples/dialog_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ void DialogExample::CreateExampleView(View* container) {
const float kFixed = 0.f;
const float kStretchy = 1.f;

views::LayoutProvider* provider = views::LayoutProvider::Get();
const int horizontal_spacing =
views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
GridLayout* layout = GridLayout::CreatePanel(container);
container->SetLayoutManager(layout);
ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId);
Expand Down Expand Up @@ -172,8 +172,9 @@ void DialogExample::CreateExampleView(View* container) {
column_set = layout->AddColumnSet(kButtonsColumnId);
column_set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, kStretchy,
GridLayout::USE_PREF, 0, 0);
layout->StartRowWithPadding(kFixed, kButtonsColumnId, kFixed,
kUnrelatedControlVerticalSpacing);
layout->StartRowWithPadding(
kFixed, kButtonsColumnId, kFixed,
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
show_ =
MdTextButton::CreateSecondaryUiButton(this, base::ASCIIToUTF16("Show"));
layout->AddView(show_);
Expand Down
2 changes: 2 additions & 0 deletions ui/views/layout/layout_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ int LayoutProvider::GetDistanceMetric(int metric) const {
return kDialogMinimumButtonWidth;
case DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN:
return kButtonHEdgeMarginNew;
case DISTANCE_UNRELATED_CONTROL_VERTICAL:
return kUnrelatedControlVerticalSpacing;
}
NOTREACHED();
return 0;
Expand Down
2 changes: 2 additions & 0 deletions ui/views/layout/layout_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ enum DistanceMetric {
// The spacing between a pair of related vertical controls, used for
// dialog layout.
DISTANCE_RELATED_CONTROL_VERTICAL,
// Vertical spacing between controls that are logically unrelated.
DISTANCE_UNRELATED_CONTROL_VERTICAL,

// Embedders must start DistanceMetric enum values from here.
VIEWS_DISTANCE_END
Expand Down

0 comments on commit 478f3b2

Please sign in to comment.