Commit cc9948e8 authored by thestig's avatar thestig Committed by Commit bot

Revert of Fix task manager's default sizing. (patchset #6 id:100001 of...

Revert of Fix task manager's default sizing. (patchset #6 id:100001 of https://codereview.chromium.org/2344703002/ )

Reason for revert:
On Linux, the task manager window self expands and gets wider and wiser.

Original issue's description:
> Fix task manager's default sizing.
>
> Set default width based on contents rather than hardcoding a value (which happened to be too small once we adjusted outer padding for the dialog).
>
> BUG=614317
>
> Committed: https://crrev.com/6678470d3169979d811eec56e7cdea668ab751c1
> Cr-Commit-Position: refs/heads/master@{#422893}

TBR=sky@chromium.org,estade@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=614317

Review-Url: https://codereview.chromium.org/2389803006
Cr-Commit-Position: refs/heads/master@{#423023}
parent 017d4ec4
...@@ -152,16 +152,7 @@ void TaskManagerView::SetSortDescriptor(const TableSortDescriptor& descriptor) { ...@@ -152,16 +152,7 @@ void TaskManagerView::SetSortDescriptor(const TableSortDescriptor& descriptor) {
} }
gfx::Size TaskManagerView::GetPreferredSize() const { gfx::Size TaskManagerView::GetPreferredSize() const {
gfx::Size table_size = tab_table_parent_->GetPreferredSize(); return gfx::Size(460, 270);
// The task name column expands to use excess space but also defaults to
// to a very narrow width: just enough to fit "Task" in English, and not
// enough to fit most actual task names such as "Tab: My email inbox". Add
// some extra width here to make the task names more readable.
table_size.set_width(table_size.width() + 180);
table_size.set_height(270);
gfx::Insets border = GetInsets();
table_size.Enlarge(border.width(), border.height());
return table_size;
} }
bool TaskManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { bool TaskManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) {
......
...@@ -115,6 +115,9 @@ class TaskManagerView : public TableViewDelegate, ...@@ -115,6 +115,9 @@ class TaskManagerView : public TableViewDelegate,
std::unique_ptr<ui::SimpleMenuModel> menu_model_; std::unique_ptr<ui::SimpleMenuModel> menu_model_;
std::unique_ptr<views::MenuRunner> menu_runner_; std::unique_ptr<views::MenuRunner> menu_runner_;
// We need to own the text of the menu, the Windows API does not copy it.
base::string16 always_on_top_menu_text_;
views::TableView* tab_table_; views::TableView* tab_table_;
views::View* tab_table_parent_; views::View* tab_table_parent_;
......
...@@ -272,11 +272,12 @@ void ScrollView::SetVerticalScrollBar(ScrollBar* vert_sb) { ...@@ -272,11 +272,12 @@ void ScrollView::SetVerticalScrollBar(ScrollBar* vert_sb) {
} }
gfx::Size ScrollView::GetPreferredSize() const { gfx::Size ScrollView::GetPreferredSize() const {
if (!is_bounded())
return View::GetPreferredSize();
gfx::Size size = contents()->GetPreferredSize(); gfx::Size size = contents()->GetPreferredSize();
if (is_bounded()) { size.SetToMax(gfx::Size(size.width(), min_height_));
size.SetToMax(gfx::Size(size.width(), min_height_)); size.SetToMin(gfx::Size(size.width(), max_height_));
size.SetToMin(gfx::Size(size.width(), max_height_));
}
gfx::Insets insets = GetInsets(); gfx::Insets insets = GetInsets();
size.Enlarge(insets.width(), insets.height()); size.Enlarge(insets.width(), insets.height());
return size; return size;
......
...@@ -137,7 +137,8 @@ TableView::TableView(ui::TableModel* model, ...@@ -137,7 +137,8 @@ TableView::TableView(ui::TableModel* model,
select_on_remove_(true), select_on_remove_(true),
table_view_observer_(NULL), table_view_observer_(NULL),
row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2), row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2),
last_layout_width_(0), last_parent_width_(0),
layout_width_(0),
grouper_(NULL), grouper_(NULL),
in_set_visible_column_width_(false) { in_set_visible_column_width_(false) {
for (size_t i = 0; i < columns.size(); ++i) { for (size_t i = 0; i < columns.size(); ++i) {
...@@ -316,17 +317,30 @@ int TableView::ViewToModel(int view_index) const { ...@@ -316,17 +317,30 @@ int TableView::ViewToModel(int view_index) const {
} }
void TableView::Layout() { void TableView::Layout() {
View* viewport = parent(); // parent()->parent() is the scrollview. When its width changes we force
if (viewport && last_layout_width_ != viewport->width() && // recalculating column sizes.
!in_set_visible_column_width_) { View* scroll_view = parent() ? parent()->parent() : NULL;
last_layout_width_ = viewport->width(); if (scroll_view) {
UpdateVisibleColumnSizes(); 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. // We have to override Layout like this since we're contained in a ScrollView.
gfx::Size pref = GetPreferredSize(); gfx::Size pref = GetPreferredSize();
if (viewport) int width = pref.width();
pref.SetToMax(viewport->size()); int height = pref.height();
SetSize(pref); if (parent()) {
width = std::max(parent()->width(), width);
height = std::max(parent()->height(), height);
}
SetBounds(x(), y(), width, height);
} }
const char* TableView::GetClassName() const { const char* TableView::GetClassName() const {
...@@ -727,8 +741,7 @@ void TableView::UpdateVisibleColumnSizes() { ...@@ -727,8 +741,7 @@ void TableView::UpdateVisibleColumnSizes() {
first_column_padding += kGroupingIndicatorSize + kTextHorizontalPadding; first_column_padding += kGroupingIndicatorSize + kTextHorizontalPadding;
std::vector<int> sizes = views::CalculateTableColumnSizes( std::vector<int> sizes = views::CalculateTableColumnSizes(
last_layout_width_, first_column_padding, header_->font_list(), layout_width_, first_column_padding, header_->font_list(), font_list_,
font_list_,
std::max(kTextHorizontalPadding, TableHeader::kHorizontalPadding) * 2, std::max(kTextHorizontalPadding, TableHeader::kHorizontalPadding) * 2,
TableHeader::kSortIndicatorWidth, columns, model_); TableHeader::kSortIndicatorWidth, columns, model_);
DCHECK_EQ(visible_columns_.size(), sizes.size()); DCHECK_EQ(visible_columns_.size(), sizes.size());
......
...@@ -341,8 +341,12 @@ class VIEWS_EXPORT TableView ...@@ -341,8 +341,12 @@ class VIEWS_EXPORT TableView
int row_height_; int row_height_;
// The last width for which column sizes were calculated. // Width of the ScrollView last time Layout() was invoked. Used to determine
int last_layout_width_; // when we should invoke UpdateVisibleColumnSizes().
int last_parent_width_;
// The width we layout to. This may differ from |last_parent_width_|.
int layout_width_;
// Current sort. // Current sort.
SortDescriptors sort_descriptors_; SortDescriptors sort_descriptors_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment