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/submenu_view.h" | 5 #include "ui/views/controls/menu/submenu_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 height += dimensions.height; | 145 height += dimensions.height; |
146 } else { | 146 } else { |
147 gfx::Size child_pref_size = | 147 gfx::Size child_pref_size = |
148 child->visible() ? child->GetPreferredSize() : gfx::Size(); | 148 child->visible() ? child->GetPreferredSize() : gfx::Size(); |
149 max_complex_width = std::max(max_complex_width, child_pref_size.width()); | 149 max_complex_width = std::max(max_complex_width, child_pref_size.width()); |
150 height += child_pref_size.height(); | 150 height += child_pref_size.height(); |
151 } | 151 } |
152 } | 152 } |
153 if (max_accelerator_width_ > 0) { | 153 if (max_accelerator_width_ > 0) { |
154 max_accelerator_width_ += | 154 max_accelerator_width_ += |
155 MenuConfig::instance().label_to_accelerator_padding; | 155 GetMenuItem()->GetMenuConfig().label_to_accelerator_padding; |
156 } | 156 } |
157 gfx::Insets insets = GetInsets(); | 157 gfx::Insets insets = GetInsets(); |
158 return gfx::Size( | 158 return gfx::Size( |
159 std::max(max_complex_width, | 159 std::max(max_complex_width, |
160 std::max(max_simple_width + max_accelerator_width_ + | 160 std::max(max_simple_width + max_accelerator_width_ + |
161 insets.width(), | 161 insets.width(), |
162 minimum_preferred_width_ - 2 * insets.width())), | 162 minimum_preferred_width_ - 2 * insets.width())), |
163 height + insets.height()); | 163 height + insets.height()); |
164 } | 164 } |
165 | 165 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 int y = vis_bounds.y() - static_cast<int>(dy); | 446 int y = vis_bounds.y() - static_cast<int>(dy); |
447 // clamp y to [0, full_height - vis_height) | 447 // clamp y to [0, full_height - vis_height) |
448 y = std::max(y, 0); | 448 y = std::max(y, 0); |
449 y = std::min(y, full_bounds.height() - vis_bounds.height() - 1); | 449 y = std::min(y, full_bounds.height() - vis_bounds.height() - 1); |
450 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); | 450 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); |
451 if (new_vis_bounds != vis_bounds) | 451 if (new_vis_bounds != vis_bounds) |
452 ScrollRectToVisible(new_vis_bounds); | 452 ScrollRectToVisible(new_vis_bounds); |
453 } | 453 } |
454 | 454 |
455 } // namespace views | 455 } // namespace views |
OLD | NEW |