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

Unified Diff: chrome/browser/ui/views/toolbar_view.cc

Issue 10907038: alternate ntp: clip middle omnibox when resizing browser window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-implement fix Created 8 years, 3 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/toolbar_view.cc
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index 3df545aa5da95e3732462070ec3b71b0b2b1997c..30b8503579dd60c894ef8ad9b0622c3deb27f504 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -423,7 +423,24 @@ 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, but keep the original
+ // size of |location_bar_view_|. This lets |location_bar_container_| clip its
+ // child |location_bar_view_| 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.
+ if (intersect_rect.IsEmpty()) {
+ intersect_rect.set_x(0);
+ intersect_rect.set_y(0);
+ intersect_rect.set_size(gfx::Size());
+ }
+ location_bar_container_->SetBoundsForContainerAndView(intersect_rect,
+ location_container_bounds.size());
#endif
}
@@ -978,10 +995,11 @@ 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);
- location_bar_container_->SetBoundsRect(target_bounds);
+ location_bar_container_->SetBoundsForContainerAndView(target_bounds,
+ target_bounds.size());
}
}

Powered by Google App Engine
This is Rietveld 408576698