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

Side by Side 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: Comments 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 unified diff | Download patch
OLDNEW
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
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 const char* ariaRole;
56 AccessibilityRole webcoreRole; 57 AccessibilityRole webcoreRole;
57 }; 58 };
58 59
60 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.
61 { "alert", AlertRole },
62 { "alertdialog", AlertDialogRole },
63 { "application", ApplicationRole },
64 { "article", ArticleRole },
65 { "banner", BannerRole },
66 { "button", ButtonRole },
67 { "checkbox", CheckBoxRole },
68 { "complementary", ComplementaryRole },
69 { "contentinfo", ContentInfoRole },
70 { "dialog", DialogRole },
71 { "directory", DirectoryRole },
72 { "grid", GridRole },
73 { "gridcell", CellRole },
74 { "columnheader", ColumnHeaderRole },
75 { "combobox", ComboBoxRole },
76 { "definition", DefinitionRole },
77 { "document", DocumentRole },
78 { "rowheader", RowHeaderRole },
79 { "form", FormRole },
80 { "group", GroupRole },
81 { "heading", HeadingRole },
82 { "img", ImageRole },
83 { "link", LinkRole },
84 { "list", ListRole },
85 { "listitem", ListItemRole },
86 { "listbox", ListBoxRole },
87 { "log", LogRole },
88 { "main", MainRole },
89 { "marquee", MarqueeRole },
90 { "math", MathRole },
91 { "menu", MenuRole },
92 { "menubar", MenuBarRole },
93 { "menuitem", MenuItemRole },
94 { "menuitemcheckbox", MenuItemCheckBoxRole },
95 { "menuitemradio", MenuItemRadioRole },
96 { "note", NoteRole },
97 { "navigation", NavigationRole },
98 { "none", NoneRole },
99 { "option", ListBoxOptionRole },
100 { "presentation", PresentationalRole },
101 { "progressbar", ProgressIndicatorRole },
102 { "radio", RadioButtonRole },
103 { "radiogroup", RadioGroupRole },
104 { "region", RegionRole },
105 { "row", RowRole },
106 { "scrollbar", ScrollBarRole },
107 { "search", SearchRole },
108 { "separator", SplitterRole },
109 { "slider", SliderRole },
110 { "spinbutton", SpinButtonRole },
111 { "status", StatusRole },
112 { "tab", TabRole },
113 { "tablist", TabListRole },
114 { "tabpanel", TabPanelRole },
115 { "text", StaticTextRole },
116 { "textbox", TextAreaRole },
117 { "timer", TimerRole },
118 { "toolbar", ToolbarRole },
119 { "tooltip", UserInterfaceTooltipRole },
120 { "tree", TreeRole },
121 { "treegrid", TreeGridRole },
122 { "treeitem", TreeItemRole }
123 };
124
59 static ARIARoleMap* createARIARoleMap() 125 static ARIARoleMap* createARIARoleMap()
60 { 126 {
61 const RoleEntry roles[] = {
62 { "alert", AlertRole },
63 { "alertdialog", AlertDialogRole },
64 { "application", ApplicationRole },
65 { "article", ArticleRole },
66 { "banner", BannerRole },
67 { "button", ButtonRole },
68 { "checkbox", CheckBoxRole },
69 { "complementary", ComplementaryRole },
70 { "contentinfo", ContentInfoRole },
71 { "dialog", DialogRole },
72 { "directory", DirectoryRole },
73 { "grid", GridRole },
74 { "gridcell", CellRole },
75 { "columnheader", ColumnHeaderRole },
76 { "combobox", ComboBoxRole },
77 { "definition", DefinitionRole },
78 { "document", DocumentRole },
79 { "rowheader", RowHeaderRole },
80 { "form", FormRole },
81 { "group", GroupRole },
82 { "heading", HeadingRole },
83 { "img", ImageRole },
84 { "link", LinkRole },
85 { "list", ListRole },
86 { "listitem", ListItemRole },
87 { "listbox", ListBoxRole },
88 { "log", LogRole },
89 // "option" isn't here because it may map to different roles depending o n the parent element's role
90 { "main", MainRole },
91 { "marquee", MarqueeRole },
92 { "math", MathRole },
93 { "menu", MenuRole },
94 { "menubar", MenuBarRole },
95 { "menuitem", MenuItemRole },
96 { "menuitemcheckbox", MenuItemCheckBoxRole },
97 { "menuitemradio", MenuItemRadioRole },
98 { "note", NoteRole },
99 { "navigation", NavigationRole },
100 { "none", NoneRole },
101 { "option", ListBoxOptionRole },
102 { "presentation", PresentationalRole },
103 { "progressbar", ProgressIndicatorRole },
104 { "radio", RadioButtonRole },
105 { "radiogroup", RadioGroupRole },
106 { "region", RegionRole },
107 { "row", RowRole },
108 { "scrollbar", ScrollBarRole },
109 { "search", SearchRole },
110 { "separator", SplitterRole },
111 { "slider", SliderRole },
112 { "spinbutton", SpinButtonRole },
113 { "status", StatusRole },
114 { "tab", TabRole },
115 { "tablist", TabListRole },
116 { "tabpanel", TabPanelRole },
117 { "text", StaticTextRole },
118 { "textbox", TextAreaRole },
119 { "timer", TimerRole },
120 { "toolbar", ToolbarRole },
121 { "tooltip", UserInterfaceTooltipRole },
122 { "tree", TreeRole },
123 { "treegrid", TreeGridRole },
124 { "treeitem", TreeItemRole }
125 };
126 ARIARoleMap* roleMap = new ARIARoleMap; 127 ARIARoleMap* roleMap = new ARIARoleMap;
127 128
128 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i) 129 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i)
129 roleMap->set(roles[i].ariaRole, roles[i].webcoreRole); 130 roleMap->set(roles[i].ariaRole, roles[i].webcoreRole);
130 return roleMap; 131 return roleMap;
131 } 132 }
132 133
134 static Vector<AtomicString>* createRoleNameVector()
135 {
136 Vector<AtomicString>* roleNameVector = new Vector<AtomicString>(NumRoles);
137 for (int i = 0; i < NumRoles; i++)
138 (*roleNameVector)[i] = nullAtom;
139
140 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i)
141 (*roleNameVector)[roles[i].webcoreRole] = AtomicString(roles[i].ariaRole );
142
143 return roleNameVector;
144 }
145
146 } // namespace
147
133 AXObject::AXObject(AXObjectCacheImpl* axObjectCache) 148 AXObject::AXObject(AXObjectCacheImpl* axObjectCache)
134 : m_id(0) 149 : m_id(0)
135 , m_haveChildren(false) 150 , m_haveChildren(false)
136 , m_role(UnknownRole) 151 , m_role(UnknownRole)
137 , m_lastKnownIsIgnoredValue(DefaultBehavior) 152 , m_lastKnownIsIgnoredValue(DefaultBehavior)
138 , m_detached(false) 153 , m_detached(false)
139 , m_parent(0) 154 , m_parent(0)
140 , m_lastModificationCount(-1) 155 , m_lastModificationCount(-1)
141 , m_cachedIsIgnored(false) 156 , m_cachedIsIgnored(false)
142 , m_cachedLiveRegionRoot(0) 157 , m_cachedLiveRegionRoot(0)
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 if (ariaPressedIsPresent()) 962 if (ariaPressedIsPresent())
948 return ToggleButtonRole; 963 return ToggleButtonRole;
949 if (ariaHasPopup()) 964 if (ariaHasPopup())
950 return PopUpButtonRole; 965 return PopUpButtonRole;
951 // We don't contemplate RadioButtonRole, as it depends on the input 966 // We don't contemplate RadioButtonRole, as it depends on the input
952 // type. 967 // type.
953 968
954 return ButtonRole; 969 return ButtonRole;
955 } 970 }
956 971
972 const AtomicString& AXObject::roleName(AccessibilityRole role)
973 {
974 static const Vector<AtomicString>* roleNameVector = createRoleNameVector();
975
976 return roleNameVector->at(role);
977 }
978
957 } // namespace blink 979 } // namespace blink
OLDNEW
« 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