Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 | 416 |
| 417 gfx::Rect location_container_bounds = | 417 gfx::Rect location_container_bounds = |
| 418 browser_view->search_view_controller()->GetNTPOmniboxBounds( | 418 browser_view->search_view_controller()->GetNTPOmniboxBounds( |
| 419 location_bar_container_->parent()); | 419 location_bar_container_->parent()); |
| 420 if (location_container_bounds.width() == 0) | 420 if (location_container_bounds.width() == 0) |
| 421 return; | 421 return; |
| 422 | 422 |
| 423 location_bar_container_->SetInToolbar(false); | 423 location_bar_container_->SetInToolbar(false); |
| 424 location_container_bounds.set_height( | 424 location_container_bounds.set_height( |
| 425 location_bar_container_->GetPreferredSize().height()); | 425 location_bar_container_->GetPreferredSize().height()); |
| 426 location_bar_container_->SetBoundsRect(location_container_bounds); | 426 |
| 427 // If bounds of |location_bar_container_| is not contained within its | |
| 428 // parent's, adjust the former's to within the latter's. This will clip its | |
| 429 // child |location_bar_view_| within its bounds without resizing it. | |
| 430 // Note that parent of |location_bar_container_| i.e. BrowserView can't clip | |
| 431 // its children, else it loses the 3D shadows. | |
| 432 gfx::Rect parent_rect = location_bar_container_->parent()->GetLocalBounds(); | |
| 433 gfx::Rect intersect_rect = parent_rect.Intersect(location_container_bounds); | |
| 434 // If the two bounds don't intersect, set bounds of |location_bar_container_| | |
| 435 // to 0. | |
| 436 location_bar_container_->SetBoundsRect( | |
| 437 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
| |
| 427 #endif | 438 #endif |
| 428 } | 439 } |
| 429 | 440 |
| 430 //////////////////////////////////////////////////////////////////////////////// | 441 //////////////////////////////////////////////////////////////////////////////// |
| 431 // ToolbarView, AccessiblePaneView overrides: | 442 // ToolbarView, AccessiblePaneView overrides: |
| 432 | 443 |
| 433 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 444 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
| 434 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 445 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
| 435 return false; | 446 return false; |
| 436 | 447 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 } | 982 } |
| 972 | 983 |
| 973 void ToolbarView::SetLocationBarContainerBounds( | 984 void ToolbarView::SetLocationBarContainerBounds( |
| 974 const gfx::Rect& bounds) { | 985 const gfx::Rect& bounds) { |
| 975 if (location_bar_container_->IsAnimating()) | 986 if (location_bar_container_->IsAnimating()) |
| 976 return; | 987 return; |
| 977 | 988 |
| 978 // LocationBarContainer is not a child of the ToolbarView. | 989 // LocationBarContainer is not a child of the ToolbarView. |
| 979 gfx::Point origin(bounds.origin()); | 990 gfx::Point origin(bounds.origin()); |
| 980 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), | 991 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), |
| 981 &origin); | 992 &origin); |
| 982 gfx::Rect target_bounds(origin, bounds.size()); | 993 gfx::Rect target_bounds(origin, bounds.size()); |
| 983 if (location_bar_container_->GetTargetBounds() != target_bounds) { | 994 if (location_bar_container_->GetTargetBounds() != target_bounds) { |
| 984 location_bar_container_->SetInToolbar(true); | 995 location_bar_container_->SetInToolbar(true); |
| 985 location_bar_container_->SetBoundsRect(target_bounds); | 996 location_bar_container_->SetBoundsRect(target_bounds); |
| 986 } | 997 } |
| 987 } | 998 } |
| OLD | NEW |