Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: ui/views/controls/menu/menu_item_view.cc

Issue 553233002: Dynamically calculate the number of extension icons to show per row in overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't resize menu to accommodate Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698