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

Side by Side Diff: Source/modules/accessibility/AXNodeObject.cpp

Issue 1012383002: Removes direct checking node on AXLayoutObject::determineAccessibilityRole. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add Test Cases Created 5 years, 8 months 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) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return true; 176 return true;
177 177
178 // Ignore labels that are already referenced by a control's title UI element . 178 // Ignore labels that are already referenced by a control's title UI element .
179 AXObject* controlObject = correspondingControlForLabelElement(); 179 AXObject* controlObject = correspondingControlForLabelElement();
180 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec t->isCheckboxOrRadio()) 180 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec t->isCheckboxOrRadio())
181 return true; 181 return true;
182 182
183 return m_role == UnknownRole; 183 return m_role == UnknownRole;
184 } 184 }
185 185
186 bool AXNodeObject::isDescendantOfElementType(const HTMLQualifiedName& tagName) c onst
187 {
188 if (!node())
189 return false;
190
191 for (Element* parent = node()->parentElement(); parent; parent = parent->par entElement()) {
192 if (parent->hasTagName(tagName))
193 return true;
194 }
195 return false;
196 }
197
186 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil() 198 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil()
187 { 199 {
188 if (!node()) 200 if (!node())
189 return UnknownRole; 201 return UnknownRole;
190 if (node()->isLink()) 202 // HTMLAnchorElement sets isLink only when it has hrefAttr.
203 // We assume that it is also LinkRole if it has event listners even though i t doesn't have hrefAttr.
204 if (node()->isLink() || (isHTMLAnchorElement(*node()) && isClickable()))
191 return LinkRole; 205 return LinkRole;
206
192 if (isHTMLButtonElement(*node())) 207 if (isHTMLButtonElement(*node()))
193 return buttonRoleType(); 208 return buttonRoleType();
209
194 if (isHTMLDetailsElement(*node())) 210 if (isHTMLDetailsElement(*node()))
195 return DetailsRole; 211 return DetailsRole;
212
196 if (isHTMLSummaryElement(*node())) { 213 if (isHTMLSummaryElement(*node())) {
197 if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode())) 214 if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode()))
198 return DisclosureTriangleRole; 215 return DisclosureTriangleRole;
199 return UnknownRole; 216 return UnknownRole;
200 } 217 }
201 218
202 if (isHTMLInputElement(*node())) { 219 if (isHTMLInputElement(*node())) {
203 HTMLInputElement& input = toHTMLInputElement(*node()); 220 HTMLInputElement& input = toHTMLInputElement(*node());
204 const AtomicString& type = input.type(); 221 const AtomicString& type = input.type();
205 if (input.dataList()) 222 if (input.dataList())
(...skipping 27 matching lines...) Expand all
233 if (input.isTextButton()) 250 if (input.isTextButton())
234 return buttonRoleType(); 251 return buttonRoleType();
235 if (type == InputTypeNames::range) 252 if (type == InputTypeNames::range)
236 return SliderRole; 253 return SliderRole;
237 if (type == InputTypeNames::color) 254 if (type == InputTypeNames::color)
238 return ColorWellRole; 255 return ColorWellRole;
239 if (type == InputTypeNames::time) 256 if (type == InputTypeNames::time)
240 return TimeRole; 257 return TimeRole;
241 return TextFieldRole; 258 return TextFieldRole;
242 } 259 }
260
243 if (isHTMLSelectElement(*node())) { 261 if (isHTMLSelectElement(*node())) {
244 HTMLSelectElement& selectElement = toHTMLSelectElement(*node()); 262 HTMLSelectElement& selectElement = toHTMLSelectElement(*node());
245 return selectElement.multiple() ? ListBoxRole : PopUpButtonRole; 263 return selectElement.multiple() ? ListBoxRole : PopUpButtonRole;
246 } 264 }
265
247 if (isHTMLTextAreaElement(*node())) 266 if (isHTMLTextAreaElement(*node()))
248 return TextAreaRole; 267 return TextAreaRole;
268
249 if (headingLevel()) 269 if (headingLevel())
250 return HeadingRole; 270 return HeadingRole;
271
251 if (isHTMLDivElement(*node())) 272 if (isHTMLDivElement(*node()))
252 return DivRole; 273 return DivRole;
274
253 if (isHTMLMeterElement(*node())) 275 if (isHTMLMeterElement(*node()))
254 return MeterRole; 276 return MeterRole;
277
255 if (isHTMLOutputElement(*node())) 278 if (isHTMLOutputElement(*node()))
256 return StatusRole; 279 return StatusRole;
280
257 if (isHTMLParagraphElement(*node())) 281 if (isHTMLParagraphElement(*node()))
258 return ParagraphRole; 282 return ParagraphRole;
283
259 if (isHTMLLabelElement(*node())) 284 if (isHTMLLabelElement(*node()))
260 return LabelRole; 285 return LabelRole;
286
287 if (isHTMLLegendElement(*node()))
288 return LegendRole;
289
261 if (isHTMLRubyElement(*node())) 290 if (isHTMLRubyElement(*node()))
262 return RubyRole; 291 return RubyRole;
292
263 if (isHTMLDListElement(*node())) 293 if (isHTMLDListElement(*node()))
264 return DescriptionListRole; 294 return DescriptionListRole;
265 if (node()->isElementNode() && node()->hasTagName(blockquoteTag)) 295
296 if (node()->hasTagName(ddTag))
297 return DescriptionListDetailRole;
298
299 if (node()->hasTagName(dtTag))
300 return DescriptionListTermRole;
301
302 if (node()->nodeName() == "math")
303 return MathRole;
304
305 if (node()->hasTagName(rpTag) || node()->hasTagName(rtTag))
306 return AnnotationRole;
307
308 if (isHTMLFormElement(*node()))
309 return FormRole;
310
311 if (node()->hasTagName(articleTag))
312 return ArticleRole;
313
314 if (node()->hasTagName(mainTag))
315 return MainRole;
316
317 if (node()->hasTagName(navTag))
318 return NavigationRole;
319
320 if (node()->hasTagName(asideTag))
321 return ComplementaryRole;
322
323 if (node()->hasTagName(preTag))
324 return PreRole;
325
326 if (node()->hasTagName(sectionTag))
327 return RegionRole;
328
329 if (node()->hasTagName(addressTag))
330 return ContentInfoRole;
331
332 if (isHTMLDialogElement(*node()))
333 return DialogRole;
334
335 // The HTML element should not be exposed as an element. That's what the Lay outView element does.
336 if (isHTMLHtmlElement(*node()))
337 return IgnoredRole;
338
339 if (isHTMLIFrameElement(*node())) {
340 const AtomicString& ariaRole = getAttribute(roleAttr);
341 if (ariaRole == "none" || ariaRole == "presentation")
342 return IframePresentationalRole;
343 return IframeRole;
344 }
345
346 // There should only be one banner/contentInfo per page. If header/footer ar e being used within an article or section
347 // then it should not be exposed as whole page's banner/contentInfo
348 if (node()->hasTagName(headerTag) && !isDescendantOfElementType(articleTag) && !isDescendantOfElementType(sectionTag))
349 return BannerRole;
350
351 if (node()->hasTagName(footerTag) && !isDescendantOfElementType(articleTag) && !isDescendantOfElementType(sectionTag))
352 return FooterRole;
353
354 if (node()->hasTagName(blockquoteTag))
266 return BlockquoteRole; 355 return BlockquoteRole;
267 if (node()->isElementNode() && node()->hasTagName(captionTag)) 356
357 if (node()->hasTagName(captionTag))
268 return CaptionRole; 358 return CaptionRole;
269 if (node()->isElementNode() && node()->hasTagName(figcaptionTag)) 359
360 if (node()->hasTagName(figcaptionTag))
270 return FigcaptionRole; 361 return FigcaptionRole;
271 if (node()->isElementNode() && node()->hasTagName(figureTag)) 362
363 if (node()->hasTagName(figureTag))
272 return FigureRole; 364 return FigureRole;
273 if (isHTMLAnchorElement(*node()) && isClickable()) 365
274 return LinkRole;
275 if (isHTMLIFrameElement(*node()))
276 return IframeRole;
277 if (isEmbeddedObject()) 366 if (isEmbeddedObject())
278 return EmbeddedObjectRole; 367 return EmbeddedObjectRole;
368
279 return UnknownRole; 369 return UnknownRole;
280 } 370 }
281 371
282 AccessibilityRole AXNodeObject::determineAccessibilityRole() 372 AccessibilityRole AXNodeObject::determineAccessibilityRole()
283 { 373 {
284 if (!node()) 374 if (!node())
285 return UnknownRole; 375 return UnknownRole;
286 376
287 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) 377 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole)
288 return m_ariaRole; 378 return m_ariaRole;
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 float range = maxValueForRange() - minValueForRange(); 2087 float range = maxValueForRange() - minValueForRange();
1998 float value = valueForRange(); 2088 float value = valueForRange();
1999 2089
2000 value += range * (percentChange / 100); 2090 value += range * (percentChange / 100);
2001 setValue(String::number(value)); 2091 setValue(String::number(value));
2002 2092
2003 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged, true); 2093 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged, true);
2004 } 2094 }
2005 2095
2006 } // namespace blink 2096 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698