Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar_view.cc |
| diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc |
| index 3df545aa5da95e3732462070ec3b71b0b2b1997c..14f85d270a025ffdd5751e9f8b4a96f77ff71b4f 100644 |
| --- a/chrome/browser/ui/views/toolbar_view.cc |
| +++ b/chrome/browser/ui/views/toolbar_view.cc |
| @@ -423,7 +423,18 @@ void ToolbarView::LayoutForSearch() { |
| location_bar_container_->SetInToolbar(false); |
| location_container_bounds.set_height( |
| location_bar_container_->GetPreferredSize().height()); |
| - location_bar_container_->SetBoundsRect(location_container_bounds); |
| + |
| + // If bounds of |location_bar_container_| is not contained within its |
| + // parent's, adjust the former's to within the latter's. This will clip its |
| + // child |location_bar_view_| within its bounds without resizing it. |
| + // Note that parent of |location_bar_container_| i.e. BrowserView can't clip |
| + // its children, else it loses the 3D shadows. |
| + gfx::Rect parent_rect = location_bar_container_->parent()->GetLocalBounds(); |
| + gfx::Rect intersect_rect = parent_rect.Intersect(location_container_bounds); |
| + // If the two bounds don't intersect, set bounds of |location_bar_container_| |
| + // to 0. |
| + location_bar_container_->SetBoundsRect( |
| + intersect_rect.IsEmpty() ? gfx::Rect() : intersect_rect); |
|
sky
2012/09/13 19:58:24
Why do you need the empty test? If empty, then isn
kuan
2012/09/13 20:13:28
Done. i thot Rect::Intersect may return negative
|
| #endif |
| } |
| @@ -978,7 +989,7 @@ void ToolbarView::SetLocationBarContainerBounds( |
| // LocationBarContainer is not a child of the ToolbarView. |
| gfx::Point origin(bounds.origin()); |
| views::View::ConvertPointToTarget(this, location_bar_container_->parent(), |
| - &origin); |
| + &origin); |
| gfx::Rect target_bounds(origin, bounds.size()); |
| if (location_bar_container_->GetTargetBounds() != target_bounds) { |
| location_bar_container_->SetInToolbar(true); |