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

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: Updated formatting Created 3 years, 11 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return 0; 401 return 0;
402 } 402 }
403 // ARIA spec says that when a parent object is presentational and this object 403 // ARIA spec says that when a parent object is presentational and this object
404 // is a required owned element of that parent, then this object is also 404 // is a required owned element of that parent, then this object is also
405 // presentational. 405 // presentational.
406 if (isRequiredOwnedElement(parent, roleValue(), element)) 406 if (isRequiredOwnedElement(parent, roleValue(), element))
407 return parent; 407 return parent;
408 return 0; 408 return 0;
409 } 409 }
410 410
411 // There should only be one banner/contentInfo per page. If header/footer are
412 // being used within an article, aside, nave, section, blockquote, details,
413 // fieldset, figure, td, or main, then it should not be exposed as whole
414 // page's banner/contentInfo.
415 static HashSet<QualifiedName>& getLandmarkRoleBlocked() {
dmazzoni 2017/02/02 16:40:06 Just for consistency, either call the function get
je_julie 2017/02/03 08:32:45 I updated with getLandmarkRolesNotAllowed() and la
416 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, landmarksRoleNotAllowed, ());
417 if (landmarksRoleNotAllowed.isEmpty()) {
418 landmarksRoleNotAllowed.add(articleTag);
419 landmarksRoleNotAllowed.add(asideTag);
420 landmarksRoleNotAllowed.add(navTag);
421 landmarksRoleNotAllowed.add(sectionTag);
422 landmarksRoleNotAllowed.add(blockquoteTag);
423 landmarksRoleNotAllowed.add(detailsTag);
424 landmarksRoleNotAllowed.add(fieldsetTag);
425 landmarksRoleNotAllowed.add(figureTag);
426 landmarksRoleNotAllowed.add(tdTag);
427 landmarksRoleNotAllowed.add(mainTag);
428 }
429 return landmarksRoleNotAllowed;
430 }
431
411 bool AXNodeObject::isDescendantOfElementType( 432 bool AXNodeObject::isDescendantOfElementType(
412 const HTMLQualifiedName& tagName) const { 433 HashSet<QualifiedName>& tagNames) const {
413 if (!getNode()) 434 if (!getNode())
414 return false; 435 return false;
415 436
416 for (Element* parent = getNode()->parentElement(); parent; 437 for (Element* parent = getNode()->parentElement(); parent;
417 parent = parent->parentElement()) { 438 parent = parent->parentElement()) {
418 if (parent->hasTagName(tagName)) 439 if (tagNames.contains(parent->tagQName()))
419 return true; 440 return true;
420 } 441 }
421 return false; 442 return false;
422 } 443 }
423 444
424 AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const { 445 AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const {
425 if (!getNode()) 446 if (!getNode())
426 return UnknownRole; 447 return UnknownRole;
427 448
428 // HTMLAnchorElement sets isLink only when it has hrefAttr. 449 // HTMLAnchorElement sets isLink only when it has hrefAttr.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 const AtomicString& ariaRole = getAttribute(roleAttr); 606 const AtomicString& ariaRole = getAttribute(roleAttr);
586 if (ariaRole == "none" || ariaRole == "presentation") 607 if (ariaRole == "none" || ariaRole == "presentation")
587 return IframePresentationalRole; 608 return IframePresentationalRole;
588 return IframeRole; 609 return IframeRole;
589 } 610 }
590 611
591 // There should only be one banner/contentInfo per page. If header/footer are 612 // There should only be one banner/contentInfo per page. If header/footer are
592 // being used within an article or section then it should not be exposed as 613 // being used within an article or section then it should not be exposed as
593 // whole page's banner/contentInfo but as a group role. 614 // whole page's banner/contentInfo but as a group role.
594 if (getNode()->hasTagName(headerTag)) { 615 if (getNode()->hasTagName(headerTag)) {
595 if (isDescendantOfElementType(articleTag) || 616 if (isDescendantOfElementType(getLandmarkRoleBlocked()))
596 isDescendantOfElementType(sectionTag) ||
597 (getNode()->parentElement() &&
598 getNode()->parentElement()->hasTagName(mainTag))) {
599 return GroupRole; 617 return GroupRole;
600 }
601 return BannerRole; 618 return BannerRole;
602 } 619 }
603 620
604 if (getNode()->hasTagName(footerTag)) { 621 if (getNode()->hasTagName(footerTag)) {
605 if (isDescendantOfElementType(articleTag) || 622 if (isDescendantOfElementType(getLandmarkRoleBlocked()))
606 isDescendantOfElementType(sectionTag) ||
607 (getNode()->parentElement() &&
608 getNode()->parentElement()->hasTagName(mainTag))) {
609 return GroupRole; 623 return GroupRole;
610 }
611 return FooterRole; 624 return FooterRole;
612 } 625 }
613 626
614 if (getNode()->hasTagName(blockquoteTag)) 627 if (getNode()->hasTagName(blockquoteTag))
615 return BlockquoteRole; 628 return BlockquoteRole;
616 629
617 if (getNode()->hasTagName(captionTag)) 630 if (getNode()->hasTagName(captionTag))
618 return CaptionRole; 631 return CaptionRole;
619 632
620 if (getNode()->hasTagName(figcaptionTag)) 633 if (getNode()->hasTagName(figcaptionTag))
(...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 return String(); 3085 return String();
3073 return toTextControlElement(node)->strippedPlaceholder(); 3086 return toTextControlElement(node)->strippedPlaceholder();
3074 } 3087 }
3075 3088
3076 DEFINE_TRACE(AXNodeObject) { 3089 DEFINE_TRACE(AXNodeObject) {
3077 visitor->trace(m_node); 3090 visitor->trace(m_node);
3078 AXObject::trace(visitor); 3091 AXObject::trace(visitor);
3079 } 3092 }
3080 3093
3081 } // namespace blink 3094 } // 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