Chromium Code Reviews| Index: chrome/browser/ui/infobar_container_delegate.cc |
| diff --git a/chrome/browser/ui/infobar_container_delegate.cc b/chrome/browser/ui/infobar_container_delegate.cc |
| index f033de3b678b2c77ae996819092053b412789ad2..ab3732c9b4e048c0e8d9f5643fc4298164a0adaf 100644 |
| --- a/chrome/browser/ui/infobar_container_delegate.cc |
| +++ b/chrome/browser/ui/infobar_container_delegate.cc |
| @@ -12,15 +12,39 @@ |
| #include "ui/views/window/non_client_view.h" |
| #endif |
| +namespace { |
| + |
| +int GetDefaultArrowTargetHeight() { |
| + return ui::MaterialDesignController::IsModeMaterial() |
| + ? InfoBarContainerDelegate::kDefaultArrowTargetHeightMd |
| + : InfoBarContainerDelegate::kDefaultArrowTargetHeight; |
| +} |
| + |
| +int GetDefaultArrowTargetHalfWidth() { |
| + return ui::MaterialDesignController::IsModeMaterial() |
| + ? InfoBarContainerDelegate::kDefaultArrowTargetHalfWidthMd |
| + : InfoBarContainerDelegate::kDefaultArrowTargetHalfWidth; |
| +} |
| + |
| +int GetSeparatorLineHeightForLayout() { |
| + return ui::MaterialDesignController::IsModeMaterial() |
| + ? 0 |
| + : InfoBarContainerDelegate::kSeparatorLineHeight; |
| +} |
| + |
| +} // namespace |
| + |
| // static |
| #if defined(OS_MACOSX) |
| const int InfoBarContainerDelegate::kSeparatorLineHeight = 1; |
| const int InfoBarContainerDelegate::kDefaultArrowTargetHeight = 11; |
| +const int InfoBarContainerDelegate::kDefaultArrowTargetHeightMd = 11; |
| #elif defined(TOOLKIT_VIEWS) |
| // Views comes second until the Mac browser is Views-based. |
| const int InfoBarContainerDelegate::kSeparatorLineHeight = |
| views::NonClientFrameView::kClientEdgeThickness; |
| const int InfoBarContainerDelegate::kDefaultArrowTargetHeight = 9; |
| +const int InfoBarContainerDelegate::kDefaultArrowTargetHeightMd = 11; |
| #endif |
| const int InfoBarContainerDelegate::kDefaultBarTargetHeight = 36; |
| @@ -28,6 +52,8 @@ const int InfoBarContainerDelegate::kDefaultBarTargetHeightMd = 40; |
| const int InfoBarContainerDelegate::kMaximumArrowTargetHeight = 24; |
| const int InfoBarContainerDelegate::kDefaultArrowTargetHalfWidth = |
| kDefaultArrowTargetHeight; |
| +const int InfoBarContainerDelegate::kDefaultArrowTargetHalfWidthMd = |
| + kDefaultArrowTargetHeightMd; |
| const int InfoBarContainerDelegate::kMaximumArrowTargetHalfWidth = 14; |
| InfoBarContainerDelegate::InfoBarContainerDelegate() |
| @@ -40,10 +66,7 @@ InfoBarContainerDelegate::~InfoBarContainerDelegate() { |
| void InfoBarContainerDelegate::SetMaxTopArrowHeight( |
| int height, |
| infobars::InfoBarContainer* container) { |
| - // Decrease the height by the arrow stroke thickness, which is the separator |
| - // line height, because the infobar arrow target heights are without-stroke. |
| - top_arrow_target_height_ = std::min( |
| - std::max(height - kSeparatorLineHeight, 0), kMaximumArrowTargetHeight); |
| + top_arrow_target_height_ = std::min(height, kMaximumArrowTargetHeight); |
|
Evan Stade
2016/04/02 02:21:42
I found a pre-existing bug where the arrow is unsh
Peter Kasting
2016/04/02 02:42:11
Make sure that the arrow tip gets drawn at the exa
Evan Stade
2016/04/04 17:24:29
yea, in the single infobar case, it copes up one p
|
| container->UpdateInfoBarArrowTargetHeights(); |
| } |
| @@ -55,13 +78,14 @@ int InfoBarContainerDelegate::ArrowTargetHeightForInfoBar( |
| if (index == 0) |
| return top_arrow_target_height_; |
| if ((index > 1) || animation.IsShowing()) |
| - return kDefaultArrowTargetHeight; |
| + return GetDefaultArrowTargetHeight(); |
| // When the first infobar is animating closed, we animate the second infobar's |
| // arrow target height from the default to the top target height. Note that |
| // the animation values here are going from 1.0 -> 0.0 as the top bar closes. |
| - return top_arrow_target_height_ + static_cast<int>( |
| - (kDefaultArrowTargetHeight - top_arrow_target_height_) * |
| - animation.GetCurrentValue()); |
| + return top_arrow_target_height_ + |
| + static_cast<int>( |
| + (GetDefaultArrowTargetHeight() - top_arrow_target_height_) * |
| + animation.GetCurrentValue()); |
| } |
| void InfoBarContainerDelegate::ComputeInfoBarElementSizes( |
| @@ -86,8 +110,9 @@ void InfoBarContainerDelegate::ComputeInfoBarElementSizes( |
| // When the infobar is not animating (i.e. fully open), we set the |
| // half-width to be proportionally the same distance between its default and |
| // maximum values as the height is between its. |
| - *arrow_half_width = kDefaultArrowTargetHalfWidth + |
| - ((kMaximumArrowTargetHalfWidth - kDefaultArrowTargetHalfWidth) * |
| + *arrow_half_width = |
| + GetDefaultArrowTargetHalfWidth() + |
| + ((kMaximumArrowTargetHalfWidth - GetDefaultArrowTargetHalfWidth()) * |
| ((*arrow_height - kDefaultArrowTargetHeight) / |
| (kMaximumArrowTargetHeight - kDefaultArrowTargetHeight))); |
| } |
| @@ -95,8 +120,8 @@ void InfoBarContainerDelegate::ComputeInfoBarElementSizes( |
| // this, changing the arrow height from 0 to kSeparatorLineHeight would |
| // produce no visible effect, because the stroke would paint atop the divider |
| // line above the infobar. |
| - if (*arrow_height) |
| - *arrow_height += kSeparatorLineHeight; |
| + if (*arrow_height && ui::MaterialDesignController::IsModeMaterial()) |
| + *arrow_height += GetSeparatorLineHeightForLayout(); |
| int target_height = bar_target_height != -1 |
| ? bar_target_height |