Chromium Code Reviews| Index: ui/views/controls/table/table_view.cc |
| diff --git a/ui/views/controls/table/table_view.cc b/ui/views/controls/table/table_view.cc |
| index 9ce94cc4519a6e53df4bc9314ec1a624ff9832dd..78c5393ad63829283b31babb465ed87c01968a0d 100644 |
| --- a/ui/views/controls/table/table_view.cc |
| +++ b/ui/views/controls/table/table_view.cc |
| @@ -137,8 +137,6 @@ TableView::TableView(ui::TableModel* model, |
| select_on_remove_(true), |
| table_view_observer_(NULL), |
| row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2), |
| - last_parent_width_(0), |
| - layout_width_(0), |
| grouper_(NULL), |
| in_set_visible_column_width_(false) { |
| for (size_t i = 0; i < columns.size(); ++i) { |
| @@ -317,30 +315,14 @@ int TableView::ViewToModel(int view_index) const { |
| } |
| void TableView::Layout() { |
| - // parent()->parent() is the scrollview. When its width changes we force |
| - // recalculating column sizes. |
| - View* scroll_view = parent() ? parent()->parent() : NULL; |
| - if (scroll_view) { |
| - const int scroll_view_width = scroll_view->GetContentsBounds().width(); |
| - if (scroll_view_width != last_parent_width_) { |
| - last_parent_width_ = scroll_view_width; |
| - if (!in_set_visible_column_width_) { |
| - // Layout to the parent (the Viewport), which differs from |
| - // |scroll_view_width| when scrollbars are present. |
| - layout_width_ = parent()->width(); |
| - UpdateVisibleColumnSizes(); |
| - } |
| - } |
| - } |
| + View* viewport = parent(); |
| + if (viewport && width() != viewport->width() && !in_set_visible_column_width_) |
|
sky
2016/09/16 21:28:58
I believe your change will result in forcing a cal
Evan Stade
2016/09/22 16:19:13
I guess that's right. We're already calling it eve
|
| + UpdateVisibleColumnSizes(); |
| // We have to override Layout like this since we're contained in a ScrollView. |
| gfx::Size pref = GetPreferredSize(); |
| - int width = pref.width(); |
| - int height = pref.height(); |
| - if (parent()) { |
| - width = std::max(parent()->width(), width); |
| - height = std::max(parent()->height(), height); |
| - } |
| - SetBounds(x(), y(), width, height); |
| + if (viewport) |
| + pref.SetToMax(viewport->size()); |
| + SetSize(pref); |
| } |
| const char* TableView::GetClassName() const { |
| @@ -741,7 +723,8 @@ void TableView::UpdateVisibleColumnSizes() { |
| first_column_padding += kGroupingIndicatorSize + kTextHorizontalPadding; |
| std::vector<int> sizes = views::CalculateTableColumnSizes( |
| - layout_width_, first_column_padding, header_->font_list(), font_list_, |
| + parent() ? parent()->width() : 0, first_column_padding, |
| + header_->font_list(), font_list_, |
| std::max(kTextHorizontalPadding, TableHeader::kHorizontalPadding) * 2, |
| TableHeader::kSortIndicatorWidth, columns, model_); |
| DCHECK_EQ(visible_columns_.size(), sizes.size()); |