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

Unified Diff: Source/modules/accessibility/AXObject.cpp

Issue 742353004: Implement computedRole and computedName (behind a flag) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update webexposed/element-instance-property-listing.html and add some SVG test cases Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/accessibility/AXObject.h ('k') | Source/modules/accessibility/AXObjectCacheImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/accessibility/AXObject.cpp
diff --git a/Source/modules/accessibility/AXObject.cpp b/Source/modules/accessibility/AXObject.cpp
index d4d99c2affaec06beb3b5ba635a6332c91b0ebb0..ad17c20560853f32c9bdf80c8068637092c48790 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;
};
+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 },
+ { "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
« no previous file with comments | « Source/modules/accessibility/AXObject.h ('k') | Source/modules/accessibility/AXObjectCacheImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698