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

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

Issue 2867073003: Name calculation should not include nameFrom:author descendants. (Closed)
Patch Set: Rebase Created 3 years, 7 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 return select_element.IsMultiple() ? kListBoxRole : kPopUpButtonRole; 540 return select_element.IsMultiple() ? kListBoxRole : kPopUpButtonRole;
541 } 541 }
542 542
543 if (isHTMLTextAreaElement(*GetNode())) 543 if (isHTMLTextAreaElement(*GetNode()))
544 return kTextFieldRole; 544 return kTextFieldRole;
545 545
546 if (HeadingLevel()) 546 if (HeadingLevel())
547 return kHeadingRole; 547 return kHeadingRole;
548 548
549 if (isHTMLDivElement(*GetNode())) 549 if (isHTMLDivElement(*GetNode()))
550 return kDivRole; 550 return kGenericContainerRole;
551 551
552 if (isHTMLMeterElement(*GetNode())) 552 if (isHTMLMeterElement(*GetNode()))
553 return kMeterRole; 553 return kMeterRole;
554 554
555 if (isHTMLOutputElement(*GetNode())) 555 if (isHTMLOutputElement(*GetNode()))
556 return kStatusRole; 556 return kStatusRole;
557 557
558 if (isHTMLParagraphElement(*GetNode())) 558 if (isHTMLParagraphElement(*GetNode()))
559 return kParagraphRole; 559 return kParagraphRole;
560 560
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 if (isHTMLIFrameElement(*GetNode())) { 628 if (isHTMLIFrameElement(*GetNode())) {
629 const AtomicString& aria_role = 629 const AtomicString& aria_role =
630 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); 630 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole);
631 if (aria_role == "none" || aria_role == "presentation") 631 if (aria_role == "none" || aria_role == "presentation")
632 return kIframePresentationalRole; 632 return kIframePresentationalRole;
633 return kIframeRole; 633 return kIframeRole;
634 } 634 }
635 635
636 // There should only be one banner/contentInfo per page. If header/footer are 636 // There should only be one banner/contentInfo per page. If header/footer are
637 // being used within an article or section then it should not be exposed as 637 // being used within an article or section then it should not be exposed as
638 // whole page's banner/contentInfo but as a group role. 638 // whole page's banner/contentInfo but as a generic container role.
639 if (GetNode()->HasTagName(headerTag)) { 639 if (GetNode()->HasTagName(headerTag)) {
640 if (IsDescendantOfElementType(GetLandmarkRolesNotAllowed())) 640 if (IsDescendantOfElementType(GetLandmarkRolesNotAllowed()))
641 return kGroupRole; 641 return kGenericContainerRole;
642 return kBannerRole; 642 return kBannerRole;
643 } 643 }
644 644
645 if (GetNode()->HasTagName(footerTag)) { 645 if (GetNode()->HasTagName(footerTag)) {
646 if (IsDescendantOfElementType(GetLandmarkRolesNotAllowed())) 646 if (IsDescendantOfElementType(GetLandmarkRolesNotAllowed()))
647 return kGroupRole; 647 return kGenericContainerRole;
648 return kFooterRole; 648 return kFooterRole;
649 } 649 }
650 650
651 if (GetNode()->HasTagName(blockquoteTag)) 651 if (GetNode()->HasTagName(blockquoteTag))
652 return kBlockquoteRole; 652 return kBlockquoteRole;
653 653
654 if (GetNode()->HasTagName(captionTag)) 654 if (GetNode()->HasTagName(captionTag))
655 return kCaptionRole; 655 return kCaptionRole;
656 656
657 if (GetNode()->HasTagName(figcaptionTag)) 657 if (GetNode()->HasTagName(figcaptionTag))
(...skipping 28 matching lines...) Expand all
686 686
687 AccessibilityRole role = NativeAccessibilityRoleIgnoringAria(); 687 AccessibilityRole role = NativeAccessibilityRoleIgnoringAria();
688 if (role != kUnknownRole) 688 if (role != kUnknownRole)
689 return role; 689 return role;
690 if (GetNode()->IsElementNode()) { 690 if (GetNode()->IsElementNode()) {
691 Element* element = ToElement(GetNode()); 691 Element* element = ToElement(GetNode());
692 // A generic element with tabIndex explicitly set gets GroupRole. 692 // A generic element with tabIndex explicitly set gets GroupRole.
693 // The layout checks for focusability aren't critical here; a false 693 // The layout checks for focusability aren't critical here; a false
694 // positive would be harmless. 694 // positive would be harmless.
695 if (element->IsInCanvasSubtree() && element->SupportsFocus()) 695 if (element->IsInCanvasSubtree() && element->SupportsFocus())
696 return kGroupRole; 696 return kGenericContainerRole;
697 } 697 }
698 return kUnknownRole; 698 return kUnknownRole;
699 } 699 }
700 700
701 AccessibilityRole AXNodeObject::DetermineAriaRoleAttribute() const { 701 AccessibilityRole AXNodeObject::DetermineAriaRoleAttribute() const {
702 const AtomicString& aria_role = 702 const AtomicString& aria_role =
703 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); 703 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole);
704 if (aria_role.IsNull() || aria_role.IsEmpty()) 704 if (aria_role.IsNull() || aria_role.IsEmpty())
705 return kUnknownRole; 705 return kUnknownRole;
706 706
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 text_alternative = 1865 text_alternative =
1866 NativeTextAlternative(visited, name_from, related_objects, name_sources, 1866 NativeTextAlternative(visited, name_from, related_objects, name_sources,
1867 &found_text_alternative); 1867 &found_text_alternative);
1868 const bool has_text_alternative = 1868 const bool has_text_alternative =
1869 !text_alternative.IsEmpty() || 1869 !text_alternative.IsEmpty() ||
1870 name_from == kAXNameFromAttributeExplicitlyEmpty; 1870 name_from == kAXNameFromAttributeExplicitlyEmpty;
1871 if (has_text_alternative && !name_sources) 1871 if (has_text_alternative && !name_sources)
1872 return text_alternative; 1872 return text_alternative;
1873 1873
1874 // Step 2F / 2G from: http://www.w3.org/TR/accname-aam-1.1 1874 // Step 2F / 2G from: http://www.w3.org/TR/accname-aam-1.1
1875 if (recursive || NameFromContents()) { 1875 if (in_aria_labelled_by_traversal || NameFromContents(recursive)) {
1876 name_from = kAXNameFromContents; 1876 Node* node = this->GetNode();
1877 if (name_sources) { 1877 if (!isHTMLSelectElement(node)) { // Avoid option descendant text
1878 name_sources->push_back(NameSource(found_text_alternative)); 1878 name_from = kAXNameFromContents;
1879 name_sources->back().type = name_from; 1879 if (name_sources) {
1880 } 1880 name_sources->push_back(NameSource(found_text_alternative));
1881 name_sources->back().type = name_from;
1882 }
1881 1883
1882 Node* node = this->GetNode(); 1884 if (node && node->IsTextNode())
1883 if (node && node->IsTextNode()) 1885 text_alternative = ToText(node)->wholeText();
1884 text_alternative = ToText(node)->wholeText(); 1886 else if (isHTMLBRElement(node))
1885 else if (isHTMLBRElement(node)) 1887 text_alternative = String("\n");
1886 text_alternative = String("\n"); 1888 else
1887 else 1889 text_alternative = TextFromDescendants(visited, false);
1888 text_alternative = TextFromDescendants(visited, false);
1889 1890
1890 if (!text_alternative.IsEmpty()) { 1891 if (!text_alternative.IsEmpty()) {
1891 if (name_sources) { 1892 if (name_sources) {
1892 found_text_alternative = true; 1893 found_text_alternative = true;
1893 name_sources->back().text = text_alternative; 1894 name_sources->back().text = text_alternative;
1894 } else { 1895 } else {
1895 return text_alternative; 1896 return text_alternative;
1897 }
1896 } 1898 }
1897 } 1899 }
1898 } 1900 }
1899 1901
1900 // Step 2H from: http://www.w3.org/TR/accname-aam-1.1 1902 // Step 2H from: http://www.w3.org/TR/accname-aam-1.1
1901 name_from = kAXNameFromTitle; 1903 name_from = kAXNameFromTitle;
1902 if (name_sources) { 1904 if (name_sources) {
1903 name_sources->push_back(NameSource(found_text_alternative, titleAttr)); 1905 name_sources->push_back(NameSource(found_text_alternative, titleAttr));
1904 name_sources->back().type = name_from; 1906 name_sources->back().type = name_from;
1905 } 1907 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 html_element = ToHTMLElement(GetNode()); 2019 html_element = ToHTMLElement(GetNode());
2018 if (html_element && IsLabelableElement(html_element)) { 2020 if (html_element && IsLabelableElement(html_element)) {
2019 if (ToLabelableElement(html_element)->labels() && 2021 if (ToLabelableElement(html_element)->labels() &&
2020 ToLabelableElement(html_element)->labels()->length() > 0) 2022 ToLabelableElement(html_element)->labels()->length() > 0)
2021 return true; 2023 return true;
2022 } 2024 }
2023 2025
2024 return false; 2026 return false;
2025 } 2027 }
2026 2028
2027 bool AXNodeObject::NameFromContents() const {
2028 Node* node = GetNode();
2029 if (!node || !node->IsElementNode())
2030 return AXObjectImpl::NameFromContents();
2031 // AXObjectImpl::nameFromContents determines whether an element should take
2032 // its name from its descendant contents based on role. However, <select> is a
2033 // special case, as unlike a typical pop-up button it contains its own pop-up
2034 // menu's contents, which should not be used as the name.
2035 if (isHTMLSelectElement(node))
2036 return false;
2037 return AXObjectImpl::NameFromContents();
2038 }
2039
2040 void AXNodeObject::GetRelativeBounds( 2029 void AXNodeObject::GetRelativeBounds(
2041 AXObjectImpl** out_container, 2030 AXObjectImpl** out_container,
2042 FloatRect& out_bounds_in_container, 2031 FloatRect& out_bounds_in_container,
2043 SkMatrix44& out_container_transform) const { 2032 SkMatrix44& out_container_transform) const {
2044 if (LayoutObjectForRelativeBounds()) { 2033 if (LayoutObjectForRelativeBounds()) {
2045 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container, 2034 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container,
2046 out_container_transform); 2035 out_container_transform);
2047 return; 2036 return;
2048 } 2037 }
2049 2038
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 return String(); 3219 return String();
3231 return ToTextControlElement(node)->StrippedPlaceholder(); 3220 return ToTextControlElement(node)->StrippedPlaceholder();
3232 } 3221 }
3233 3222
3234 DEFINE_TRACE(AXNodeObject) { 3223 DEFINE_TRACE(AXNodeObject) {
3235 visitor->Trace(node_); 3224 visitor->Trace(node_);
3236 AXObjectImpl::Trace(visitor); 3225 AXObjectImpl::Trace(visitor);
3237 } 3226 }
3238 3227
3239 } // namespace blink 3228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698