diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-23 21:34:48 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-23 21:34:48 +0000 |
commit | d684905b131ab5ed8df3c236887ff336493f4c8f (patch) | |
tree | f557e408f9a60c458a4266ca90d916eb20c76ae7 /ui | |
parent | cc042ccd6e7bbc5f881e03ddeaef28b7792cd600 (diff) | |
download | chromium_src-d684905b131ab5ed8df3c236887ff336493f4c8f.zip chromium_src-d684905b131ab5ed8df3c236887ff336493f4c8f.tar.gz chromium_src-d684905b131ab5ed8df3c236887ff336493f4c8f.tar.bz2 |
Clean up Layout() of BoundedScrollView.
Review URL: https://chromiumcodereview.appspot.com/12582005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/message_center/views/message_center_bubble.cc | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/ui/message_center/views/message_center_bubble.cc b/ui/message_center/views/message_center_bubble.cc index a5c010d..cdf2e14 100644 --- a/ui/message_center/views/message_center_bubble.cc +++ b/ui/message_center/views/message_center_bubble.cc @@ -278,7 +278,6 @@ class BoundedScrollView : public views::ScrollView { // Overridden from views::View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; - virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); private: int min_height_; @@ -308,25 +307,15 @@ gfx::Size BoundedScrollView::GetPreferredSize() { } void BoundedScrollView::Layout() { - // Lay out the view as if it will have a scroll bar. - gfx::Rect content_bounds = gfx::Rect(contents()->GetPreferredSize()); - content_bounds.set_width(std::max(0, width() - GetScrollBarWidth())); - contents()->SetBoundsRect(content_bounds); - views::ScrollView::Layout(); - - // But use the scroll bar space if no scroll bar is needed. - if (!vertical_scroll_bar()->visible()) { - content_bounds = contents()->bounds(); - content_bounds.set_width(content_bounds.width() + GetScrollBarWidth()); - contents()->SetBoundsRect(content_bounds); + int content_width = 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); } -} + contents()->SetBounds(0, 0, content_width, content_height); -void BoundedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { - // Make sure any content resizing takes into account the scroll bar. - gfx::Rect content_bounds = gfx::Rect(contents()->GetPreferredSize()); - content_bounds.set_width(std::max(0, width() - GetScrollBarWidth())); - contents()->SetBoundsRect(content_bounds); + views::ScrollView::Layout(); } // MessageListView ///////////////////////////////////////////////////////////// |