Chromium Code Reviews| Index: Source/modules/accessibility/AXObject.cpp |
| diff --git a/Source/modules/accessibility/AXObject.cpp b/Source/modules/accessibility/AXObject.cpp |
| index d4d99c2affaec06beb3b5ba635a6332c91b0ebb0..e329e155bc3f1387d510d9c0a34512d7b59b1a61 100644 |
| --- a/Source/modules/accessibility/AXObject.cpp |
| +++ b/Source/modules/accessibility/AXObject.cpp |
| @@ -49,80 +49,81 @@ namespace blink { |
| using namespace HTMLNames; |
| +namespace { |
| typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap; |
| struct RoleEntry { |
| - String ariaRole; |
| + const char* ariaRole; |
| AccessibilityRole webcoreRole; |
| }; |
| +RoleEntry roles[] = { |
|
adamk
2014/12/19 00:07:46
Hopefully final nit: this should probably be const
aboxhall
2014/12/19 00:20:38
Done.
|
| + { "alert", AlertRole }, |
| + { "alertdialog", AlertDialogRole }, |
| + { "application", ApplicationRole }, |
| + { "article", ArticleRole }, |
| + { "banner", BannerRole }, |
| + { "button", ButtonRole }, |
| + { "checkbox", CheckBoxRole }, |
| + { "complementary", ComplementaryRole }, |
| + { "contentinfo", ContentInfoRole }, |
| + { "dialog", DialogRole }, |
| + { "directory", DirectoryRole }, |
| + { "grid", GridRole }, |
| + { "gridcell", CellRole }, |
| + { "columnheader", ColumnHeaderRole }, |
| + { "combobox", ComboBoxRole }, |
| + { "definition", DefinitionRole }, |
| + { "document", DocumentRole }, |
| + { "rowheader", RowHeaderRole }, |
| + { "form", FormRole }, |
| + { "group", GroupRole }, |
| + { "heading", HeadingRole }, |
| + { "img", ImageRole }, |
| + { "link", LinkRole }, |
| + { "list", ListRole }, |
| + { "listitem", ListItemRole }, |
| + { "listbox", ListBoxRole }, |
| + { "log", LogRole }, |
| + { "main", MainRole }, |
| + { "marquee", MarqueeRole }, |
| + { "math", MathRole }, |
| + { "menu", MenuRole }, |
| + { "menubar", MenuBarRole }, |
| + { "menuitem", MenuItemRole }, |
| + { "menuitemcheckbox", MenuItemCheckBoxRole }, |
| + { "menuitemradio", MenuItemRadioRole }, |
| + { "note", NoteRole }, |
| + { "navigation", NavigationRole }, |
| + { "none", NoneRole }, |
| + { "option", ListBoxOptionRole }, |
| + { "presentation", PresentationalRole }, |
| + { "progressbar", ProgressIndicatorRole }, |
| + { "radio", RadioButtonRole }, |
| + { "radiogroup", RadioGroupRole }, |
| + { "region", RegionRole }, |
| + { "row", RowRole }, |
| + { "scrollbar", ScrollBarRole }, |
| + { "search", SearchRole }, |
| + { "separator", SplitterRole }, |
| + { "slider", SliderRole }, |
| + { "spinbutton", SpinButtonRole }, |
| + { "status", StatusRole }, |
| + { "tab", TabRole }, |
| + { "tablist", TabListRole }, |
| + { "tabpanel", TabPanelRole }, |
| + { "text", StaticTextRole }, |
| + { "textbox", TextAreaRole }, |
| + { "timer", TimerRole }, |
| + { "toolbar", ToolbarRole }, |
| + { "tooltip", UserInterfaceTooltipRole }, |
| + { "tree", TreeRole }, |
| + { "treegrid", TreeGridRole }, |
| + { "treeitem", TreeItemRole } |
| +}; |
| + |
| static ARIARoleMap* createARIARoleMap() |
| { |
| - const RoleEntry roles[] = { |
| - { "alert", AlertRole }, |
| - { "alertdialog", AlertDialogRole }, |
| - { "application", ApplicationRole }, |
| - { "article", ArticleRole }, |
| - { "banner", BannerRole }, |
| - { "button", ButtonRole }, |
| - { "checkbox", CheckBoxRole }, |
| - { "complementary", ComplementaryRole }, |
| - { "contentinfo", ContentInfoRole }, |
| - { "dialog", DialogRole }, |
| - { "directory", DirectoryRole }, |
| - { "grid", GridRole }, |
| - { "gridcell", CellRole }, |
| - { "columnheader", ColumnHeaderRole }, |
| - { "combobox", ComboBoxRole }, |
| - { "definition", DefinitionRole }, |
| - { "document", DocumentRole }, |
| - { "rowheader", RowHeaderRole }, |
| - { "form", FormRole }, |
| - { "group", GroupRole }, |
| - { "heading", HeadingRole }, |
| - { "img", ImageRole }, |
| - { "link", LinkRole }, |
| - { "list", ListRole }, |
| - { "listitem", ListItemRole }, |
| - { "listbox", ListBoxRole }, |
| - { "log", LogRole }, |
| - // "option" isn't here because it may map to different roles depending on the parent element's role |
| - { "main", MainRole }, |
| - { "marquee", MarqueeRole }, |
| - { "math", MathRole }, |
| - { "menu", MenuRole }, |
| - { "menubar", MenuBarRole }, |
| - { "menuitem", MenuItemRole }, |
| - { "menuitemcheckbox", MenuItemCheckBoxRole }, |
| - { "menuitemradio", MenuItemRadioRole }, |
| - { "note", NoteRole }, |
| - { "navigation", NavigationRole }, |
| - { "none", NoneRole }, |
| - { "option", ListBoxOptionRole }, |
| - { "presentation", PresentationalRole }, |
| - { "progressbar", ProgressIndicatorRole }, |
| - { "radio", RadioButtonRole }, |
| - { "radiogroup", RadioGroupRole }, |
| - { "region", RegionRole }, |
| - { "row", RowRole }, |
| - { "scrollbar", ScrollBarRole }, |
| - { "search", SearchRole }, |
| - { "separator", SplitterRole }, |
| - { "slider", SliderRole }, |
| - { "spinbutton", SpinButtonRole }, |
| - { "status", StatusRole }, |
| - { "tab", TabRole }, |
| - { "tablist", TabListRole }, |
| - { "tabpanel", TabPanelRole }, |
| - { "text", StaticTextRole }, |
| - { "textbox", TextAreaRole }, |
| - { "timer", TimerRole }, |
| - { "toolbar", ToolbarRole }, |
| - { "tooltip", UserInterfaceTooltipRole }, |
| - { "tree", TreeRole }, |
| - { "treegrid", TreeGridRole }, |
| - { "treeitem", TreeItemRole } |
| - }; |
| ARIARoleMap* roleMap = new ARIARoleMap; |
| for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i) |
| @@ -130,6 +131,20 @@ static ARIARoleMap* createARIARoleMap() |
| return roleMap; |
| } |
| +static Vector<AtomicString>* createRoleNameVector() |
| +{ |
| + Vector<AtomicString>* roleNameVector = new Vector<AtomicString>(NumRoles); |
| + for (int i = 0; i < NumRoles; i++) |
| + (*roleNameVector)[i] = nullAtom; |
| + |
| + for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i) |
| + (*roleNameVector)[roles[i].webcoreRole] = AtomicString(roles[i].ariaRole); |
| + |
| + return roleNameVector; |
| +} |
| + |
| +} // namespace |
| + |
| AXObject::AXObject(AXObjectCacheImpl* axObjectCache) |
| : m_id(0) |
| , m_haveChildren(false) |
| @@ -954,4 +969,11 @@ AccessibilityRole AXObject::buttonRoleType() const |
| return ButtonRole; |
| } |
| +const AtomicString& AXObject::roleName(AccessibilityRole role) |
| +{ |
| + static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); |
| + |
| + return roleNameVector->at(role); |
| +} |
| + |
| } // namespace blink |