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

Unified Diff: ui/views/layout/grid_layout.cc

Issue 2859193004: Remove GridLayout::SetInsets in favor of an empty border on the host. (Closed)
Patch Set: missed a merge problem Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/layout/grid_layout.h ('k') | ui/views/layout/grid_layout_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/layout/grid_layout.cc
diff --git a/ui/views/layout/grid_layout.cc b/ui/views/layout/grid_layout.cc
index 9704ac5c73065c831c7baa52f86674a32574dacf..7a713dd502e5727e2a9b44e33e0b15f70454b954 100644
--- a/ui/views/layout/grid_layout.cc
+++ b/ui/views/layout/grid_layout.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
+#include "ui/views/border.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/view.h"
@@ -652,19 +653,12 @@ GridLayout::~GridLayout() {
// static
GridLayout* GridLayout::CreatePanel(View* host) {
GridLayout* layout = new GridLayout(host);
- layout->SetInsets(LayoutProvider::Get()->GetInsetsMetric(INSETS_PANEL));
+ host->SetBorder(
+ CreateEmptyBorder(LayoutProvider::Get()->GetInsetsMetric(INSETS_PANEL)));
host->SetLayoutManager(layout);
return layout;
}
-void GridLayout::SetInsets(int top, int left, int bottom, int right) {
- insets_.Set(top, left, bottom, right);
-}
-
-void GridLayout::SetInsets(const gfx::Insets& insets) {
- insets_ = insets;
-}
-
ColumnSet* GridLayout::AddColumnSet(int id) {
DCHECK(GetColumnSet(id) == nullptr);
column_sets_.push_back(base::WrapUnique(new ColumnSet(id)));
@@ -784,13 +778,14 @@ void GridLayout::Layout(View* host) {
ColumnSet* column_set = view_state->column_set;
View* view = view_state->view;
DCHECK(view);
- int x = column_set->columns_[view_state->start_col]->Location() +
- insets_.left();
+ const gfx::Insets& insets = host_->GetInsets();
+ int x =
+ column_set->columns_[view_state->start_col]->Location() + insets.left();
int width = column_set->GetColumnWidth(view_state->start_col,
view_state->col_span);
CalculateSize(view_state->pref_width, view_state->h_align,
&x, &width);
- int y = rows_[view_state->start_row]->Location() + insets_.top();
+ int y = rows_[view_state->start_row]->Location() + insets.top();
int height = LayoutElement::TotalSize(view_state->start_row,
view_state->row_span, &rows_);
if (view_state->v_align == BASELINE && view_state->baseline != -1) {
@@ -839,14 +834,15 @@ void GridLayout::SizeRowsAndColumns(bool layout, int width, int height,
column_set->CalculateSize();
pref->set_width(std::max(pref->width(), column_set->LayoutWidth()));
}
- pref->set_width(pref->width() + insets_.width());
+ const gfx::Insets& insets = host_->GetInsets();
+ pref->set_width(pref->width() + insets.width());
// Go over the columns again and set them all to the size we settled for.
width = width ? width : pref->width();
for (const auto& column_set : column_sets_) {
// We're doing a layout, divvy up any extra space.
- column_set->Resize(width - column_set->LayoutWidth() - insets_.left() -
- insets_.right());
+ column_set->Resize(width - column_set->LayoutWidth() - insets.left() -
+ insets.right());
// And reset the x coordinates.
column_set->ResetColumnXCoordinates();
}
@@ -914,7 +910,7 @@ void GridLayout::SizeRowsAndColumns(bool layout, int width, int height,
// We now know the preferred height, set it here.
pref->set_height(rows_.back()->Location() + rows_.back()->Size() +
- insets_.height());
+ insets.height());
if (layout && height != pref->height()) {
// We're doing a layout, and the height differs from the preferred height,
« no previous file with comments | « ui/views/layout/grid_layout.h ('k') | ui/views/layout/grid_layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698