Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "platform/text/PlatformLocale.h" | 42 #include "platform/text/PlatformLocale.h" |
| 43 #include "wtf/StdLibExtras.h" | 43 #include "wtf/StdLibExtras.h" |
| 44 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
| 45 | 45 |
| 46 using blink::WebLocalizedString; | 46 using blink::WebLocalizedString; |
| 47 | 47 |
| 48 namespace blink { | 48 namespace blink { |
| 49 | 49 |
| 50 using namespace HTMLNames; | 50 using namespace HTMLNames; |
| 51 | 51 |
| 52 namespace { | |
| 52 typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap; | 53 typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap; |
| 53 | 54 |
| 54 struct RoleEntry { | 55 struct RoleEntry { |
| 55 String ariaRole; | 56 String ariaRole; |
| 56 AccessibilityRole webcoreRole; | 57 AccessibilityRole webcoreRole; |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 static ARIARoleMap* createARIARoleMap() | 60 void fillRoles(Vector<RoleEntry>* rolesVector) |
| 60 { | 61 { |
| 61 const RoleEntry roles[] = { | 62 RoleEntry roles[] = { |
| 62 { "alert", AlertRole }, | 63 { "alert", AlertRole }, |
| 63 { "alertdialog", AlertDialogRole }, | 64 { "alertdialog", AlertDialogRole }, |
| 64 { "application", ApplicationRole }, | 65 { "application", ApplicationRole }, |
| 65 { "article", ArticleRole }, | 66 { "article", ArticleRole }, |
| 66 { "banner", BannerRole }, | 67 { "banner", BannerRole }, |
| 67 { "button", ButtonRole }, | 68 { "button", ButtonRole }, |
| 68 { "checkbox", CheckBoxRole }, | 69 { "checkbox", CheckBoxRole }, |
| 69 { "complementary", ComplementaryRole }, | 70 { "complementary", ComplementaryRole }, |
| 70 { "contentinfo", ContentInfoRole }, | 71 { "contentinfo", ContentInfoRole }, |
| 71 { "dialog", DialogRole }, | 72 { "dialog", DialogRole }, |
| 72 { "directory", DirectoryRole }, | 73 { "directory", DirectoryRole }, |
| 73 { "grid", GridRole }, | 74 { "grid", GridRole }, |
| 74 { "gridcell", CellRole }, | 75 { "gridcell", CellRole }, |
| 75 { "columnheader", ColumnHeaderRole }, | 76 { "columnheader", ColumnHeaderRole }, |
| 76 { "combobox", ComboBoxRole }, | 77 { "combobox", ComboBoxRole }, |
| 77 { "definition", DefinitionRole }, | 78 { "definition", DefinitionRole }, |
| 78 { "document", DocumentRole }, | 79 { "document", DocumentRole }, |
| 79 { "rowheader", RowHeaderRole }, | 80 { "rowheader", RowHeaderRole }, |
| 80 { "form", FormRole }, | 81 { "form", FormRole }, |
| 81 { "group", GroupRole }, | 82 { "group", GroupRole }, |
| 82 { "heading", HeadingRole }, | 83 { "heading", HeadingRole }, |
| 83 { "img", ImageRole }, | 84 { "img", ImageRole }, |
| 84 { "link", LinkRole }, | 85 { "link", LinkRole }, |
| 85 { "list", ListRole }, | 86 { "list", ListRole }, |
| 86 { "listitem", ListItemRole }, | 87 { "listitem", ListItemRole }, |
| 87 { "listbox", ListBoxRole }, | 88 { "listbox", ListBoxRole }, |
| 88 { "log", LogRole }, | 89 { "log", LogRole }, |
| 89 // "option" isn't here because it may map to different roles depending o n the parent element's role | 90 // "option" isn't here because it may map to different roles depending o n the parent element's role |
|
dmazzoni
2014/12/12 00:41:48
Maybe try to handle this role as a special case?
aboxhall
2014/12/13 01:38:36
This comment is actually a lie - option is present
| |
| 90 { "main", MainRole }, | 91 { "main", MainRole }, |
| 91 { "marquee", MarqueeRole }, | 92 { "marquee", MarqueeRole }, |
| 92 { "math", MathRole }, | 93 { "math", MathRole }, |
| 93 { "menu", MenuRole }, | 94 { "menu", MenuRole }, |
| 94 { "menubar", MenuBarRole }, | 95 { "menubar", MenuBarRole }, |
| 95 { "menuitem", MenuItemRole }, | 96 { "menuitem", MenuItemRole }, |
| 96 { "menuitemcheckbox", MenuItemCheckBoxRole }, | 97 { "menuitemcheckbox", MenuItemCheckBoxRole }, |
| 97 { "menuitemradio", MenuItemRadioRole }, | 98 { "menuitemradio", MenuItemRadioRole }, |
| 98 { "note", NoteRole }, | 99 { "note", NoteRole }, |
| 99 { "navigation", NavigationRole }, | 100 { "navigation", NavigationRole }, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 116 { "tabpanel", TabPanelRole }, | 117 { "tabpanel", TabPanelRole }, |
| 117 { "text", StaticTextRole }, | 118 { "text", StaticTextRole }, |
| 118 { "textbox", TextAreaRole }, | 119 { "textbox", TextAreaRole }, |
| 119 { "timer", TimerRole }, | 120 { "timer", TimerRole }, |
| 120 { "toolbar", ToolbarRole }, | 121 { "toolbar", ToolbarRole }, |
| 121 { "tooltip", UserInterfaceTooltipRole }, | 122 { "tooltip", UserInterfaceTooltipRole }, |
| 122 { "tree", TreeRole }, | 123 { "tree", TreeRole }, |
| 123 { "treegrid", TreeGridRole }, | 124 { "treegrid", TreeGridRole }, |
| 124 { "treeitem", TreeItemRole } | 125 { "treeitem", TreeItemRole } |
| 125 }; | 126 }; |
| 127 size_t numRoles = WTF_ARRAY_LENGTH(roles); | |
| 128 rolesVector->resize(numRoles); | |
| 129 for (size_t i = 0; i < numRoles; ++i) | |
| 130 rolesVector->at(i) = roles[i]; | |
| 131 } | |
| 132 | |
| 133 static ARIARoleMap* createARIARoleMap() | |
| 134 { | |
| 126 ARIARoleMap* roleMap = new ARIARoleMap; | 135 ARIARoleMap* roleMap = new ARIARoleMap; |
| 127 | 136 |
| 128 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i) | 137 Vector<RoleEntry> roles; |
| 138 fillRoles(&roles); | |
| 139 for (size_t i = 0; i < roles.size(); ++i) | |
| 129 roleMap->set(roles[i].ariaRole, roles[i].webcoreRole); | 140 roleMap->set(roles[i].ariaRole, roles[i].webcoreRole); |
| 130 return roleMap; | 141 return roleMap; |
| 131 } | 142 } |
| 132 | 143 |
| 144 static void fillRoleNameVector(Vector<AtomicString>* roleNameVector) | |
| 145 { | |
| 146 roleNameVector->resize(NumRoles); | |
| 147 for (int i = 0; i < NumRoles; i++) { | |
| 148 roleNameVector->at(i) = AtomicString(); | |
| 149 } | |
| 150 | |
| 151 Vector<RoleEntry> roles; | |
| 152 | |
| 153 fillRoles(&roles); | |
| 154 for (size_t i = 0; i < roles.size(); ++i) { | |
| 155 roleNameVector->insert(roles[i].webcoreRole, AtomicString(roles[i].ariaR ole)); | |
| 156 } | |
| 157 } | |
| 158 | |
| 159 } // namespace | |
| 160 | |
| 133 AXObject::AXObject(AXObjectCacheImpl* axObjectCache) | 161 AXObject::AXObject(AXObjectCacheImpl* axObjectCache) |
| 134 : m_id(0) | 162 : m_id(0) |
| 135 , m_haveChildren(false) | 163 , m_haveChildren(false) |
| 136 , m_role(UnknownRole) | 164 , m_role(UnknownRole) |
| 137 , m_lastKnownIsIgnoredValue(DefaultBehavior) | 165 , m_lastKnownIsIgnoredValue(DefaultBehavior) |
| 138 , m_detached(false) | 166 , m_detached(false) |
| 139 , m_parent(0) | 167 , m_parent(0) |
| 140 , m_lastModificationCount(-1) | 168 , m_lastModificationCount(-1) |
| 141 , m_cachedIsIgnored(false) | 169 , m_cachedIsIgnored(false) |
| 142 , m_cachedLiveRegionRoot(0) | 170 , m_cachedLiveRegionRoot(0) |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 if (ariaPressedIsPresent()) | 975 if (ariaPressedIsPresent()) |
| 948 return ToggleButtonRole; | 976 return ToggleButtonRole; |
| 949 if (ariaHasPopup()) | 977 if (ariaHasPopup()) |
| 950 return PopUpButtonRole; | 978 return PopUpButtonRole; |
| 951 // We don't contemplate RadioButtonRole, as it depends on the input | 979 // We don't contemplate RadioButtonRole, as it depends on the input |
| 952 // type. | 980 // type. |
| 953 | 981 |
| 954 return ButtonRole; | 982 return ButtonRole; |
| 955 } | 983 } |
| 956 | 984 |
| 985 const AtomicString& AXObject::roleName(const AccessibilityRole role) | |
| 986 { | |
| 987 static Vector<AtomicString> roleNameVector; | |
| 988 if (roleNameVector.size() == 0) | |
| 989 fillRoleNameVector(&roleNameVector); | |
| 990 | |
| 991 return roleNameVector[role]; | |
|
dmazzoni
2014/12/12 00:41:48
Add a check/assert that this is in-bounds
aboxhall
2014/12/13 01:38:36
Done.
| |
| 992 } | |
| 993 | |
| 957 } // namespace blink | 994 } // namespace blink |
| OLD | NEW |