Chromium Code Reviews| Index: chrome/browser/ui/views/infobars/infobar_container.cc |
| diff --git a/chrome/browser/ui/views/infobars/infobar_container.cc b/chrome/browser/ui/views/infobars/infobar_container.cc |
| index ce1a9a55d12a9541df3c42ce52f300e2ed989512..6aa583f6894100a2d0b89c4aedea37e3ab673ca1 100644 |
| --- a/chrome/browser/ui/views/infobars/infobar_container.cc |
| +++ b/chrome/browser/ui/views/infobars/infobar_container.cc |
| @@ -33,6 +33,11 @@ InfoBarContainer::~InfoBarContainer() { |
| ChangeTabContents(NULL); |
| } |
| +int InfoBarContainer::VerticalOverlap() const { |
| + int temp_total_height; |
| + return GetVerticalOverlap(&temp_total_height); |
| +} |
| + |
| void InfoBarContainer::ChangeTabContents(TabContents* contents) { |
| registrar_.RemoveAll(); |
| @@ -80,32 +85,26 @@ void InfoBarContainer::RemoveInfoBar(InfoBarView* infobar) { |
| infobars_.erase(infobar); |
| } |
| -void InfoBarContainer::PaintInfoBarArrows(gfx::Canvas* canvas, |
| - View* outer_view, |
| - int arrow_center_x) { |
| - for (int i = 0; i < child_count(); ++i) { |
| - InfoBarView* infobar = static_cast<InfoBarView*>(GetChildViewAt(i)); |
| - infobar->PaintArrow(canvas, outer_view, arrow_center_x); |
| - } |
| -} |
| - |
| gfx::Size InfoBarContainer::GetPreferredSize() { |
| // We do not have a preferred width (we will expand to fit the available width |
| // of the delegate). Our preferred height is the sum of the preferred heights |
|
Peter Kasting
2011/03/08 23:21:31
Nit: I'd move this second sentence to the declarat
Sheridan Rawlins
2011/03/09 00:18:26
Done.
|
| - // of the InfoBars contained within us. |
| - int height = 0; |
| - for (int i = 0; i < child_count(); ++i) |
| - height += GetChildViewAt(i)->GetPreferredSize().height(); |
| - return gfx::Size(0, height); |
| + // of the InfoBars contained within us plus the vertical_overlap. |
| + int total_height; |
| + GetVerticalOverlap(&total_height); |
| + return gfx::Size(0, total_height); |
| } |
| void InfoBarContainer::Layout() { |
| - int top = 0; |
| + int total_height; |
| + int top = GetVerticalOverlap(&total_height); |
| + |
| for (int i = 0; i < child_count(); ++i) { |
| View* child = GetChildViewAt(i); |
| gfx::Size ps = child->GetPreferredSize(); |
| - child->SetBounds(0, top, width(), ps.height()); |
| - top += ps.height(); |
| + int overlapped_top = top - |
|
Peter Kasting
2011/03/08 23:21:31
Nit: Just use "top -=" here and "top +=" below, an
Sheridan Rawlins
2011/03/09 00:18:26
Done.
|
| + static_cast<InfoBarView*>(child)->VerticalOverlap(); |
| + child->SetBounds(0, overlapped_top, width(), ps.height()); |
| + top = overlapped_top + ps.height(); |
| } |
| } |
| @@ -140,6 +139,24 @@ void InfoBarContainer::Observe(NotificationType type, |
| } |
| } |
| +int InfoBarContainer::GetVerticalOverlap(int* total_height) const { |
| + int minimum_top = 0; |
|
Peter Kasting
2011/03/08 23:21:31
I do not find this algorithm at all comprehensible
Sheridan Rawlins
2011/03/09 00:18:26
I think we're going to have to agree to disagree h
|
| + int top = 0; |
| + |
| + for (int i = 0; i < child_count(); ++i) { |
| + View* child = const_cast<View*>(GetChildViewAt(i)); |
| + gfx::Size ps = child->GetPreferredSize(); |
| + int overlapped_top = top - |
| + static_cast<const InfoBarView*>(child)->VerticalOverlap(); |
| + minimum_top = std::min(minimum_top, overlapped_top); |
| + top = overlapped_top + ps.height(); |
| + } |
| + |
| + DCHECK(total_height); |
|
Peter Kasting
2011/03/08 23:21:31
Your API comments say this can be NULL. Either ma
Sheridan Rawlins
2011/03/09 00:18:26
Done.
|
| + *total_height = top - minimum_top; |
| + return -minimum_top; |
| +} |
| + |
| void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate, |
| bool use_animation) { |
| // Search for the infobar associated with |delegate|. We cannot search for |