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

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

Issue 2477463003: Replace ui::AXViewState with AXNodeData and AXActionData (Closed)
Patch Set: Fix test Created 4 years, 1 month 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
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/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "ui/accessibility/ax_view_state.h" 12 #include "ui/accessibility/ax_node_data.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/models/menu_model.h" 14 #include "ui/base/models/menu_model.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/color_utils.h" 16 #include "ui/gfx/color_utils.h"
17 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/vector2d.h" 18 #include "ui/gfx/geometry/vector2d.h"
19 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/text_utils.h" 20 #include "ui/gfx/text_utils.h"
21 #include "ui/native_theme/common_theme.h" 21 #include "ui/native_theme/common_theme.h"
22 #include "ui/resources/grit/ui_resources.h" 22 #include "ui/resources/grit/ui_resources.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 147
148 const MenuDelegate* delegate = GetDelegate(); 148 const MenuDelegate* delegate = GetDelegate();
149 CHECK(delegate); 149 CHECK(delegate);
150 gfx::Point location(p); 150 gfx::Point location(p);
151 ConvertPointToScreen(this, &location); 151 ConvertPointToScreen(this, &location);
152 *tooltip = delegate->GetTooltipText(command_, location); 152 *tooltip = delegate->GetTooltipText(command_, location);
153 return !tooltip->empty(); 153 return !tooltip->empty();
154 } 154 }
155 155
156 void MenuItemView::GetAccessibleState(ui::AXViewState* state) { 156 void MenuItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
157 state->role = ui::AX_ROLE_MENU_ITEM; 157 node_data->role = ui::AX_ROLE_MENU_ITEM;
158 158
159 base::string16 item_text; 159 base::string16 item_text;
160 if (IsContainer()) { 160 if (IsContainer()) {
161 // The first child is taking over, just use its accessible name instead of 161 // The first child is taking over, just use its accessible name instead of
162 // |title_|. 162 // |title_|.
163 View* child = child_at(0); 163 View* child = child_at(0);
164 ui::AXViewState state; 164 ui::AXNodeData node_data;
165 child->GetAccessibleState(&state); 165 child->GetAccessibleNodeData(&node_data);
166 item_text = state.name; 166 item_text = node_data.GetString16Attribute(ui::AX_ATTR_NAME);
167 } else { 167 } else {
168 item_text = title_; 168 item_text = title_;
169 } 169 }
170 state->name = GetAccessibleNameForMenuItem(item_text, GetMinorText()); 170 node_data->SetName(GetAccessibleNameForMenuItem(item_text, GetMinorText()));
171 171
172 switch (GetType()) { 172 switch (GetType()) {
173 case SUBMENU: 173 case SUBMENU:
174 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 174 node_data->AddStateFlag(ui::AX_STATE_HASPOPUP);
175 break; 175 break;
176 case CHECKBOX: 176 case CHECKBOX:
177 case RADIO: 177 case RADIO:
178 if (GetDelegate()->IsItemChecked(GetCommand())) 178 if (GetDelegate()->IsItemChecked(GetCommand()))
179 state->AddStateFlag(ui::AX_STATE_CHECKED); 179 node_data->AddStateFlag(ui::AX_STATE_CHECKED);
180 break; 180 break;
181 case NORMAL: 181 case NORMAL:
182 case SEPARATOR: 182 case SEPARATOR:
183 case EMPTY: 183 case EMPTY:
184 // No additional accessibility states currently for these menu states. 184 // No additional accessibility states currently for these menu states.
185 break; 185 break;
186 } 186 }
187 } 187 }
188 188
189 // static 189 // static
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 } else { 1078 } else {
1079 const Type& type = menu_item->GetType(); 1079 const Type& type = menu_item->GetType();
1080 if (type == CHECKBOX || type == RADIO) 1080 if (type == CHECKBOX || type == RADIO)
1081 return true; 1081 return true;
1082 } 1082 }
1083 } 1083 }
1084 return false; 1084 return false;
1085 } 1085 }
1086 1086
1087 } // namespace views 1087 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_item_view.h ('k') | ui/views/controls/menu/menu_scroll_view_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698