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

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: Finished pulling out ScopedAXObjectCache etc. Many fprintfs remain. 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 { "treegrid", TreeGridRole }, 123 { "treegrid", TreeGridRole },
124 { "treeitem", TreeItemRole } 124 { "treeitem", TreeItemRole }
125 }; 125 };
126 ARIARoleMap* roleMap = new ARIARoleMap; 126 ARIARoleMap* roleMap = new ARIARoleMap;
127 127
128 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i) 128 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i)
129 roleMap->set(roles[i].ariaRole, roles[i].webcoreRole); 129 roleMap->set(roles[i].ariaRole, roles[i].webcoreRole);
130 return roleMap; 130 return roleMap;
131 } 131 }
132 132
133 AXObject::AXObject() 133 struct RoleNameEntry {
134 AccessibilityRole webcoreRole;
135 String roleName;
136 };
137
138 static Vector<AtomicString>* createRoleNameVector()
139 {
140 const RoleNameEntry roleNames[] = {
141 { NoRole, "none" },
dmazzoni 2014/12/09 00:49:51 Actually there is an ARIA role of "none" now, it m
aboxhall 2014/12/13 01:38:36 Good point, although I note it doesn't seem to wor
dmazzoni 2014/12/16 19:18:19 The spec here: http://www.w3.org/TR/wai-aria-1.1/#
aboxhall 2014/12/16 23:56:37 Ah - I didn't look at the 1.1 spec. As discussed
142 { AlertDialogRole, "alertDialog" },
143 { AlertRole, "alert" },
144 { AnnotationRole, "annotation" },
145 { ApplicationRole, "application" },
146 { ArticleRole, "article" },
147 { BannerRole, "banner" },
148 { BlockquoteRole, "blockquote" },
149 { BusyIndicatorRole, "busyIndicator" },
150 { ButtonRole, "button" },
151 { CanvasRole, "canvas" },
152 { CellRole, "cell" },
153 { CheckBoxRole, "checkBox" },
154 { ColorWellRole, "colorWell" },
155 { ColumnHeaderRole, "columnHeader" },
156 { ColumnRole, "column" },
157 { ComboBoxRole, "comboBox" },
158 { ComplementaryRole, "complementary" },
159 { ContentInfoRole, "contentInfo" },
160 { DateRole, "date" },
161 { DateTimeRole, "dateTime" },
162 { DefinitionRole, "definition" },
163 { DescriptionListDetailRole, "descriptionListDetail" },
164 { DescriptionListRole, "descriptionList" },
165 { DescriptionListTermRole, "descriptionListTerm" },
166 { DetailsRole, "details" },
167 { DialogRole, "dialog" },
168 { DirectoryRole, "directory" },
169 { DisclosureTriangleRole, "disclosureTriangle" },
170 { DivRole, "div" },
171 { DocumentRole, "document" },
172 { EmbeddedObjectRole, "embeddedObject" },
173 { FigcaptionRole, "figcaption" },
174 { FigureRole, "figure" },
175 { FooterRole, "footer" },
176 { FormRole, "form" },
177 { GridRole, "grid" },
178 { GroupRole, "group" },
179 { HeadingRole, "heading" },
180 { IframeRole, "iframe" },
181 { IgnoredRole, "ignored" },
182 { ImageMapLinkRole, "imageMapLink" },
183 { ImageMapRole, "imageMap" },
184 { ImageRole, "image" },
185 { InlineTextBoxRole, "inlineTextBox" },
186 { LabelRole, "label" },
187 { LegendRole, "legend" },
188 { LinkRole, "link" },
189 { ListBoxOptionRole, "listBoxOption" },
190 { ListBoxRole, "listBox" },
191 { ListItemRole, "listItem" },
192 { ListMarkerRole, "listMarker" },
193 { ListRole, "list" },
194 { LogRole, "log" },
195 { MainRole, "main" },
196 { MarqueeRole, "marquee" },
197 { MathElementRole, "mathElement" },
198 { MathRole, "math" },
199 { MenuBarRole, "menuBar" },
200 { MenuButtonRole, "menuButton" },
201 { MenuItemRole, "menuItem" },
202 { MenuItemCheckBoxRole, "menuItemCheckBox" },
203 { MenuItemRadioRole, "menuItemRadio" },
204 { MenuListOptionRole, "menuListOption" },
205 { MenuListPopupRole, "menuListPopup" },
206 { MenuRole, "menu" },
207 { MeterRole, "meter" },
208 { NavigationRole, "navigation" },
209 { NoneRole, "none" },
210 { NoteRole, "note" },
211 { OutlineRole, "outline" },
212 { ParagraphRole, "paragraph" },
213 { PopUpButtonRole, "popUpButton" },
214 { PreRole, "pre" },
215 { PresentationalRole, "presentational" },
216 { ProgressIndicatorRole, "progressIndicator" },
217 { RadioButtonRole, "radioButton" },
218 { RadioGroupRole, "radioGroup" },
219 { RegionRole, "region" },
220 { RootWebAreaRole, "rootWebArea" },
221 { RowHeaderRole, "rowHeader" },
222 { RowRole, "row" },
223 { RubyRole, "ruby" },
224 { RulerRole, "ruler" },
225 { SVGRootRole, "svgRoot" },
226 { ScrollAreaRole, "scrollArea" },
227 { ScrollBarRole, "scrollBar" },
228 { SeamlessWebAreaRole, "seamlessWebArea" },
229 { SearchRole, "search" },
230 { SliderRole, "slider" },
231 { SliderThumbRole, "sliderThumb" },
232 { SpinButtonPartRole, "spinButtonPart" },
233 { SpinButtonRole, "spinButton" },
234 { SplitterRole, "splitter" },
235 { StaticTextRole, "staticText" },
236 { StatusRole, "status" },
237 { TabGroupRole, "tabGroup" },
238 { TabListRole, "tabList" },
239 { TabPanelRole, "tabPanel" },
240 { TabRole, "tab" },
241 { TableHeaderContainerRole, "tableHeaderContainer" },
242 { TableRole, "table" },
243 { TextAreaRole, "textArea" },
244 { TextFieldRole, "textField" },
245 { TimeRole, "time" },
246 { TimerRole, "timer" },
247 { ToggleButtonRole, "toggleButton" },
248 { ToolbarRole, "toolbar" },
249 { TreeGridRole, "treeGrid" },
250 { TreeItemRole, "treeItem" },
251 { TreeRole, "tree" },
252 { UnknownRole, "unknown" },
253 { UserInterfaceTooltipRole, "userInterfaceTooltip" },
254 { WebAreaRole, "webArea" },
255 { WindowRole, "window" }
256 };
257 Vector<AtomicString>* roleNameVector = new Vector<AtomicString>(NumRoles);
258
259 for (size_t i = 0; i < WTF_ARRAY_LENGTH(roleNames); ++i) {
260 roleNameVector->insert(roleNames[i].webcoreRole,
261 AtomicString(roleNames[i].roleName));
262 }
263 return roleNameVector;
264 }
265
266 AXObject::AXObject(AXObjectCache* axObjectCache)
134 : m_id(0) 267 : m_id(0)
135 , m_haveChildren(false) 268 , m_haveChildren(false)
136 , m_role(UnknownRole) 269 , m_role(UnknownRole)
137 , m_lastKnownIsIgnoredValue(DefaultBehavior) 270 , m_lastKnownIsIgnoredValue(DefaultBehavior)
138 , m_detached(false) 271 , m_detached(false)
139 , m_parent(0) 272 , m_parent(0)
140 , m_lastModificationCount(-1) 273 , m_lastModificationCount(-1)
141 , m_cachedIsIgnored(false) 274 , m_cachedIsIgnored(false)
142 , m_cachedLiveRegionRoot(0) 275 , m_cachedLiveRegionRoot(0)
276 , m_axObjectCache(toAXObjectCacheImpl(axObjectCache))
143 { 277 {
144 } 278 }
145 279
146 AXObject::~AXObject() 280 AXObject::~AXObject()
147 { 281 {
148 ASSERT(isDetached()); 282 ASSERT(isDetached());
149 } 283 }
150 284
151 void AXObject::detach() 285 void AXObject::detach()
152 { 286 {
153 // Clear any children and call detachFromParent on them so that 287 // Clear any children and call detachFromParent on them so that
154 // no children are left with dangling pointers to their parent. 288 // no children are left with dangling pointers to their parent.
155 clearChildren(); 289 clearChildren();
156 290
157 m_detached = true; 291 m_detached = true;
158 } 292 }
159 293
160 bool AXObject::isDetached() const 294 bool AXObject::isDetached() const
161 { 295 {
162 return m_detached; 296 return m_detached;
163 } 297 }
164 298
165 AXObjectCacheImpl* AXObject::axObjectCache() const 299 AXObjectCacheImpl* AXObject::axObjectCache() const
166 { 300 {
167 Document* doc = document(); 301 return m_axObjectCache;
168 if (doc)
169 return toAXObjectCacheImpl(doc->axObjectCache());
170 return 0;
171 } 302 }
172 303
173 bool AXObject::isARIATextControl() const 304 bool AXObject::isARIATextControl() const
174 { 305 {
175 return ariaRoleAttribute() == TextAreaRole || ariaRoleAttribute() == TextFie ldRole; 306 return ariaRoleAttribute() == TextAreaRole || ariaRoleAttribute() == TextFie ldRole;
176 } 307 }
177 308
178 bool AXObject::isButton() const 309 bool AXObject::isButton() const
179 { 310 {
180 AccessibilityRole role = roleValue(); 311 AccessibilityRole role = roleValue();
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 if (ariaPressedIsPresent()) 1102 if (ariaPressedIsPresent())
972 return ToggleButtonRole; 1103 return ToggleButtonRole;
973 if (ariaHasPopup()) 1104 if (ariaHasPopup())
974 return PopUpButtonRole; 1105 return PopUpButtonRole;
975 // We don't contemplate RadioButtonRole, as it depends on the input 1106 // We don't contemplate RadioButtonRole, as it depends on the input
976 // type. 1107 // type.
977 1108
978 return ButtonRole; 1109 return ButtonRole;
979 } 1110 }
980 1111
1112 const AtomicString& AXObject::roleName(const AccessibilityRole role)
1113 {
1114 static const Vector<AtomicString>* roleNameVector = createRoleNameVector();
1115
1116 return roleNameVector->at(role);
1117 }
1118
981 } // namespace blink 1119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698