Index: views/grid_layout.cc |
diff --git a/views/grid_layout.cc b/views/grid_layout.cc |
index b3f0625f2d4bc16fcfc43ba80c199f205034d8dd..5e685ac9f9b1e2f2376bd4b8052a2c09e2c7e562 100644 |
--- a/views/grid_layout.cc |
+++ b/views/grid_layout.cc |
@@ -844,22 +844,26 @@ void GridLayout::SizeRowsAndColumns(bool layout, int width, int height, |
if (rows_.empty()) |
return; |
- // Calculate the size of each of the columns. Some views preferred heights are |
- // derived from their width, as such we need to calculate the size of the |
- // columns first. |
+ // Calculate the preferred width of each of the columns. Some views' |
+ // preferred heights are derived from their width, as such we need to |
+ // calculate the size of the columns first. |
for (std::vector<ColumnSet*>::iterator i = column_sets_.begin(); |
i != column_sets_.end(); ++i) { |
(*i)->CalculateSize(); |
- if (layout || width > 0) { |
- // We're doing a layout, divy up any extra space. |
- (*i)->Resize(width - (*i)->LayoutWidth() - left_inset_ - right_inset_); |
- // And reset the x coordinates. |
- (*i)->ResetColumnXCoordinates(); |
- } |
pref->set_width(std::max(pref->width(), (*i)->LayoutWidth())); |
} |
pref->set_width(pref->width() + left_inset_ + right_inset_); |
+ // Go over the columns again and set them all to the size we settled for. |
+ width = width ? width : pref->width(); |
+ for (std::vector<ColumnSet*>::iterator i = column_sets_.begin(); |
+ i != column_sets_.end(); ++i) { |
+ // We're doing a layout, divy up any extra space. |
+ (*i)->Resize(width - (*i)->LayoutWidth() - left_inset_ - right_inset_); |
+ // And reset the x coordinates. |
+ (*i)->ResetColumnXCoordinates(); |
+ } |
+ |
// Reset the height of each row. |
LayoutElement::ResetSizes(&rows_); |
@@ -1063,4 +1067,3 @@ views::GridLayout* CreatePanelGridLayout(views::View* host) { |
kPanelVertMargin, kPanelHorizMargin); |
return layout; |
} |
- |