Chromium Code Reviews| Index: chrome/browser/ui/views/frame/contents_container.cc |
| diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc |
| index 508fff9f24523528d3bd8804b09a49af50f3bfda..3ad5317b13b3ffcbd54bcc4bab546fc51cdfd035 100644 |
| --- a/chrome/browser/ui/views/frame/contents_container.cc |
| +++ b/chrome/browser/ui/views/frame/contents_container.cc |
| @@ -18,7 +18,9 @@ ContentsContainer::ContentsContainer(views::WebView* active) |
| overlay_(NULL), |
| preview_(NULL), |
| preview_web_contents_(NULL), |
| - active_top_margin_(0) { |
| + active_top_margin_(0), |
| + preview_height_(100), |
| + preview_height_units_(INSTANT_SIZE_PERCENT) { |
| AddChildView(active_); |
| } |
| @@ -54,17 +56,21 @@ void ContentsContainer::MakePreviewContentsActiveContents() { |
| } |
| void ContentsContainer::SetPreview(views::WebView* preview, |
| - WebContents* preview_web_contents) { |
| - if (preview == preview_) |
| + WebContents* preview_web_contents, |
| + int height, |
| + InstantSizeUnits units) { |
| + if (preview == preview_ && |
| + height == preview_height_ && units == preview_height_units_) |
| return; |
| if (preview_) |
| RemoveChildView(preview_); |
| preview_ = preview; |
| preview_web_contents_ = preview_web_contents; |
| + preview_height_ = height; |
| + preview_height_units_ = units; |
| if (preview_) |
| AddChildView(preview_); |
| - |
| Layout(); |
|
sreeram
2012/09/19 19:59:52
This method needs to be slightly different:
void
Jered
2012/09/19 20:22:18
Done.
|
| } |
| @@ -95,13 +101,25 @@ void ContentsContainer::Layout() { |
| overlay_->SetBounds(0, 0, width(), height()); |
| if (preview_) |
| - preview_->SetBounds(0, 0, width(), height()); |
| + preview_->SetBounds(0, 0, width(), PreviewHeightInPixels()); |
| // Need to invoke views::View in case any views whose bounds didn't change |
| // still need a layout. |
| views::View::Layout(); |
| } |
| +int ContentsContainer::PreviewHeightInPixels() const { |
| + switch (preview_height_units_) { |
| + case INSTANT_SIZE_PERCENT: |
| + return std::min(height(), (height() * preview_height_) / 100); |
| + |
| + case INSTANT_SIZE_PIXELS: |
| + return std::min(height(), preview_height_); |
| + } |
| + NOTREACHED() << "unknown units: " << preview_height_units_; |
| + return 0; |
| +} |
| + |
| std::string ContentsContainer::GetClassName() const { |
| return kViewClassName; |
| } |