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

Side by Side Diff: ui/views/controls/menu/submenu_view.cc

Issue 2418523004: Makes Chrome's app menu have a vertical orientation. (Closed)
Patch Set: Moved clarifying comments to a previous line. Created 4 years, 2 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 | « ui/views/controls/menu/menu_scroll_view_container.cc ('k') | 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 (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/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 int menu_item_width = width - insets.width(); 175 int menu_item_width = width - insets.width();
176 for (int i = 0; i < child_count(); ++i) { 176 for (int i = 0; i < child_count(); ++i) {
177 const View* child = child_at(i); 177 const View* child = child_at(i);
178 height += child->visible() ? child->GetHeightForWidth(menu_item_width) : 0; 178 height += child->visible() ? child->GetHeightForWidth(menu_item_width) : 0;
179 } 179 }
180 180
181 return gfx::Size(width, height + insets.height()); 181 return gfx::Size(width, height + insets.height());
182 } 182 }
183 183
184 void SubmenuView::GetAccessibleState(ui::AXViewState* state) { 184 void SubmenuView::GetAccessibleState(ui::AXViewState* state) {
185 // Inherit most of the state from the parent menu item, except the role. 185 // Inherit most of the state from the parent menu item, except the role and
186 // the orientation.
186 if (GetMenuItem()) 187 if (GetMenuItem())
187 GetMenuItem()->GetAccessibleState(state); 188 GetMenuItem()->GetAccessibleState(state);
188 state->role = ui::AX_ROLE_MENU_LIST_POPUP; 189 state->role = ui::AX_ROLE_MENU_LIST_POPUP;
190 // Menus in Chrome are always traversed in a vertical direction.
191 state->AddStateFlag(ui::AX_STATE_VERTICAL);
189 } 192 }
190 193
191 void SubmenuView::PaintChildren(const ui::PaintContext& context) { 194 void SubmenuView::PaintChildren(const ui::PaintContext& context) {
192 View::PaintChildren(context); 195 View::PaintChildren(context);
193 196
194 bool paint_drop_indicator = false; 197 bool paint_drop_indicator = false;
195 if (drop_item_) { 198 if (drop_item_) {
196 switch (drop_position_) { 199 switch (drop_position_) {
197 case MenuDelegate::DROP_NONE: 200 case MenuDelegate::DROP_NONE:
198 case MenuDelegate::DROP_ON: 201 case MenuDelegate::DROP_ON:
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 y = std::max(y, 0); 512 y = std::max(y, 0);
510 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); 513 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height());
511 if (new_vis_bounds != vis_bounds) { 514 if (new_vis_bounds != vis_bounds) {
512 ScrollRectToVisible(new_vis_bounds); 515 ScrollRectToVisible(new_vis_bounds);
513 return true; 516 return true;
514 } 517 }
515 return false; 518 return false;
516 } 519 }
517 520
518 } // namespace views 521 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_scroll_view_container.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698