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

Unified Diff: ui/views/controls/scroll_view.cc

Issue 2509783002: Don't reset scroll position of contents on every ScrollView layout. (Closed)
Patch Set: make test work with scrolling by layer (I think) --- i.e. fix mac Created 4 years, 1 month 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 | « ash/common/system/tray/tray_details_view.cc ('k') | ui/views/controls/scroll_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/scroll_view.cc
diff --git a/ui/views/controls/scroll_view.cc b/ui/views/controls/scroll_view.cc
index 8a0c2590e8d2eae11644a63eddd61455fc6c0fa6..cf212b7c8bd3c99d10b268ab234d9acf05508a54 100644
--- a/ui/views/controls/scroll_view.cc
+++ b/ui/views/controls/scroll_view.cc
@@ -283,7 +283,7 @@ gfx::Size ScrollView::GetPreferredSize() const {
if (!is_bounded())
return View::GetPreferredSize();
- gfx::Size size = contents()->GetPreferredSize();
+ gfx::Size size = contents_->GetPreferredSize();
size.SetToMax(gfx::Size(size.width(), min_height_));
size.SetToMin(gfx::Size(size.width(), max_height_));
gfx::Insets insets = GetInsets();
@@ -297,7 +297,7 @@ int ScrollView::GetHeightForWidth(int width) const {
gfx::Insets insets = GetInsets();
width = std::max(0, width - insets.width());
- int height = contents()->GetHeightForWidth(width) + insets.height();
+ int height = contents_->GetHeightForWidth(width) + insets.height();
return std::min(std::max(height, min_height_), max_height_);
}
@@ -308,13 +308,12 @@ void ScrollView::Layout() {
gfx::Rect available_rect = GetContentsBounds();
if (is_bounded()) {
int content_width = available_rect.width();
- int content_height = contents()->GetHeightForWidth(content_width);
+ int content_height = contents_->GetHeightForWidth(content_width);
if (content_height > height()) {
content_width = std::max(content_width - GetScrollBarWidth(), 0);
- content_height = contents()->GetHeightForWidth(content_width);
+ content_height = contents_->GetHeightForWidth(content_width);
}
- if (contents()->bounds().size() != gfx::Size(content_width, content_height))
- contents()->SetBounds(0, 0, content_width, content_height);
+ contents_->SetSize(gfx::Size(content_width, content_height));
}
// Most views will want to auto-fit the available space. Most of them want to
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | ui/views/controls/scroll_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698