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 if (intersect_rect.IsEmpty()) { | |
|
dhollowa
2012/09/13 18:24:08
if (interset_rect.IsEmpty())
intersect_rect = gf
kuan
2012/09/13 19:10:29
Done. i shortened it even more in SetBoundsRect.
| |
| 437 intersect_rect.set_x(0); | |
| 438 intersect_rect.set_y(0); | |
| 439 intersect_rect.set_size(gfx::Size()); | |
| 440 } | |
| 441 location_bar_container_->SetBoundsRect(intersect_rect); | |
| 427 #endif | 442 #endif |
| 428 } | 443 } |
| 429 | 444 |
| 430 //////////////////////////////////////////////////////////////////////////////// | 445 //////////////////////////////////////////////////////////////////////////////// |
| 431 // ToolbarView, AccessiblePaneView overrides: | 446 // ToolbarView, AccessiblePaneView overrides: |
| 432 | 447 |
| 433 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 448 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
| 434 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 449 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
| 435 return false; | 450 return false; |
| 436 | 451 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 } | 986 } |
| 972 | 987 |
| 973 void ToolbarView::SetLocationBarContainerBounds( | 988 void ToolbarView::SetLocationBarContainerBounds( |
| 974 const gfx::Rect& bounds) { | 989 const gfx::Rect& bounds) { |
| 975 if (location_bar_container_->IsAnimating()) | 990 if (location_bar_container_->IsAnimating()) |
| 976 return; | 991 return; |
| 977 | 992 |
| 978 // LocationBarContainer is not a child of the ToolbarView. | 993 // LocationBarContainer is not a child of the ToolbarView. |
| 979 gfx::Point origin(bounds.origin()); | 994 gfx::Point origin(bounds.origin()); |
| 980 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), | 995 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), |
| 981 &origin); | 996 &origin); |
| 982 gfx::Rect target_bounds(origin, bounds.size()); | 997 gfx::Rect target_bounds(origin, bounds.size()); |
| 983 if (location_bar_container_->GetTargetBounds() != target_bounds) { | 998 if (location_bar_container_->GetTargetBounds() != target_bounds) { |
| 984 location_bar_container_->SetInToolbar(true); | 999 location_bar_container_->SetInToolbar(true); |
| 985 location_bar_container_->SetBoundsRect(target_bounds); | 1000 location_bar_container_->SetBoundsRect(target_bounds); |
| 986 } | 1001 } |
| 987 } | 1002 } |
| OLD | NEW |