| 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 "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, | 1639 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, |
| 1640 bool prefer_leading, | 1640 bool prefer_leading, |
| 1641 bool* is_leading) { | 1641 bool* is_leading) { |
| 1642 DCHECK(item); | 1642 DCHECK(item); |
| 1643 | 1643 |
| 1644 SubmenuView* submenu = item->GetSubmenu(); | 1644 SubmenuView* submenu = item->GetSubmenu(); |
| 1645 DCHECK(submenu); | 1645 DCHECK(submenu); |
| 1646 | 1646 |
| 1647 gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize(); | 1647 gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize(); |
| 1648 | 1648 |
| 1649 // For comboboxes, ensure the menu is at least as wide as the anchor. |
| 1650 if (is_combobox_) |
| 1651 pref.set_width(std::max(pref.width(), state_.initial_bounds.width())); |
| 1652 |
| 1649 // Don't let the menu go too wide. | 1653 // Don't let the menu go too wide. |
| 1650 pref.set_width(std::min(pref.width(), | 1654 pref.set_width(std::min(pref.width(), |
| 1651 item->GetDelegate()->GetMaxWidthForMenu(item))); | 1655 item->GetDelegate()->GetMaxWidthForMenu(item))); |
| 1652 if (!state_.monitor_bounds.IsEmpty()) | 1656 if (!state_.monitor_bounds.IsEmpty()) |
| 1653 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); | 1657 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); |
| 1654 | 1658 |
| 1655 // Assume we can honor prefer_leading. | 1659 // Assume we can honor prefer_leading. |
| 1656 *is_leading = prefer_leading; | 1660 *is_leading = prefer_leading; |
| 1657 | 1661 |
| 1658 int x, y; | 1662 int x, y; |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 } | 2370 } |
| 2367 } | 2371 } |
| 2368 | 2372 |
| 2369 gfx::Screen* MenuController::GetScreen() { | 2373 gfx::Screen* MenuController::GetScreen() { |
| 2370 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2374 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2371 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2375 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2372 : gfx::Screen::GetNativeScreen(); | 2376 : gfx::Screen::GetNativeScreen(); |
| 2373 } | 2377 } |
| 2374 | 2378 |
| 2375 } // namespace views | 2379 } // namespace views |
| OLD | NEW |