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

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: renames, don't const_cast, ditch InfoBarView::VerticalOffset. 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..71e322b0b180ccef9d25204545c7ed571d55a6aa 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() {
+ 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)->AnimatedTabHeight();
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) {
+ // Our |total_height| is the sum of the preferred heights of the InfoBars
+ // contained within us plus the |vertical_overlap|.
+ int vertical_overlap = 0;
+ int next_child_y = 0;
+
+ for (int i = 0; i < child_count(); ++i) {
+ View* child = GetChildViewAt(i);
+ gfx::Size ps = child->GetPreferredSize();
+ next_child_y -= static_cast<InfoBarView*>(child)->AnimatedTabHeight();
+ vertical_overlap = std::max(vertical_overlap, -next_child_y);
+ next_child_y += child->GetPreferredSize().height();
+ }
+
+ if (total_height)
+ *total_height = next_child_y + vertical_overlap;
+ return vertical_overlap;
+}
+
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