| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "modules/accessibility/AXNodeObject.h" | 29 #include "modules/accessibility/AXNodeObject.h" |
| 30 | 30 |
| 31 #include "core/InputTypeNames.h" | 31 #include "core/InputTypeNames.h" |
| 32 #include "core/dom/AccessibleNode.h" | |
| 33 #include "core/dom/DocumentUserGestureToken.h" | 32 #include "core/dom/DocumentUserGestureToken.h" |
| 34 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
| 35 #include "core/dom/NodeTraversal.h" | 34 #include "core/dom/NodeTraversal.h" |
| 36 #include "core/dom/QualifiedName.h" | 35 #include "core/dom/QualifiedName.h" |
| 37 #include "core/dom/Text.h" | 36 #include "core/dom/Text.h" |
| 38 #include "core/dom/shadow/FlatTreeTraversal.h" | 37 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 39 #include "core/editing/EditingUtilities.h" | 38 #include "core/editing/EditingUtilities.h" |
| 40 #include "core/editing/markers/DocumentMarkerController.h" | 39 #include "core/editing/markers/DocumentMarkerController.h" |
| 41 #include "core/frame/FrameView.h" | 40 #include "core/frame/FrameView.h" |
| 42 #include "core/html/HTMLAnchorElement.h" | 41 #include "core/html/HTMLAnchorElement.h" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 611 |
| 613 if (isHTMLDialogElement(*getNode())) | 612 if (isHTMLDialogElement(*getNode())) |
| 614 return DialogRole; | 613 return DialogRole; |
| 615 | 614 |
| 616 // 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 |
| 617 // LayoutView element does. | 616 // LayoutView element does. |
| 618 if (isHTMLHtmlElement(*getNode())) | 617 if (isHTMLHtmlElement(*getNode())) |
| 619 return IgnoredRole; | 618 return IgnoredRole; |
| 620 | 619 |
| 621 if (isHTMLIFrameElement(*getNode())) { | 620 if (isHTMLIFrameElement(*getNode())) { |
| 622 const AtomicString& ariaRole = | 621 const AtomicString& ariaRole = getAttribute(roleAttr); |
| 623 getAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); | |
| 624 if (ariaRole == "none" || ariaRole == "presentation") | 622 if (ariaRole == "none" || ariaRole == "presentation") |
| 625 return IframePresentationalRole; | 623 return IframePresentationalRole; |
| 626 return IframeRole; | 624 return IframeRole; |
| 627 } | 625 } |
| 628 | 626 |
| 629 // There should only be one banner/contentInfo per page. If header/footer are | 627 // There should only be one banner/contentInfo per page. If header/footer are |
| 630 // being used within an article or section then it should not be exposed as | 628 // being used within an article or section then it should not be exposed as |
| 631 // whole page's banner/contentInfo but as a group role. | 629 // whole page's banner/contentInfo but as a group role. |
| 632 if (getNode()->hasTagName(headerTag)) { | 630 if (getNode()->hasTagName(headerTag)) { |
| 633 if (isDescendantOfElementType(getLandmarkRolesNotAllowed())) | 631 if (isDescendantOfElementType(getLandmarkRolesNotAllowed())) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // A generic element with tabIndex explicitly set gets GroupRole. | 684 // A generic element with tabIndex explicitly set gets GroupRole. |
| 687 // The layout checks for focusability aren't critical here; a false | 685 // The layout checks for focusability aren't critical here; a false |
| 688 // positive would be harmless. | 686 // positive would be harmless. |
| 689 if (element->isInCanvasSubtree() && element->supportsFocus()) | 687 if (element->isInCanvasSubtree() && element->supportsFocus()) |
| 690 return GroupRole; | 688 return GroupRole; |
| 691 } | 689 } |
| 692 return UnknownRole; | 690 return UnknownRole; |
| 693 } | 691 } |
| 694 | 692 |
| 695 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const { | 693 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const { |
| 696 const AtomicString& ariaRole = | 694 const AtomicString& ariaRole = getAttribute(roleAttr); |
| 697 getAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); | |
| 698 if (ariaRole.isNull() || ariaRole.isEmpty()) | 695 if (ariaRole.isNull() || ariaRole.isEmpty()) |
| 699 return UnknownRole; | 696 return UnknownRole; |
| 700 | 697 |
| 701 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); | 698 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); |
| 702 | 699 |
| 703 // ARIA states if an item can get focus, it should not be presentational. | 700 // ARIA states if an item can get focus, it should not be presentational. |
| 704 if ((role == NoneRole || role == PresentationalRole) && | 701 if ((role == NoneRole || role == PresentationalRole) && |
| 705 canSetFocusAttribute()) | 702 canSetFocusAttribute()) |
| 706 return UnknownRole; | 703 return UnknownRole; |
| 707 | 704 |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 if (isHiddenForTextAlternativeCalculation()) | 1984 if (isHiddenForTextAlternativeCalculation()) |
| 1988 return false; | 1985 return false; |
| 1989 | 1986 |
| 1990 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 | 1987 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 |
| 1991 HeapVector<Member<Element>> elements; | 1988 HeapVector<Member<Element>> elements; |
| 1992 ariaLabelledbyElementVector(elements); | 1989 ariaLabelledbyElementVector(elements); |
| 1993 if (elements.size() > 0) | 1990 if (elements.size() > 0) |
| 1994 return false; | 1991 return false; |
| 1995 | 1992 |
| 1996 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 | 1993 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 |
| 1997 const AtomicString& ariaLabel = | 1994 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 1998 getAOMPropertyOrARIAAttribute(AOMStringProperty::kLabel); | |
| 1999 if (!ariaLabel.isEmpty()) | 1995 if (!ariaLabel.isEmpty()) |
| 2000 return false; | 1996 return false; |
| 2001 | 1997 |
| 2002 // Based on | 1998 // Based on |
| 2003 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an
d-description-calculation | 1999 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an
d-description-calculation |
| 2004 // 5.1/5.5 Text inputs, Other labelable Elements | 2000 // 5.1/5.5 Text inputs, Other labelable Elements |
| 2005 HTMLElement* htmlElement = nullptr; | 2001 HTMLElement* htmlElement = nullptr; |
| 2006 if (getNode()->isHTMLElement()) | 2002 if (getNode()->isHTMLElement()) |
| 2007 htmlElement = toHTMLElement(getNode()); | 2003 htmlElement = toHTMLElement(getNode()); |
| 2008 if (htmlElement && isLabelableElement(htmlElement)) { | 2004 if (htmlElement && isLabelableElement(htmlElement)) { |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 if (isWebArea()) { | 2918 if (isWebArea()) { |
| 2923 Document* document = this->getDocument(); | 2919 Document* document = this->getDocument(); |
| 2924 if (document) { | 2920 if (document) { |
| 2925 nameFrom = AXNameFromAttribute; | 2921 nameFrom = AXNameFromAttribute; |
| 2926 if (nameSources) { | 2922 if (nameSources) { |
| 2927 nameSources->push_back( | 2923 nameSources->push_back( |
| 2928 NameSource(foundTextAlternative, aria_labelAttr)); | 2924 NameSource(foundTextAlternative, aria_labelAttr)); |
| 2929 nameSources->back().type = nameFrom; | 2925 nameSources->back().type = nameFrom; |
| 2930 } | 2926 } |
| 2931 if (Element* documentElement = document->documentElement()) { | 2927 if (Element* documentElement = document->documentElement()) { |
| 2932 AXObject* axDocument = axObjectCache().getOrCreate(documentElement); | |
| 2933 DCHECK(axDocument); | |
| 2934 const AtomicString& ariaLabel = | 2928 const AtomicString& ariaLabel = |
| 2935 axDocument->getAOMPropertyOrARIAAttribute( | 2929 documentElement->getAttribute(aria_labelAttr); |
| 2936 AOMStringProperty::kLabel); | |
| 2937 if (!ariaLabel.isEmpty()) { | 2930 if (!ariaLabel.isEmpty()) { |
| 2938 textAlternative = ariaLabel; | 2931 textAlternative = ariaLabel; |
| 2939 | 2932 |
| 2940 if (nameSources) { | 2933 if (nameSources) { |
| 2941 NameSource& source = nameSources->back(); | 2934 NameSource& source = nameSources->back(); |
| 2942 source.text = textAlternative; | 2935 source.text = textAlternative; |
| 2943 source.attributeValue = ariaLabel; | 2936 source.attributeValue = ariaLabel; |
| 2944 *foundTextAlternative = true; | 2937 *foundTextAlternative = true; |
| 2945 } else { | 2938 } else { |
| 2946 return textAlternative; | 2939 return textAlternative; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3213 return String(); | 3206 return String(); |
| 3214 return toTextControlElement(node)->strippedPlaceholder(); | 3207 return toTextControlElement(node)->strippedPlaceholder(); |
| 3215 } | 3208 } |
| 3216 | 3209 |
| 3217 DEFINE_TRACE(AXNodeObject) { | 3210 DEFINE_TRACE(AXNodeObject) { |
| 3218 visitor->trace(m_node); | 3211 visitor->trace(m_node); |
| 3219 AXObject::trace(visitor); | 3212 AXObject::trace(visitor); |
| 3220 } | 3213 } |
| 3221 | 3214 |
| 3222 } // namespace blink | 3215 } // namespace blink |
| OLD | NEW |