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

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

Issue 2649953004: Updated descendant condition for header/footer AX role mapping. (Closed)
Patch Set: addressed review comment Created 3 years, 10 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 | « third_party/WebKit/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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return 0; 413 return 0;
414 } 414 }
415 // ARIA spec says that when a parent object is presentational and this object 415 // ARIA spec says that when a parent object is presentational and this object
416 // is a required owned element of that parent, then this object is also 416 // is a required owned element of that parent, then this object is also
417 // presentational. 417 // presentational.
418 if (isRequiredOwnedElement(parent, roleValue(), element)) 418 if (isRequiredOwnedElement(parent, roleValue(), element))
419 return parent; 419 return parent;
420 return 0; 420 return 0;
421 } 421 }
422 422
423 // There should only be one banner/contentInfo per page. If header/footer are
424 // being used within an article, aside, nave, section, blockquote, details,
425 // fieldset, figure, td, or main, then it should not be exposed as whole
426 // page's banner/contentInfo.
427 static HashSet<QualifiedName>& getLandmarkRolesNotAllowed() {
428 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, landmarkRolesNotAllowed, ());
429 if (landmarkRolesNotAllowed.isEmpty()) {
430 landmarkRolesNotAllowed.add(articleTag);
431 landmarkRolesNotAllowed.add(asideTag);
432 landmarkRolesNotAllowed.add(navTag);
433 landmarkRolesNotAllowed.add(sectionTag);
434 landmarkRolesNotAllowed.add(blockquoteTag);
435 landmarkRolesNotAllowed.add(detailsTag);
436 landmarkRolesNotAllowed.add(fieldsetTag);
437 landmarkRolesNotAllowed.add(figureTag);
438 landmarkRolesNotAllowed.add(tdTag);
439 landmarkRolesNotAllowed.add(mainTag);
440 }
441 return landmarkRolesNotAllowed;
442 }
443
423 bool AXNodeObject::isDescendantOfElementType( 444 bool AXNodeObject::isDescendantOfElementType(
424 const HTMLQualifiedName& tagName) const { 445 HashSet<QualifiedName>& tagNames) const {
425 if (!getNode()) 446 if (!getNode())
426 return false; 447 return false;
427 448
428 for (Element* parent = getNode()->parentElement(); parent; 449 for (Element* parent = getNode()->parentElement(); parent;
429 parent = parent->parentElement()) { 450 parent = parent->parentElement()) {
430 if (parent->hasTagName(tagName)) 451 if (tagNames.contains(parent->tagQName()))
431 return true; 452 return true;
432 } 453 }
433 return false; 454 return false;
434 } 455 }
435 456
436 AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const { 457 AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const {
437 if (!getNode()) 458 if (!getNode())
438 return UnknownRole; 459 return UnknownRole;
439 460
440 // HTMLAnchorElement sets isLink only when it has hrefAttr. 461 // HTMLAnchorElement sets isLink only when it has hrefAttr.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 const AtomicString& ariaRole = getAttribute(roleAttr); 618 const AtomicString& ariaRole = getAttribute(roleAttr);
598 if (ariaRole == "none" || ariaRole == "presentation") 619 if (ariaRole == "none" || ariaRole == "presentation")
599 return IframePresentationalRole; 620 return IframePresentationalRole;
600 return IframeRole; 621 return IframeRole;
601 } 622 }
602 623
603 // There should only be one banner/contentInfo per page. If header/footer are 624 // There should only be one banner/contentInfo per page. If header/footer are
604 // being used within an article or section then it should not be exposed as 625 // being used within an article or section then it should not be exposed as
605 // whole page's banner/contentInfo but as a group role. 626 // whole page's banner/contentInfo but as a group role.
606 if (getNode()->hasTagName(headerTag)) { 627 if (getNode()->hasTagName(headerTag)) {
607 if (isDescendantOfElementType(articleTag) || 628 if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))
608 isDescendantOfElementType(sectionTag) ||
609 (getNode()->parentElement() &&
610 getNode()->parentElement()->hasTagName(mainTag))) {
611 return GroupRole; 629 return GroupRole;
612 }
613 return BannerRole; 630 return BannerRole;
614 } 631 }
615 632
616 if (getNode()->hasTagName(footerTag)) { 633 if (getNode()->hasTagName(footerTag)) {
617 if (isDescendantOfElementType(articleTag) || 634 if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))
618 isDescendantOfElementType(sectionTag) ||
619 (getNode()->parentElement() &&
620 getNode()->parentElement()->hasTagName(mainTag))) {
621 return GroupRole; 635 return GroupRole;
622 }
623 return FooterRole; 636 return FooterRole;
624 } 637 }
625 638
626 if (getNode()->hasTagName(blockquoteTag)) 639 if (getNode()->hasTagName(blockquoteTag))
627 return BlockquoteRole; 640 return BlockquoteRole;
628 641
629 if (getNode()->hasTagName(captionTag)) 642 if (getNode()->hasTagName(captionTag))
630 return CaptionRole; 643 return CaptionRole;
631 644
632 if (getNode()->hasTagName(figcaptionTag)) 645 if (getNode()->hasTagName(figcaptionTag))
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 return String(); 3115 return String();
3103 return toTextControlElement(node)->strippedPlaceholder(); 3116 return toTextControlElement(node)->strippedPlaceholder();
3104 } 3117 }
3105 3118
3106 DEFINE_TRACE(AXNodeObject) { 3119 DEFINE_TRACE(AXNodeObject) {
3107 visitor->trace(m_node); 3120 visitor->trace(m_node);
3108 AXObject::trace(visitor); 3121 AXObject::trace(visitor);
3109 } 3122 }
3110 3123
3111 } // namespace blink 3124 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698