| 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, but keep the original |
| 429 // size of |location_bar_view_|. This lets |location_bar_container_| clip its |
| 430 // child |location_bar_view_| without resizing it. |
| 431 // Note that parent of |location_bar_container_| i.e. BrowserView can't clip |
| 432 // its children, else it loses the 3D shadows. |
| 433 gfx::Rect parent_rect = location_bar_container_->parent()->GetLocalBounds(); |
| 434 gfx::Rect intersect_rect = parent_rect.Intersect(location_container_bounds); |
| 435 // If the two bounds don't intersect, set bounds of |location_bar_container_| |
| 436 // to 0. |
| 437 if (intersect_rect.IsEmpty()) { |
| 438 intersect_rect.set_x(0); |
| 439 intersect_rect.set_y(0); |
| 440 intersect_rect.set_size(gfx::Size()); |
| 441 } |
| 442 location_bar_container_->SetBoundsForContainerAndView(intersect_rect, |
| 443 location_container_bounds.size()); |
| 427 #endif | 444 #endif |
| 428 } | 445 } |
| 429 | 446 |
| 430 //////////////////////////////////////////////////////////////////////////////// | 447 //////////////////////////////////////////////////////////////////////////////// |
| 431 // ToolbarView, AccessiblePaneView overrides: | 448 // ToolbarView, AccessiblePaneView overrides: |
| 432 | 449 |
| 433 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 450 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
| 434 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 451 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
| 435 return false; | 452 return false; |
| 436 | 453 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 } | 988 } |
| 972 | 989 |
| 973 void ToolbarView::SetLocationBarContainerBounds( | 990 void ToolbarView::SetLocationBarContainerBounds( |
| 974 const gfx::Rect& bounds) { | 991 const gfx::Rect& bounds) { |
| 975 if (location_bar_container_->IsAnimating()) | 992 if (location_bar_container_->IsAnimating()) |
| 976 return; | 993 return; |
| 977 | 994 |
| 978 // LocationBarContainer is not a child of the ToolbarView. | 995 // LocationBarContainer is not a child of the ToolbarView. |
| 979 gfx::Point origin(bounds.origin()); | 996 gfx::Point origin(bounds.origin()); |
| 980 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), | 997 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), |
| 981 &origin); | 998 &origin); |
| 982 gfx::Rect target_bounds(origin, bounds.size()); | 999 gfx::Rect target_bounds(origin, bounds.size()); |
| 983 if (location_bar_container_->GetTargetBounds() != target_bounds) { | 1000 if (location_bar_container_->GetTargetBounds() != target_bounds) { |
| 984 location_bar_container_->SetInToolbar(true); | 1001 location_bar_container_->SetInToolbar(true); |
| 985 location_bar_container_->SetBoundsRect(target_bounds); | 1002 location_bar_container_->SetBoundsForContainerAndView(target_bounds, |
| 1003 target_bounds.size()); |
| 986 } | 1004 } |
| 987 } | 1005 } |
| OLD | NEW |