| 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(intersect_rect); |
| 427 #endif | 437 #endif |
| 428 } | 438 } |
| 429 | 439 |
| 430 //////////////////////////////////////////////////////////////////////////////// | 440 //////////////////////////////////////////////////////////////////////////////// |
| 431 // ToolbarView, AccessiblePaneView overrides: | 441 // ToolbarView, AccessiblePaneView overrides: |
| 432 | 442 |
| 433 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 443 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
| 434 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 444 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
| 435 return false; | 445 return false; |
| 436 | 446 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 } | 981 } |
| 972 | 982 |
| 973 void ToolbarView::SetLocationBarContainerBounds( | 983 void ToolbarView::SetLocationBarContainerBounds( |
| 974 const gfx::Rect& bounds) { | 984 const gfx::Rect& bounds) { |
| 975 if (location_bar_container_->IsAnimating()) | 985 if (location_bar_container_->IsAnimating()) |
| 976 return; | 986 return; |
| 977 | 987 |
| 978 // LocationBarContainer is not a child of the ToolbarView. | 988 // LocationBarContainer is not a child of the ToolbarView. |
| 979 gfx::Point origin(bounds.origin()); | 989 gfx::Point origin(bounds.origin()); |
| 980 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), | 990 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), |
| 981 &origin); | 991 &origin); |
| 982 gfx::Rect target_bounds(origin, bounds.size()); | 992 gfx::Rect target_bounds(origin, bounds.size()); |
| 983 if (location_bar_container_->GetTargetBounds() != target_bounds) { | 993 if (location_bar_container_->GetTargetBounds() != target_bounds) { |
| 984 location_bar_container_->SetInToolbar(true); | 994 location_bar_container_->SetInToolbar(true); |
| 985 location_bar_container_->SetBoundsRect(target_bounds); | 995 location_bar_container_->SetBoundsRect(target_bounds); |
| 986 } | 996 } |
| 987 } | 997 } |
| OLD | NEW |