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

Unified Diff: chrome/browser/ui/views/infobars/infobar_container.cc

Issue 6609047: [linux_views][Win] spoof proof redesign infobar extension with tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit fixes. Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
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..5af1dfc491c38a04847d2a8277454a50f6c811be 100644
--- a/chrome/browser/ui/views/infobars/infobar_container.cc
+++ b/chrome/browser/ui/views/infobars/infobar_container.cc
@@ -33,6 +33,10 @@ InfoBarContainer::~InfoBarContainer() {
ChangeTabContents(NULL);
}
+int InfoBarContainer::VerticalOverlap() const {
+ return GetVerticalOverlap(NULL);
+}
+
void InfoBarContainer::ChangeTabContents(TabContents* contents) {
registrar_.RemoveAll();
@@ -80,30 +84,21 @@ 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
- // 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 delegate).
+ int total_height;
+ GetVerticalOverlap(&total_height);
+ return gfx::Size(0, total_height);
}
void InfoBarContainer::Layout() {
- int top = 0;
+ int top = GetVerticalOverlap(NULL);
+
for (int i = 0; i < child_count(); ++i) {
View* child = GetChildViewAt(i);
gfx::Size ps = child->GetPreferredSize();
+ top -= static_cast<InfoBarView*>(child)->VerticalOverlap();
child->SetBounds(0, top, width(), ps.height());
top += ps.height();
}
@@ -140,6 +135,25 @@ void InfoBarContainer::Observe(NotificationType type,
}
}
+int InfoBarContainer::GetVerticalOverlap(int* total_height) const {
+ // Our |total_height| is the sum of the preferred heights of the InfoBars
+ // contained within us plus the vertical overlap.
+ int minimum_top = 0;
Peter Kasting 2011/03/09 00:41:45 Nit: I suggest renaming this |vertical_overlap| an
Sheridan Rawlins 2011/03/09 01:09:34 Done.
+ int top = 0;
Peter Kasting 2011/03/09 00:41:45 Nit: |top| is kind of vague, how about |next_child
Sheridan Rawlins 2011/03/09 01:09:34 Done.
+
+ for (int i = 0; i < child_count(); ++i) {
+ View* child = const_cast<View*>(GetChildViewAt(i));
Peter Kasting 2011/03/09 00:41:45 Nit: It is really a shame that GetPreferredSize()
Sheridan Rawlins 2011/03/09 01:09:34 Done.
+ gfx::Size ps = child->GetPreferredSize();
Peter Kasting 2011/03/09 00:41:45 Nit: Eliminate this, just roll into its use below
Sheridan Rawlins 2011/03/09 01:09:34 Done.
+ top -= static_cast<InfoBarView*>(child)->VerticalOverlap();
+ minimum_top = std::min(minimum_top, top);
+ top += ps.height();
+ }
+
+ if (total_height)
+ *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

Powered by Google App Engine
This is Rietveld 408576698