diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 18:47:39 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 18:47:39 +0000 |
commit | 5bd5fec92bb88808f19b29f4e9180a516e2db8c6 (patch) | |
tree | 605c8b5e2860b8420606898ede5b51a9788e52e6 /views/controls | |
parent | 2573e7b3f741f4f113fa6389612fd9ddc57a73c9 (diff) | |
download | chromium_src-5bd5fec92bb88808f19b29f4e9180a516e2db8c6.zip chromium_src-5bd5fec92bb88808f19b29f4e9180a516e2db8c6.tar.gz chromium_src-5bd5fec92bb88808f19b29f4e9180a516e2db8c6.tar.bz2 |
Fix column sizing in views::TableView.
r51628 accidentally broke the sizing logic to only work if autosize_columns_ is
set. Use a flag to track whether an initial sizing operation is required.
BUG=48373
TEST=Open Content Settings Exceptions dialog, close, reopen. Columns in the table should be sized reasonably instead of being all clumped up at the left edge.
Review URL: http://codereview.chromium.org/2888001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/table/table_view.cc | 7 | ||||
-rw-r--r-- | views/controls/table/table_view.h | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index 7ab4c91..726283c 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -132,7 +132,7 @@ void TableView::DidChangeBounds(const gfx::Rect& previous, return; SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0); Layout(); - if (autosize_columns_ && width() > 0) + if ((autosize_columns_ || !column_sizes_valid_) && width() > 0) ResetColumnSizes(); UpdateContentOffset(); SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); @@ -864,6 +864,7 @@ HWND TableView::CreateNativeControl(HWND parent_container) { ::ImmAssociateContextEx(list_view_, NULL, 0); UpdateContentOffset(); + column_sizes_valid_ = false; return list_view_; } @@ -1314,6 +1315,8 @@ void TableView::ResetColumnSizes() { // Prefer the bounds of the window over our bounds, which may be // different. width = window_width; + // Only set the flag when we know the true width of the table. + column_sizes_valid_ = true; } } @@ -1553,7 +1556,7 @@ void TableView::VisibilityChanged(View* starting_from, bool is_visible) { // available to the columns only works when the native control is visible, so // update the column sizes in case we become visible. This depends on // VisibilityChanged() being called in post order on the view tree. - if (is_visible && autosize_columns_) + if (is_visible && (autosize_columns_ || !column_sizes_valid_) && width() > 0) ResetColumnSizes(); } diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h index 28d877e..9f427d4 100644 --- a/views/controls/table/table_view.h +++ b/views/controls/table/table_view.h @@ -443,6 +443,9 @@ class TableView : public NativeControl, // Whether or not the user can resize columns. bool resizable_columns_; + // Whether the column sizes have been determined. + bool column_sizes_valid_; + // NOTE: While this has the name View in it, it's not a view. Rather it's // a wrapper around the List-View window. HWND list_view_; |