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

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

Issue 1016413002: Fix wrench menu spacing regression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wrench-menu
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/wrench_menu.h" 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 10
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 return entry.first->IsItemCheckedAt(entry.second); 987 return entry.first->IsItemCheckedAt(entry.second);
988 } 988 }
989 989
990 bool WrenchMenu::IsCommandEnabled(int command_id) const { 990 bool WrenchMenu::IsCommandEnabled(int command_id) const {
991 if (IsBookmarkCommand(command_id)) 991 if (IsBookmarkCommand(command_id))
992 return true; 992 return true;
993 993
994 if (command_id == 0) 994 if (command_id == 0)
995 return false; // The root item. 995 return false; // The root item.
996 996
997 if (command_id == IDC_MORE_TOOLS_MENU)
998 return true;
999
997 // The items representing the cut menu (cut/copy/paste), zoom menu 1000 // The items representing the cut menu (cut/copy/paste), zoom menu
998 // (increment/decrement/reset) and extension toolbar view are always enabled. 1001 // (increment/decrement/reset) and extension toolbar view are always enabled.
999 // The child views of these items enabled state updates appropriately. 1002 // The child views of these items enabled state updates appropriately.
1000 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU || 1003 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU ||
1001 command_id == IDC_MORE_TOOLS_MENU ||
1002 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) 1004 command_id == IDC_EXTENSIONS_OVERFLOW_MENU)
1003 return true; 1005 return true;
1004 1006
1005 const Entry& entry = command_id_to_entry_.find(command_id)->second; 1007 const Entry& entry = command_id_to_entry_.find(command_id)->second;
1006 return entry.first->IsEnabledAt(entry.second); 1008 return entry.first->IsEnabledAt(entry.second);
1007 } 1009 }
1008 1010
1009 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { 1011 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) {
1010 if (IsBookmarkCommand(command_id)) { 1012 if (IsBookmarkCommand(command_id)) {
1011 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenBookmark", 1013 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenBookmark",
1012 menu_opened_timer_.Elapsed()); 1014 menu_opened_timer_.Elapsed());
1013 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", 1015 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction",
1014 MENU_ACTION_BOOKMARK_OPEN, LIMIT_MENU_ACTION); 1016 MENU_ACTION_BOOKMARK_OPEN, LIMIT_MENU_ACTION);
1015 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags); 1017 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags);
1016 return; 1018 return;
1017 } 1019 }
1018 1020
1019 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU || 1021 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU ||
1020 command_id == IDC_MORE_TOOLS_MENU ||
1021 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { 1022 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) {
1022 // These items are represented by child views. If ExecuteCommand is invoked 1023 // These items are represented by child views. If ExecuteCommand is invoked
1023 // it means the user clicked on the area around the buttons and we should 1024 // it means the user clicked on the area around the buttons and we should
1024 // not do anyting. 1025 // not do anyting.
1025 return; 1026 return;
1026 } 1027 }
1027 1028
1028 const Entry& entry = command_id_to_entry_.find(command_id)->second; 1029 const Entry& entry = command_id_to_entry_.find(command_id)->second;
1029 return entry.first->ActivatedAt(entry.second, mouse_event_flags); 1030 return entry.first->ActivatedAt(entry.second, mouse_event_flags);
1030 } 1031 }
1031 1032
1032 bool WrenchMenu::GetAccelerator(int command_id, 1033 bool WrenchMenu::GetAccelerator(int command_id,
1033 ui::Accelerator* accelerator) const { 1034 ui::Accelerator* accelerator) const {
1034 if (IsBookmarkCommand(command_id)) 1035 if (IsBookmarkCommand(command_id))
1035 return false; 1036 return false;
1036 1037
1037 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU || 1038 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU ||
1038 command_id == IDC_MORE_TOOLS_MENU ||
1039 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { 1039 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) {
1040 // These have special child views; don't show the accelerator for them. 1040 // These have special child views; don't show the accelerator for them.
1041 return false; 1041 return false;
1042 } 1042 }
1043 1043
1044 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1044 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1045 const Entry& entry = ix->second; 1045 const Entry& entry = ix->second;
1046 ui::Accelerator menu_accelerator; 1046 ui::Accelerator menu_accelerator;
1047 if (!entry.first->GetAcceleratorAt(entry.second, &menu_accelerator)) 1047 if (!entry.first->GetAcceleratorAt(entry.second, &menu_accelerator))
1048 return false; 1048 return false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 void WrenchMenu::PopulateMenu(MenuItemView* parent, 1100 void WrenchMenu::PopulateMenu(MenuItemView* parent,
1101 MenuModel* model) { 1101 MenuModel* model) {
1102 for (int i = 0, max = model->GetItemCount(); i < max; ++i) { 1102 for (int i = 0, max = model->GetItemCount(); i < max; ++i) {
1103 // Add the menu item at the end. 1103 // Add the menu item at the end.
1104 int menu_index = parent->HasSubmenu() ? 1104 int menu_index = parent->HasSubmenu() ?
1105 parent->GetSubmenu()->child_count() : 0; 1105 parent->GetSubmenu()->child_count() : 0;
1106 MenuItemView* item = 1106 MenuItemView* item =
1107 AddMenuItem(parent, menu_index, model, i, model->GetTypeAt(i)); 1107 AddMenuItem(parent, menu_index, model, i, model->GetTypeAt(i));
1108 1108
1109 if (model->GetCommandIdAt(i) == IDC_EDIT_MENU || 1109 if (model->GetCommandIdAt(i) == IDC_EDIT_MENU ||
1110 model->GetCommandIdAt(i) == IDC_ZOOM_MENU || 1110 model->GetCommandIdAt(i) == IDC_ZOOM_MENU) {
1111 model->GetCommandIdAt(i) == IDC_MORE_TOOLS_MENU) {
1112 const MenuConfig& config = item->GetMenuConfig(); 1111 const MenuConfig& config = item->GetMenuConfig();
1113 int top_margin = config.item_top_margin + config.separator_height / 2; 1112 int top_margin = config.item_top_margin + config.separator_height / 2;
1114 int bottom_margin = 1113 int bottom_margin =
1115 config.item_bottom_margin + config.separator_height / 2; 1114 config.item_bottom_margin + config.separator_height / 2;
1116 1115
1117 // Chromeos adds extra vertical space for the menu buttons. 1116 // Chromeos adds extra vertical space for the menu buttons.
1118 #if defined(OS_CHROMEOS) 1117 #if defined(OS_CHROMEOS)
1119 top_margin += 4; 1118 top_margin += 4;
1120 bottom_margin += 5; 1119 bottom_margin += 5;
1121 #endif 1120 #endif
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 0, 1260 0,
1262 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1261 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1263 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1262 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1264 } 1263 }
1265 1264
1266 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { 1265 int WrenchMenu::ModelIndexFromCommandId(int command_id) const {
1267 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1266 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1268 DCHECK(ix != command_id_to_entry_.end()); 1267 DCHECK(ix != command_id_to_entry_.end());
1269 return ix->second.second; 1268 return ix->second.second;
1270 } 1269 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698