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

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: Update nits 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
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 Node* curNode = node(); 264 Node* curNode = node();
265 if (!parent->hasInheritedPresentationalRole() 265 if (!parent->hasInheritedPresentationalRole()
266 && !isPresentationRoleInTable(parent, curNode)) 266 && !isPresentationRoleInTable(parent, curNode))
267 return false; 267 return false;
268 268
269 // ARIA spec says that when a parent object is presentational and this objec t 269 // ARIA spec says that when a parent object is presentational and this objec t
270 // is a required owned element of that parent, then this object is also pres entational. 270 // is a required owned element of that parent, then this object is also pres entational.
271 return isRequiredOwnedElement(parent, roleValue(), curNode); 271 return isRequiredOwnedElement(parent, roleValue(), curNode);
272 } 272 }
273 273
274 bool AXNodeObject::isDescendantOfElementType(const HTMLQualifiedName& tagName) c onst
275 {
276 if (!node())
277 return false;
278
279 for (Element* parent = node()->parentElement(); parent; parent = parent->par entElement()) {
280 if (parent->hasTagName(tagName))
281 return true;
282 }
283 return false;
284 }
285
274 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil() 286 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil()
275 { 287 {
276 if (!node()) 288 if (!node())
277 return UnknownRole; 289 return UnknownRole;
278 if (node()->isLink()) 290 // HTMLAnchorElement sets isLink only when it has hrefAttr.
291 // We assume that it is also LinkRole if it has event listners even though i t doesn't have hrefAttr.
292 if (node()->isLink() || (isHTMLAnchorElement(*node()) && isClickable()))
279 return LinkRole; 293 return LinkRole;
294
280 if (isHTMLButtonElement(*node())) 295 if (isHTMLButtonElement(*node()))
281 return buttonRoleType(); 296 return buttonRoleType();
297
282 if (isHTMLDetailsElement(*node())) 298 if (isHTMLDetailsElement(*node()))
283 return DetailsRole; 299 return DetailsRole;
300
284 if (isHTMLSummaryElement(*node())) { 301 if (isHTMLSummaryElement(*node())) {
285 if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode())) 302 if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode()))
286 return DisclosureTriangleRole; 303 return DisclosureTriangleRole;
287 return UnknownRole; 304 return UnknownRole;
288 } 305 }
289 306
290 if (isHTMLInputElement(*node())) { 307 if (isHTMLInputElement(*node())) {
291 HTMLInputElement& input = toHTMLInputElement(*node()); 308 HTMLInputElement& input = toHTMLInputElement(*node());
292 const AtomicString& type = input.type(); 309 const AtomicString& type = input.type();
293 if (input.dataList()) 310 if (input.dataList())
(...skipping 27 matching lines...) Expand all
321 if (input.isTextButton()) 338 if (input.isTextButton())
322 return buttonRoleType(); 339 return buttonRoleType();
323 if (type == InputTypeNames::range) 340 if (type == InputTypeNames::range)
324 return SliderRole; 341 return SliderRole;
325 if (type == InputTypeNames::color) 342 if (type == InputTypeNames::color)
326 return ColorWellRole; 343 return ColorWellRole;
327 if (type == InputTypeNames::time) 344 if (type == InputTypeNames::time)
328 return TimeRole; 345 return TimeRole;
329 return TextFieldRole; 346 return TextFieldRole;
330 } 347 }
348
331 if (isHTMLSelectElement(*node())) { 349 if (isHTMLSelectElement(*node())) {
332 HTMLSelectElement& selectElement = toHTMLSelectElement(*node()); 350 HTMLSelectElement& selectElement = toHTMLSelectElement(*node());
333 return selectElement.multiple() ? ListBoxRole : PopUpButtonRole; 351 return selectElement.multiple() ? ListBoxRole : PopUpButtonRole;
334 } 352 }
353
335 if (isHTMLTextAreaElement(*node())) 354 if (isHTMLTextAreaElement(*node()))
336 return TextFieldRole; 355 return TextFieldRole;
356
337 if (headingLevel()) 357 if (headingLevel())
338 return HeadingRole; 358 return HeadingRole;
359
339 if (isHTMLDivElement(*node())) 360 if (isHTMLDivElement(*node()))
340 return DivRole; 361 return DivRole;
362
341 if (isHTMLMeterElement(*node())) 363 if (isHTMLMeterElement(*node()))
342 return MeterRole; 364 return MeterRole;
365
343 if (isHTMLOutputElement(*node())) 366 if (isHTMLOutputElement(*node()))
344 return StatusRole; 367 return StatusRole;
368
345 if (isHTMLParagraphElement(*node())) 369 if (isHTMLParagraphElement(*node()))
346 return ParagraphRole; 370 return ParagraphRole;
371
347 if (isHTMLLabelElement(*node())) 372 if (isHTMLLabelElement(*node()))
348 return LabelRole; 373 return LabelRole;
374
375 if (isHTMLLegendElement(*node()))
376 return LegendRole;
377
349 if (isHTMLRubyElement(*node())) 378 if (isHTMLRubyElement(*node()))
350 return RubyRole; 379 return RubyRole;
380
351 if (isHTMLDListElement(*node())) 381 if (isHTMLDListElement(*node()))
352 return DescriptionListRole; 382 return DescriptionListRole;
353 if (node()->isElementNode() && node()->hasTagName(blockquoteTag)) 383
384 if (node()->hasTagName(ddTag))
385 return DescriptionListDetailRole;
386
387 if (node()->hasTagName(dtTag))
388 return DescriptionListTermRole;
389
390 if (node()->nodeName() == "math")
391 return MathRole;
392
393 if (node()->hasTagName(rpTag) || node()->hasTagName(rtTag))
394 return AnnotationRole;
395
396 if (isHTMLFormElement(*node()))
397 return FormRole;
398
399 if (node()->hasTagName(articleTag))
400 return ArticleRole;
401
402 if (node()->hasTagName(mainTag))
403 return MainRole;
404
405 if (node()->hasTagName(navTag))
406 return NavigationRole;
407
408 if (node()->hasTagName(asideTag))
409 return ComplementaryRole;
410
411 if (node()->hasTagName(preTag))
412 return PreRole;
413
414 if (node()->hasTagName(sectionTag))
415 return RegionRole;
416
417 if (node()->hasTagName(addressTag))
418 return ContentInfoRole;
419
420 if (isHTMLDialogElement(*node()))
421 return DialogRole;
422
423 // The HTML element should not be exposed as an element. That's what the Lay outView element does.
424 if (isHTMLHtmlElement(*node()))
425 return IgnoredRole;
426
427 if (isHTMLIFrameElement(*node())) {
428 const AtomicString& ariaRole = getAttribute(roleAttr);
429 if (ariaRole == "none" || ariaRole == "presentation")
430 return IframePresentationalRole;
431 return IframeRole;
432 }
433
434 // There should only be one banner/contentInfo per page. If header/footer ar e being used within an article or section
435 // then it should not be exposed as whole page's banner/contentInfo
436 if (node()->hasTagName(headerTag) && !isDescendantOfElementType(articleTag) && !isDescendantOfElementType(sectionTag))
437 return BannerRole;
438
439 if (node()->hasTagName(footerTag) && !isDescendantOfElementType(articleTag) && !isDescendantOfElementType(sectionTag))
440 return FooterRole;
441
442 if (node()->hasTagName(blockquoteTag))
354 return BlockquoteRole; 443 return BlockquoteRole;
355 if (node()->isElementNode() && node()->hasTagName(captionTag)) 444
445 if (node()->hasTagName(captionTag))
356 return CaptionRole; 446 return CaptionRole;
357 if (node()->isElementNode() && node()->hasTagName(figcaptionTag)) 447
448 if (node()->hasTagName(figcaptionTag))
358 return FigcaptionRole; 449 return FigcaptionRole;
359 if (node()->isElementNode() && node()->hasTagName(figureTag)) 450
451 if (node()->hasTagName(figureTag))
360 return FigureRole; 452 return FigureRole;
361 if (isHTMLAnchorElement(*node()) && isClickable()) 453
362 return LinkRole;
363 if (isHTMLIFrameElement(*node()))
364 return IframeRole;
365 if (isEmbeddedObject()) 454 if (isEmbeddedObject())
366 return EmbeddedObjectRole; 455 return EmbeddedObjectRole;
456
367 return UnknownRole; 457 return UnknownRole;
368 } 458 }
369 459
370 AccessibilityRole AXNodeObject::determineAccessibilityRole() 460 AccessibilityRole AXNodeObject::determineAccessibilityRole()
371 { 461 {
372 if (!node()) 462 if (!node())
373 return UnknownRole; 463 return UnknownRole;
374 464
375 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) 465 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole)
376 return m_ariaRole; 466 return m_ariaRole;
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 float range = maxValueForRange() - minValueForRange(); 2172 float range = maxValueForRange() - minValueForRange();
2083 float value = valueForRange(); 2173 float value = valueForRange();
2084 2174
2085 value += range * (percentChange / 100); 2175 value += range * (percentChange / 100);
2086 setValue(String::number(value)); 2176 setValue(String::number(value));
2087 2177
2088 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged) ; 2178 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged) ;
2089 } 2179 }
2090 2180
2091 } // namespace blink 2181 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698