Chromium Code Reviews| Index: ui/views/controls/menu/menu_item_view.cc |
| diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc |
| index 8755c024dd3b0c44c82bf110670a1ba7179c6315..7c891c1d3f6725cd99e9448e57ef5cb234a5770d 100644 |
| --- a/ui/views/controls/menu/menu_item_view.cc |
| +++ b/ui/views/controls/menu/menu_item_view.cc |
| @@ -410,6 +410,27 @@ gfx::Size MenuItemView::GetPreferredSize() const { |
| dimensions.height); |
| } |
| +int MenuItemView::GetHeightForWidth(int width) const { |
| + int height = 0; |
| + // If this is a container, check the child view. Otherwise, we use the |
| + // default menu height for everything but the icon. |
| + if (!IsContainer()) |
|
sky
2014/09/12 20:09:37
If !container, can't you just use GetPreferredSize
Devlin
2014/09/12 22:41:37
As long as we don't mind being inconsistent for ic
|
| + height = icon_view_ ? icon_view_->GetHeightForWidth(width) : 0; |
|
sky
2014/09/12 20:09:37
nit: spacing.
Devlin
2014/09/12 22:41:37
moot (line gone).
|
| + else |
| + height = child_at(0)->GetHeightForWidth(width); |
| + |
| + if (!icon_view_ && GetRootMenuItem()->has_icons()) |
| + height = std::max(height, GetMenuConfig().check_height); |
| + height += GetBottomMargin() + GetTopMargin(); |
| + |
| + // There's a chance our dimensions changed as a result of this. If so, |
| + // invalidate them so they get recalculated as needed. |
| + if (is_dimensions_valid() && height != GetDimensions().height) |
|
sky
2014/09/12 20:09:37
I don't understand the need for this. Can you elab
Devlin
2014/09/12 22:41:37
But the Dimensions are used in GetPreferredSize(),
sky
2014/09/15 15:29:54
Why does that matter though? GetPreferredSize and
Devlin
2014/09/15 15:39:20
In SubmenuView::GetPreferredSize(), we loop over t
|
| + invalidate_dimensions(); |
| + |
| + return height; |
| +} |
| + |
| const MenuItemView::MenuItemDimensions& MenuItemView::GetDimensions() const { |
| if (!is_dimensions_valid()) |
| dimensions_ = CalculateDimensions(); |