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

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

Issue 2791943002: Re-land: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Fix for crash with test Created 3 years, 8 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 11 matching lines...) Expand all
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"
32 #include "core/dom/DocumentUserGestureToken.h" 33 #include "core/dom/DocumentUserGestureToken.h"
33 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
34 #include "core/dom/NodeTraversal.h" 35 #include "core/dom/NodeTraversal.h"
35 #include "core/dom/QualifiedName.h" 36 #include "core/dom/QualifiedName.h"
36 #include "core/dom/Text.h" 37 #include "core/dom/Text.h"
37 #include "core/dom/shadow/FlatTreeTraversal.h" 38 #include "core/dom/shadow/FlatTreeTraversal.h"
38 #include "core/editing/EditingUtilities.h" 39 #include "core/editing/EditingUtilities.h"
39 #include "core/editing/markers/DocumentMarkerController.h" 40 #include "core/editing/markers/DocumentMarkerController.h"
40 #include "core/frame/FrameView.h" 41 #include "core/frame/FrameView.h"
41 #include "core/html/HTMLAnchorElement.h" 42 #include "core/html/HTMLAnchorElement.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 612
612 if (isHTMLDialogElement(*getNode())) 613 if (isHTMLDialogElement(*getNode()))
613 return DialogRole; 614 return DialogRole;
614 615
615 // The HTML element should not be exposed as an element. That's what the 616 // The HTML element should not be exposed as an element. That's what the
616 // LayoutView element does. 617 // LayoutView element does.
617 if (isHTMLHtmlElement(*getNode())) 618 if (isHTMLHtmlElement(*getNode()))
618 return IgnoredRole; 619 return IgnoredRole;
619 620
620 if (isHTMLIFrameElement(*getNode())) { 621 if (isHTMLIFrameElement(*getNode())) {
621 const AtomicString& ariaRole = getAttribute(roleAttr); 622 const AtomicString& ariaRole =
623 getAOMPropertyOrARIAAttribute(AOMStringProperty::kRole);
622 if (ariaRole == "none" || ariaRole == "presentation") 624 if (ariaRole == "none" || ariaRole == "presentation")
623 return IframePresentationalRole; 625 return IframePresentationalRole;
624 return IframeRole; 626 return IframeRole;
625 } 627 }
626 628
627 // There should only be one banner/contentInfo per page. If header/footer are 629 // 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 630 // 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. 631 // whole page's banner/contentInfo but as a group role.
630 if (getNode()->hasTagName(headerTag)) { 632 if (getNode()->hasTagName(headerTag)) {
631 if (isDescendantOfElementType(getLandmarkRolesNotAllowed())) 633 if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 // A generic element with tabIndex explicitly set gets GroupRole. 686 // A generic element with tabIndex explicitly set gets GroupRole.
685 // The layout checks for focusability aren't critical here; a false 687 // The layout checks for focusability aren't critical here; a false
686 // positive would be harmless. 688 // positive would be harmless.
687 if (element->isInCanvasSubtree() && element->supportsFocus()) 689 if (element->isInCanvasSubtree() && element->supportsFocus())
688 return GroupRole; 690 return GroupRole;
689 } 691 }
690 return UnknownRole; 692 return UnknownRole;
691 } 693 }
692 694
693 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const { 695 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const {
694 const AtomicString& ariaRole = getAttribute(roleAttr); 696 const AtomicString& ariaRole =
697 getAOMPropertyOrARIAAttribute(AOMStringProperty::kRole);
695 if (ariaRole.isNull() || ariaRole.isEmpty()) 698 if (ariaRole.isNull() || ariaRole.isEmpty())
696 return UnknownRole; 699 return UnknownRole;
697 700
698 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); 701 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole);
699 702
700 // ARIA states if an item can get focus, it should not be presentational. 703 // ARIA states if an item can get focus, it should not be presentational.
701 if ((role == NoneRole || role == PresentationalRole) && 704 if ((role == NoneRole || role == PresentationalRole) &&
702 canSetFocusAttribute()) 705 canSetFocusAttribute())
703 return UnknownRole; 706 return UnknownRole;
704 707
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 if (isHiddenForTextAlternativeCalculation()) 1987 if (isHiddenForTextAlternativeCalculation())
1985 return false; 1988 return false;
1986 1989
1987 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 1990 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1
1988 HeapVector<Member<Element>> elements; 1991 HeapVector<Member<Element>> elements;
1989 ariaLabelledbyElementVector(elements); 1992 ariaLabelledbyElementVector(elements);
1990 if (elements.size() > 0) 1993 if (elements.size() > 0)
1991 return false; 1994 return false;
1992 1995
1993 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 1996 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1
1994 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); 1997 const AtomicString& ariaLabel =
1998 getAOMPropertyOrARIAAttribute(AOMStringProperty::kLabel);
1995 if (!ariaLabel.isEmpty()) 1999 if (!ariaLabel.isEmpty())
1996 return false; 2000 return false;
1997 2001
1998 // Based on 2002 // Based on
1999 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an d-description-calculation 2003 // 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 2004 // 5.1/5.5 Text inputs, Other labelable Elements
2001 HTMLElement* htmlElement = nullptr; 2005 HTMLElement* htmlElement = nullptr;
2002 if (getNode()->isHTMLElement()) 2006 if (getNode()->isHTMLElement())
2003 htmlElement = toHTMLElement(getNode()); 2007 htmlElement = toHTMLElement(getNode());
2004 if (htmlElement && isLabelableElement(htmlElement)) { 2008 if (htmlElement && isLabelableElement(htmlElement)) {
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 if (isWebArea()) { 2922 if (isWebArea()) {
2919 Document* document = this->getDocument(); 2923 Document* document = this->getDocument();
2920 if (document) { 2924 if (document) {
2921 nameFrom = AXNameFromAttribute; 2925 nameFrom = AXNameFromAttribute;
2922 if (nameSources) { 2926 if (nameSources) {
2923 nameSources->push_back( 2927 nameSources->push_back(
2924 NameSource(foundTextAlternative, aria_labelAttr)); 2928 NameSource(foundTextAlternative, aria_labelAttr));
2925 nameSources->back().type = nameFrom; 2929 nameSources->back().type = nameFrom;
2926 } 2930 }
2927 if (Element* documentElement = document->documentElement()) { 2931 if (Element* documentElement = document->documentElement()) {
2928 const AtomicString& ariaLabel = 2932 const AtomicString& ariaLabel = AccessibleNode::getProperty(
aboxhall 2017/04/03 08:41:55 This looks good, but why not do this everywhere ge
dmazzoni 2017/04/03 15:25:48 It depends on whether we have an AXObject or an El
2929 documentElement->getAttribute(aria_labelAttr); 2933 documentElement, AOMStringProperty::kLabel);
2930 if (!ariaLabel.isEmpty()) { 2934 if (!ariaLabel.isEmpty()) {
2931 textAlternative = ariaLabel; 2935 textAlternative = ariaLabel;
2932 2936
2933 if (nameSources) { 2937 if (nameSources) {
2934 NameSource& source = nameSources->back(); 2938 NameSource& source = nameSources->back();
2935 source.text = textAlternative; 2939 source.text = textAlternative;
2936 source.attributeValue = ariaLabel; 2940 source.attributeValue = ariaLabel;
2937 *foundTextAlternative = true; 2941 *foundTextAlternative = true;
2938 } else { 2942 } else {
2939 return textAlternative; 2943 return textAlternative;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 return String(); 3210 return String();
3207 return toTextControlElement(node)->strippedPlaceholder(); 3211 return toTextControlElement(node)->strippedPlaceholder();
3208 } 3212 }
3209 3213
3210 DEFINE_TRACE(AXNodeObject) { 3214 DEFINE_TRACE(AXNodeObject) {
3211 visitor->trace(m_node); 3215 visitor->trace(m_node);
3212 AXObject::trace(visitor); 3216 AXObject::trace(visitor);
3213 } 3217 }
3214 3218
3215 } // namespace blink 3219 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ElementRareData.cpp ('k') | third_party/WebKit/Source/modules/accessibility/AXObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698