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

Side by Side Diff: chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc

Issue 1477253002: Use a single views::MenuConfig instance for each platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add menu_config_android Created 5 years 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu.cc ('k') | ui/views/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extension_toolbar_menu_view.h" 5 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // views::ScrollView::GetPreferredSize() includes the contents' size, but 67 // views::ScrollView::GetPreferredSize() includes the contents' size, but
68 // not the scrollbar width. Add it in if necessary. 68 // not the scrollbar width. Add it in if necessary.
69 if (container_->GetPreferredSize().height() > max_height_) 69 if (container_->GetPreferredSize().height() > max_height_)
70 s.Enlarge(GetScrollBarWidth(), 0); 70 s.Enlarge(GetScrollBarWidth(), 0);
71 return s; 71 return s;
72 } 72 }
73 73
74 int ExtensionToolbarMenuView::GetHeightForWidth(int width) const { 74 int ExtensionToolbarMenuView::GetHeightForWidth(int width) const {
75 // The width passed in here includes the full width of the menu, so we need 75 // The width passed in here includes the full width of the menu, so we need
76 // to omit the necessary padding. 76 // to omit the necessary padding.
77 const views::MenuConfig& menu_config = 77 const views::MenuConfig& menu_config = views::MenuConfig::instance();
78 static_cast<const views::MenuItemView*>(parent())->GetMenuConfig();
79 int end_padding = menu_config.arrow_to_edge_padding - 78 int end_padding = menu_config.arrow_to_edge_padding -
80 container_->toolbar_actions_bar()->platform_settings().item_spacing; 79 container_->toolbar_actions_bar()->platform_settings().item_spacing;
81 width -= start_padding() + end_padding; 80 width -= start_padding() + end_padding;
82 81
83 return views::ScrollView::GetHeightForWidth(width); 82 return views::ScrollView::GetHeightForWidth(width);
84 } 83 }
85 84
86 void ExtensionToolbarMenuView::Layout() { 85 void ExtensionToolbarMenuView::Layout() {
87 SetPosition(gfx::Point(start_padding(), 0)); 86 SetPosition(gfx::Point(start_padding(), 0));
88 SizeToPreferredSize(); 87 SizeToPreferredSize();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 133 }
135 134
136 int ExtensionToolbarMenuView::start_padding() const { 135 int ExtensionToolbarMenuView::start_padding() const {
137 // We pad enough on the left so that the first icon starts at the same point 136 // We pad enough on the left so that the first icon starts at the same point
138 // as the labels. We subtract kItemSpacing because there needs to be padding 137 // as the labels. We subtract kItemSpacing because there needs to be padding
139 // so we can see the drop indicator. 138 // so we can see the drop indicator.
140 return views::MenuItemView::label_start() - 139 return views::MenuItemView::label_start() -
141 container_->toolbar_actions_bar()->platform_settings().item_spacing; 140 container_->toolbar_actions_bar()->platform_settings().item_spacing;
142 } 141 }
143 142
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu.cc ('k') | ui/views/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698