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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 | 611 |
| 612 if (isHTMLDialogElement(*getNode())) | 612 if (isHTMLDialogElement(*getNode())) |
| 613 return DialogRole; | 613 return DialogRole; |
| 614 | 614 |
| 615 // The HTML element should not be exposed as an element. That's what the | 615 // The HTML element should not be exposed as an element. That's what the |
| 616 // LayoutView element does. | 616 // LayoutView element does. |
| 617 if (isHTMLHtmlElement(*getNode())) | 617 if (isHTMLHtmlElement(*getNode())) |
| 618 return IgnoredRole; | 618 return IgnoredRole; |
| 619 | 619 |
| 620 if (isHTMLIFrameElement(*getNode())) { | 620 if (isHTMLIFrameElement(*getNode())) { |
| 621 const AtomicString& ariaRole = getAttribute(roleAttr); | 621 const AtomicString& ariaRole = |
| 622 getAriaAttributeOrAOMProperty(AOMStringProperty::Role); | |
|
esprehn
2017/03/22 03:40:32
I'm skeptical of having a separate enum for every
dmazzoni
2017/03/23 03:36:41
We use this pattern elsewhere in accessibility cod
| |
| 622 if (ariaRole == "none" || ariaRole == "presentation") | 623 if (ariaRole == "none" || ariaRole == "presentation") |
| 623 return IframePresentationalRole; | 624 return IframePresentationalRole; |
| 624 return IframeRole; | 625 return IframeRole; |
| 625 } | 626 } |
| 626 | 627 |
| 627 // There should only be one banner/contentInfo per page. If header/footer are | 628 // There should only be one banner/contentInfo per page. If header/footer are |
| 628 // being used within an article or section then it should not be exposed as | 629 // being used within an article or section then it should not be exposed as |
| 629 // whole page's banner/contentInfo but as a group role. | 630 // whole page's banner/contentInfo but as a group role. |
| 630 if (getNode()->hasTagName(headerTag)) { | 631 if (getNode()->hasTagName(headerTag)) { |
| 631 if (isDescendantOfElementType(getLandmarkRolesNotAllowed())) | 632 if (isDescendantOfElementType(getLandmarkRolesNotAllowed())) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 // A generic element with tabIndex explicitly set gets GroupRole. | 685 // A generic element with tabIndex explicitly set gets GroupRole. |
| 685 // The layout checks for focusability aren't critical here; a false | 686 // The layout checks for focusability aren't critical here; a false |
| 686 // positive would be harmless. | 687 // positive would be harmless. |
| 687 if (element->isInCanvasSubtree() && element->supportsFocus()) | 688 if (element->isInCanvasSubtree() && element->supportsFocus()) |
| 688 return GroupRole; | 689 return GroupRole; |
| 689 } | 690 } |
| 690 return UnknownRole; | 691 return UnknownRole; |
| 691 } | 692 } |
| 692 | 693 |
| 693 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const { | 694 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const { |
| 694 const AtomicString& ariaRole = getAttribute(roleAttr); | 695 const AtomicString& ariaRole = |
| 696 getAriaAttributeOrAOMProperty(AOMStringProperty::Role); | |
| 695 if (ariaRole.isNull() || ariaRole.isEmpty()) | 697 if (ariaRole.isNull() || ariaRole.isEmpty()) |
| 696 return UnknownRole; | 698 return UnknownRole; |
| 697 | 699 |
| 698 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); | 700 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); |
| 699 | 701 |
| 700 // ARIA states if an item can get focus, it should not be presentational. | 702 // ARIA states if an item can get focus, it should not be presentational. |
| 701 if ((role == NoneRole || role == PresentationalRole) && | 703 if ((role == NoneRole || role == PresentationalRole) && |
| 702 canSetFocusAttribute()) | 704 canSetFocusAttribute()) |
| 703 return UnknownRole; | 705 return UnknownRole; |
| 704 | 706 |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1984 if (isHiddenForTextAlternativeCalculation()) | 1986 if (isHiddenForTextAlternativeCalculation()) |
| 1985 return false; | 1987 return false; |
| 1986 | 1988 |
| 1987 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 | 1989 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 |
| 1988 HeapVector<Member<Element>> elements; | 1990 HeapVector<Member<Element>> elements; |
| 1989 ariaLabelledbyElementVector(elements); | 1991 ariaLabelledbyElementVector(elements); |
| 1990 if (elements.size() > 0) | 1992 if (elements.size() > 0) |
| 1991 return false; | 1993 return false; |
| 1992 | 1994 |
| 1993 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 | 1995 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 |
| 1994 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 1996 const AtomicString& ariaLabel = |
| 1997 getAriaAttributeOrAOMProperty(AOMStringProperty::Label); | |
| 1995 if (!ariaLabel.isEmpty()) | 1998 if (!ariaLabel.isEmpty()) |
| 1996 return false; | 1999 return false; |
| 1997 | 2000 |
| 1998 // Based on | 2001 // Based on |
| 1999 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an d-description-calculation | 2002 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an d-description-calculation |
| 2000 // 5.1/5.5 Text inputs, Other labelable Elements | 2003 // 5.1/5.5 Text inputs, Other labelable Elements |
| 2001 HTMLElement* htmlElement = nullptr; | 2004 HTMLElement* htmlElement = nullptr; |
| 2002 if (getNode()->isHTMLElement()) | 2005 if (getNode()->isHTMLElement()) |
| 2003 htmlElement = toHTMLElement(getNode()); | 2006 htmlElement = toHTMLElement(getNode()); |
| 2004 if (htmlElement && isLabelableElement(htmlElement)) { | 2007 if (htmlElement && isLabelableElement(htmlElement)) { |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2918 if (isWebArea()) { | 2921 if (isWebArea()) { |
| 2919 Document* document = this->getDocument(); | 2922 Document* document = this->getDocument(); |
| 2920 if (document) { | 2923 if (document) { |
| 2921 nameFrom = AXNameFromAttribute; | 2924 nameFrom = AXNameFromAttribute; |
| 2922 if (nameSources) { | 2925 if (nameSources) { |
| 2923 nameSources->push_back( | 2926 nameSources->push_back( |
| 2924 NameSource(foundTextAlternative, aria_labelAttr)); | 2927 NameSource(foundTextAlternative, aria_labelAttr)); |
| 2925 nameSources->back().type = nameFrom; | 2928 nameSources->back().type = nameFrom; |
| 2926 } | 2929 } |
| 2927 if (Element* documentElement = document->documentElement()) { | 2930 if (Element* documentElement = document->documentElement()) { |
| 2931 AXObject* axDocument = axObjectCache().getOrCreate(documentElement); | |
| 2932 DCHECK(axDocument); | |
| 2928 const AtomicString& ariaLabel = | 2933 const AtomicString& ariaLabel = |
| 2929 documentElement->getAttribute(aria_labelAttr); | 2934 axDocument->getAriaAttributeOrAOMProperty(AOMStringProperty::Label); |
| 2930 if (!ariaLabel.isEmpty()) { | 2935 if (!ariaLabel.isEmpty()) { |
| 2931 textAlternative = ariaLabel; | 2936 textAlternative = ariaLabel; |
| 2932 | 2937 |
| 2933 if (nameSources) { | 2938 if (nameSources) { |
| 2934 NameSource& source = nameSources->back(); | 2939 NameSource& source = nameSources->back(); |
| 2935 source.text = textAlternative; | 2940 source.text = textAlternative; |
| 2936 source.attributeValue = ariaLabel; | 2941 source.attributeValue = ariaLabel; |
| 2937 *foundTextAlternative = true; | 2942 *foundTextAlternative = true; |
| 2938 } else { | 2943 } else { |
| 2939 return textAlternative; | 2944 return textAlternative; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3206 return String(); | 3211 return String(); |
| 3207 return toTextControlElement(node)->strippedPlaceholder(); | 3212 return toTextControlElement(node)->strippedPlaceholder(); |
| 3208 } | 3213 } |
| 3209 | 3214 |
| 3210 DEFINE_TRACE(AXNodeObject) { | 3215 DEFINE_TRACE(AXNodeObject) { |
| 3211 visitor->trace(m_node); | 3216 visitor->trace(m_node); |
| 3212 AXObject::trace(visitor); | 3217 AXObject::trace(visitor); |
| 3213 } | 3218 } |
| 3214 | 3219 |
| 3215 } // namespace blink | 3220 } // namespace blink |
| OLD | NEW |