Index: chrome/browser/ui/views/infobars/infobar_view.cc |
diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc |
index 1e2969499f4849003b531d0a3763fc9bda3c35f3..40f5a26ed6daad66e628091ea8d79b6102dcb65a 100644 |
--- a/chrome/browser/ui/views/infobars/infobar_view.cc |
+++ b/chrome/browser/ui/views/infobars/infobar_view.cc |
@@ -59,6 +59,8 @@ InfoBarView::InfoBarView(InfoBarDelegate* delegate) |
ALLOW_THIS_IN_INITIALIZER_LIST(animation_(new ui::SlideAnimation(this))), |
ALLOW_THIS_IN_INITIALIZER_LIST(delete_factory_(this)), |
target_height_(kDefaultTargetHeight), |
+ tab_height_(0), |
+ bar_height_(0), |
fill_path_(new SkPath), |
stroke_path_(new SkPath) { |
set_parent_owned(false); // InfoBar deletes itself at the appropriate time. |
@@ -281,11 +283,9 @@ void InfoBarView::PaintChildren(gfx::Canvas* canvas) { |
// |
// gfx::CanvasSkia* canvas_skia = canvas->AsCanvasSkia(); |
// canvas_skia->clipPath(*fill_path_); |
- int tab_height = AnimatedTabHeight(); |
- int bar_height = AnimatedBarHeight(); |
- DCHECK_EQ(tab_height + bar_height, height()) |
- << "Animation progressed between OnBoundsChanged & PaintChildren."; |
- canvas->ClipRectInt(0, tab_height, width(), bar_height); |
+ DCHECK_EQ(tab_height_ + bar_height_, height()) |
+ << "Bounds set in OnBoundsChanged doesn't match PaintChildren."; |
+ canvas->ClipRectInt(0, tab_height_, width(), bar_height_); |
views::View::PaintChildren(canvas); |
canvas->Restore(); |
@@ -301,6 +301,8 @@ void InfoBarView::ButtonPressed(views::Button* sender, |
} |
void InfoBarView::AnimationProgressed(const ui::Animation* animation) { |
+ InvalidateLayout(); |
+ |
if (container_) |
container_->OnInfoBarAnimated(false); |
} |
@@ -314,6 +316,17 @@ void InfoBarView::RemoveInfoBar() const { |
container_->RemoveDelegate(delegate()); |
} |
+void InfoBarView::SetTargetHeight(int height) { |
+ if (target_height_ != height) { |
+ target_height_ = height; |
+ |
+ InvalidateLayout(); |
+ |
+ if (container_) |
+ container_->OnInfoBarAnimated(!animation_->is_animating()); |
+ } |
+} |
+ |
int InfoBarView::StartX() const { |
// Ensure we don't return a value greater than EndX(), so children can safely |
// set something's width to "EndX() - StartX()" without risking that being |
@@ -358,17 +371,17 @@ gfx::Size InfoBarView::GetPreferredSize() { |
} |
void InfoBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
- int tab_height = AnimatedTabHeight(); |
- int bar_height = AnimatedBarHeight(); |
- int divider_y = tab_height - 1; |
- DCHECK_EQ(tab_height + bar_height, height()) |
+ tab_height_ = AnimatedTabHeight(); |
+ bar_height_ = AnimatedBarHeight(); |
+ int divider_y = tab_height_ - 1; |
+ DCHECK_EQ(tab_height_ + bar_height_, height()) |
<< "Animation progressed between Layout & OnBoundsChanged."; |
int mirrored_x = GetMirroredXWithWidthInView(0, kTabWidth); |
stroke_path_->rewind(); |
fill_path_->rewind(); |
- if (tab_height) { |
+ if (tab_height_) { |
stroke_path_->moveTo(SkIntToScalar(mirrored_x), |
SkIntToScalar(divider_y)); |
stroke_path_->rCubicTo( |
@@ -403,8 +416,8 @@ void InfoBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
// a fill at a very different place than we'd want. |
stroke_path_->offset(SK_ScalarHalf, SK_ScalarHalf); |
} |
- if (bar_height) { |
- fill_path_->addRect(0.0, SkIntToScalar(tab_height), |
+ if (bar_height_) { |
+ fill_path_->addRect(0.0, SkIntToScalar(tab_height_), |
SkIntToScalar(width()), SkIntToScalar(height())); |
} |
} |