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

Unified Diff: ui/views/controls/table/table_view.cc

Issue 2389803006: Revert of Fix task manager's default sizing. (Closed)
Patch Set: Created 4 years, 2 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/controls/table/table_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 473b0b98c2d3b3fc3f8edff3d20c4ba2746c4072..9ce94cc4519a6e53df4bc9314ec1a624ff9832dd 100644
--- a/ui/views/controls/table/table_view.cc
+++ b/ui/views/controls/table/table_view.cc
@@ -137,7 +137,8 @@
select_on_remove_(true),
table_view_observer_(NULL),
row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2),
- last_layout_width_(0),
+ last_parent_width_(0),
+ layout_width_(0),
grouper_(NULL),
in_set_visible_column_width_(false) {
for (size_t i = 0; i < columns.size(); ++i) {
@@ -316,17 +317,30 @@
}
void TableView::Layout() {
- View* viewport = parent();
- if (viewport && last_layout_width_ != viewport->width() &&
- !in_set_visible_column_width_) {
- last_layout_width_ = viewport->width();
- UpdateVisibleColumnSizes();
+ // 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();
+ }
+ }
}
// We have to override Layout like this since we're contained in a ScrollView.
gfx::Size pref = GetPreferredSize();
- if (viewport)
- pref.SetToMax(viewport->size());
- SetSize(pref);
+ 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);
}
const char* TableView::GetClassName() const {
@@ -727,8 +741,7 @@
first_column_padding += kGroupingIndicatorSize + kTextHorizontalPadding;
std::vector<int> sizes = views::CalculateTableColumnSizes(
- last_layout_width_, first_column_padding, header_->font_list(),
- font_list_,
+ layout_width_, 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());
« no previous file with comments | « ui/views/controls/table/table_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698