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

Side by Side Diff: ui/views/controls/scroll_view.cc

Issue 2344703002: Fix task manager's default sizing. (Closed)
Patch Set: less work Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | ui/views/controls/table/table_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/scroll_view.h" 5 #include "ui/views/controls/scroll_view.h"
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 void ScrollView::SetVerticalScrollBar(ScrollBar* vert_sb) { 266 void ScrollView::SetVerticalScrollBar(ScrollBar* vert_sb) {
267 DCHECK(vert_sb); 267 DCHECK(vert_sb);
268 vert_sb->SetVisible(vert_sb_->visible()); 268 vert_sb->SetVisible(vert_sb_->visible());
269 delete vert_sb_; 269 delete vert_sb_;
270 vert_sb->set_controller(this); 270 vert_sb->set_controller(this);
271 vert_sb_ = vert_sb; 271 vert_sb_ = vert_sb;
272 } 272 }
273 273
274 gfx::Size ScrollView::GetPreferredSize() const { 274 gfx::Size ScrollView::GetPreferredSize() const {
275 if (!is_bounded())
276 return View::GetPreferredSize();
277
278 gfx::Size size = contents()->GetPreferredSize(); 275 gfx::Size size = contents()->GetPreferredSize();
279 size.SetToMax(gfx::Size(size.width(), min_height_)); 276 size.SetToMax(gfx::Size(size.width(), min_height_));
280 size.SetToMin(gfx::Size(size.width(), max_height_)); 277 size.SetToMin(gfx::Size(size.width(), max_height_));
281 gfx::Insets insets = GetInsets(); 278 gfx::Insets insets = GetInsets();
282 size.Enlarge(insets.width(), insets.height()); 279 size.Enlarge(insets.width(), insets.height());
280
281 // If not vertically bounded, there's no specific preferred height.
sky 2016/09/22 17:39:58 Is there a reason to do this? I would be inclined
Evan Stade 2016/09/22 22:42:47 If !is_bounded() then max_height_ will be 0, so si
282 if (!is_bounded())
283 size.set_height(0);
284
283 return size; 285 return size;
284 } 286 }
285 287
286 int ScrollView::GetHeightForWidth(int width) const { 288 int ScrollView::GetHeightForWidth(int width) const {
287 if (!is_bounded()) 289 if (!is_bounded())
288 return View::GetHeightForWidth(width); 290 return View::GetHeightForWidth(width);
289 291
290 gfx::Insets insets = GetInsets(); 292 gfx::Insets insets = GetInsets();
291 width = std::max(0, width - insets.width()); 293 width = std::max(0, width - insets.width());
292 int height = contents()->GetHeightForWidth(width) + insets.height(); 294 int height = contents()->GetHeightForWidth(width) + insets.height();
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 760
759 VariableRowHeightScrollHelper::RowInfo 761 VariableRowHeightScrollHelper::RowInfo
760 FixedRowHeightScrollHelper::GetRowInfo(int y) { 762 FixedRowHeightScrollHelper::GetRowInfo(int y) {
761 if (y < top_margin_) 763 if (y < top_margin_)
762 return RowInfo(0, top_margin_); 764 return RowInfo(0, top_margin_);
763 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 765 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
764 row_height_); 766 row_height_);
765 } 767 }
766 768
767 } // namespace views 769 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | ui/views/controls/table/table_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698