| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 home_->SetBounds(next_element_x, child_y, | 597 home_->SetBounds(next_element_x, child_y, |
| 598 home_->GetPreferredSize().width(), child_height); | 598 home_->GetPreferredSize().width(), child_height); |
| 599 } else { | 599 } else { |
| 600 home_->SetVisible(false); | 600 home_->SetVisible(false); |
| 601 home_->SetBounds(next_element_x, child_y, 0, child_height); | 601 home_->SetBounds(next_element_x, child_y, 0, child_height); |
| 602 } | 602 } |
| 603 next_element_x = home_->bounds().right() + | 603 next_element_x = home_->bounds().right() + |
| 604 theme_provider->GetDisplayProperty( | 604 theme_provider->GetDisplayProperty( |
| 605 ThemeProperties::PROPERTY_TOOLBAR_VIEW_STANDARD_SPACING); | 605 ThemeProperties::PROPERTY_TOOLBAR_VIEW_STANDARD_SPACING); |
| 606 | 606 |
| 607 int browser_actions_width = browser_actions_->GetPreferredSize().width(); | 607 int browser_actions_desired_width = |
| 608 browser_actions_->GetPreferredSize().width(); |
| 608 int app_menu_width = app_menu_->GetPreferredSize().width(); | 609 int app_menu_width = app_menu_->GetPreferredSize().width(); |
| 609 const int right_edge_spacing = theme_provider->GetDisplayProperty( | 610 const int right_edge_spacing = theme_provider->GetDisplayProperty( |
| 610 ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING); | 611 ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING); |
| 611 const int location_bar_right_padding = theme_provider->GetDisplayProperty( | 612 const int location_bar_right_padding = theme_provider->GetDisplayProperty( |
| 612 ThemeProperties::PROPERTY_TOOLBAR_VIEW_LOCATION_BAR_RIGHT_PADDING); | 613 ThemeProperties::PROPERTY_TOOLBAR_VIEW_LOCATION_BAR_RIGHT_PADDING); |
| 614 |
| 615 // Don't allow the omnibox to shrink to the point of non-existence. |
| 616 int kMinimumLocationBarWidth = 100; |
| 613 int available_width = std::max( | 617 int available_width = std::max( |
| 614 0, width() - right_edge_spacing - app_menu_width - browser_actions_width - | 618 0, width() - right_edge_spacing - app_menu_width - |
| 615 (browser_actions_width > 0 ? element_padding : 0) - | 619 (browser_actions_desired_width > 0 ? element_padding : 0) - |
| 616 location_bar_right_padding - next_element_x); | 620 location_bar_right_padding - next_element_x - |
| 621 kMinimumLocationBarWidth); |
| 622 int browser_actions_width = |
| 623 std::min(available_width, browser_actions_desired_width); |
| 624 available_width -= browser_actions_width; |
| 625 int location_bar_width = kMinimumLocationBarWidth + available_width; |
| 617 | 626 |
| 618 int location_height = location_bar_->GetPreferredSize().height(); | 627 int location_height = location_bar_->GetPreferredSize().height(); |
| 619 int location_y = (height() - location_height + 1) / 2; | 628 int location_y = (height() - location_height + 1) / 2; |
| 620 location_bar_->SetBounds(next_element_x, location_y, | 629 location_bar_->SetBounds(next_element_x, location_y, |
| 621 std::max(available_width, 0), location_height); | 630 location_bar_width, location_height); |
| 622 next_element_x = location_bar_->bounds().right() + location_bar_right_padding; | 631 next_element_x = location_bar_->bounds().right() + location_bar_right_padding; |
| 623 | 632 |
| 624 browser_actions_->SetBounds( | 633 browser_actions_->SetBounds( |
| 625 next_element_x, child_y, browser_actions_width, child_height); | 634 next_element_x, child_y, browser_actions_width, child_height); |
| 626 next_element_x = browser_actions_->bounds().right(); | 635 next_element_x = browser_actions_->bounds().right(); |
| 627 if (browser_actions_width > 0) | 636 if (browser_actions_width > 0) |
| 628 next_element_x += element_padding; | 637 next_element_x += element_padding; |
| 629 | 638 |
| 630 // The browser actions need to do a layout explicitly, because when an | 639 // The browser actions need to do a layout explicitly, because when an |
| 631 // extension is loaded/unloaded/changed, BrowserActionContainer removes and | 640 // extension is loaded/unloaded/changed, BrowserActionContainer removes and |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 SchedulePaint(); | 849 SchedulePaint(); |
| 841 } | 850 } |
| 842 | 851 |
| 843 int ToolbarView::content_shadow_height() const { | 852 int ToolbarView::content_shadow_height() const { |
| 844 ui::ThemeProvider* theme_provider = GetThemeProvider(); | 853 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 845 return theme_provider->GetDisplayProperty( | 854 return theme_provider->GetDisplayProperty( |
| 846 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH | 855 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH |
| 847 ? ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH | 856 ? ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH |
| 848 : ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT); | 857 : ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT); |
| 849 } | 858 } |
| OLD | NEW |