Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 group 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; |
|
dmazzoni
2017/05/16 16:25:39
Up to you, but I can see an argument for this
bein
aleventhal1
2017/05/16 18:11:26
Acknowledged.
| |
| 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; |
|
dmazzoni
2017/05/16 16:25:39
Same
aleventhal1
2017/05/16 18:11:26
Acknowledged.
| |
| 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 Loading... | |
| 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 Loading... | |
| 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 name_from = kAXNameFromContents; |
| 1877 if (name_sources) { | 1877 if (name_sources) { |
| 1878 name_sources->push_back(NameSource(found_text_alternative)); | 1878 name_sources->push_back(NameSource(found_text_alternative)); |
| 1879 name_sources->back().type = name_from; | 1879 name_sources->back().type = name_from; |
| 1880 } | 1880 } |
| 1881 | 1881 |
| 1882 Node* node = this->GetNode(); | 1882 Node* node = this->GetNode(); |
| 1883 if (node && node->IsTextNode()) | 1883 if (node && node->IsTextNode()) |
| 1884 text_alternative = ToText(node)->wholeText(); | 1884 text_alternative = ToText(node)->wholeText(); |
| 1885 else if (isHTMLBRElement(node)) | 1885 else if (isHTMLBRElement(node)) |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2017 html_element = ToHTMLElement(GetNode()); | 2017 html_element = ToHTMLElement(GetNode()); |
| 2018 if (html_element && IsLabelableElement(html_element)) { | 2018 if (html_element && IsLabelableElement(html_element)) { |
| 2019 if (ToLabelableElement(html_element)->labels() && | 2019 if (ToLabelableElement(html_element)->labels() && |
| 2020 ToLabelableElement(html_element)->labels()->length() > 0) | 2020 ToLabelableElement(html_element)->labels()->length() > 0) |
| 2021 return true; | 2021 return true; |
| 2022 } | 2022 } |
| 2023 | 2023 |
| 2024 return false; | 2024 return false; |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 bool AXNodeObject::NameFromContents() const { | 2027 bool AXNodeObject::NameFromContents(const bool recursive) const { |
| 2028 Node* node = GetNode(); | 2028 // AXObject::nameFromContents determines whether an element should take its |
| 2029 if (!node || !node->IsElementNode()) | 2029 // name from its descendant contents based on role. However, <select> is a |
| 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 | 2030 // 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. | 2031 // menu's contents, which should not be used as the name. |
| 2035 if (isHTMLSelectElement(node)) | 2032 return !isHTMLSelectElement(GetNode()) && |
| 2036 return false; | 2033 AXObjectImpl::NameFromContents(recursive); |
| 2037 return AXObjectImpl::NameFromContents(); | |
| 2038 } | 2034 } |
| 2039 | 2035 |
| 2040 void AXNodeObject::GetRelativeBounds( | 2036 void AXNodeObject::GetRelativeBounds( |
| 2041 AXObjectImpl** out_container, | 2037 AXObjectImpl** out_container, |
| 2042 FloatRect& out_bounds_in_container, | 2038 FloatRect& out_bounds_in_container, |
| 2043 SkMatrix44& out_container_transform) const { | 2039 SkMatrix44& out_container_transform) const { |
| 2044 if (LayoutObjectForRelativeBounds()) { | 2040 if (LayoutObjectForRelativeBounds()) { |
| 2045 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container, | 2041 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container, |
| 2046 out_container_transform); | 2042 out_container_transform); |
| 2047 return; | 2043 return; |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3230 return String(); | 3226 return String(); |
| 3231 return ToTextControlElement(node)->StrippedPlaceholder(); | 3227 return ToTextControlElement(node)->StrippedPlaceholder(); |
| 3232 } | 3228 } |
| 3233 | 3229 |
| 3234 DEFINE_TRACE(AXNodeObject) { | 3230 DEFINE_TRACE(AXNodeObject) { |
| 3235 visitor->Trace(node_); | 3231 visitor->Trace(node_); |
| 3236 AXObjectImpl::Trace(visitor); | 3232 AXObjectImpl::Trace(visitor); |
| 3237 } | 3233 } |
| 3238 | 3234 |
| 3239 } // namespace blink | 3235 } // namespace blink |
| OLD | NEW |