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

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

Issue 2750533006: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Created 3 years, 9 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "core/html/HTMLTableSectionElement.h" 56 #include "core/html/HTMLTableSectionElement.h"
57 #include "core/html/HTMLTextAreaElement.h" 57 #include "core/html/HTMLTextAreaElement.h"
58 #include "core/html/LabelsNodeList.h" 58 #include "core/html/LabelsNodeList.h"
59 #include "core/html/TextControlElement.h" 59 #include "core/html/TextControlElement.h"
60 #include "core/html/parser/HTMLParserIdioms.h" 60 #include "core/html/parser/HTMLParserIdioms.h"
61 #include "core/html/shadow/MediaControlElements.h" 61 #include "core/html/shadow/MediaControlElements.h"
62 #include "core/layout/LayoutBlockFlow.h" 62 #include "core/layout/LayoutBlockFlow.h"
63 #include "core/layout/LayoutObject.h" 63 #include "core/layout/LayoutObject.h"
64 #include "core/svg/SVGElement.h" 64 #include "core/svg/SVGElement.h"
65 #include "modules/accessibility/AXObjectCacheImpl.h" 65 #include "modules/accessibility/AXObjectCacheImpl.h"
66 #include "modules/accessibility/AccessibleNode.h"
66 #include "platform/UserGestureIndicator.h" 67 #include "platform/UserGestureIndicator.h"
67 #include "platform/text/PlatformLocale.h" 68 #include "platform/text/PlatformLocale.h"
68 #include "wtf/text/StringBuilder.h" 69 #include "wtf/text/StringBuilder.h"
69 70
70 namespace blink { 71 namespace blink {
71 72
72 using namespace HTMLNames; 73 using namespace HTMLNames;
73 74
74 class SparseAttributeSetter { 75 class SparseAttributeSetter {
75 USING_FAST_MALLOC(SparseAttributeSetter); 76 USING_FAST_MALLOC(SparseAttributeSetter);
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 609
609 if (isHTMLDialogElement(*getNode())) 610 if (isHTMLDialogElement(*getNode()))
610 return DialogRole; 611 return DialogRole;
611 612
612 // The HTML element should not be exposed as an element. That's what the 613 // The HTML element should not be exposed as an element. That's what the
613 // LayoutView element does. 614 // LayoutView element does.
614 if (isHTMLHtmlElement(*getNode())) 615 if (isHTMLHtmlElement(*getNode()))
615 return IgnoredRole; 616 return IgnoredRole;
616 617
617 if (isHTMLIFrameElement(*getNode())) { 618 if (isHTMLIFrameElement(*getNode())) {
618 const AtomicString& ariaRole = getAttribute(roleAttr); 619 const AtomicString& ariaRole =
620 getAomPropertyOrAriaAttribute(AomStringProperty::Role);
619 if (ariaRole == "none" || ariaRole == "presentation") 621 if (ariaRole == "none" || ariaRole == "presentation")
620 return IframePresentationalRole; 622 return IframePresentationalRole;
621 return IframeRole; 623 return IframeRole;
622 } 624 }
623 625
624 // There should only be one banner/contentInfo per page. If header/footer are 626 // There should only be one banner/contentInfo per page. If header/footer are
625 // being used within an article or section then it should not be exposed as 627 // being used within an article or section then it should not be exposed as
626 // whole page's banner/contentInfo but as a group role. 628 // whole page's banner/contentInfo but as a group role.
627 if (getNode()->hasTagName(headerTag)) { 629 if (getNode()->hasTagName(headerTag)) {
628 if (isDescendantOfElementType(getLandmarkRolesNotAllowed())) 630 if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 // A generic element with tabIndex explicitly set gets GroupRole. 683 // A generic element with tabIndex explicitly set gets GroupRole.
682 // The layout checks for focusability aren't critical here; a false 684 // The layout checks for focusability aren't critical here; a false
683 // positive would be harmless. 685 // positive would be harmless.
684 if (element->isInCanvasSubtree() && element->supportsFocus()) 686 if (element->isInCanvasSubtree() && element->supportsFocus())
685 return GroupRole; 687 return GroupRole;
686 } 688 }
687 return UnknownRole; 689 return UnknownRole;
688 } 690 }
689 691
690 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const { 692 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const {
691 const AtomicString& ariaRole = getAttribute(roleAttr); 693 const AtomicString& ariaRole =
694 getAomPropertyOrAriaAttribute(AomStringProperty::Role);
692 if (ariaRole.isNull() || ariaRole.isEmpty()) 695 if (ariaRole.isNull() || ariaRole.isEmpty())
693 return UnknownRole; 696 return UnknownRole;
694 697
695 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); 698 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole);
696 699
697 // 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.
698 if ((role == NoneRole || role == PresentationalRole) && 701 if ((role == NoneRole || role == PresentationalRole) &&
699 canSetFocusAttribute()) 702 canSetFocusAttribute())
700 return UnknownRole; 703 return UnknownRole;
701 704
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 if (isHiddenForTextAlternativeCalculation()) 1895 if (isHiddenForTextAlternativeCalculation())
1893 return false; 1896 return false;
1894 1897
1895 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 1898 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1
1896 HeapVector<Member<Element>> elements; 1899 HeapVector<Member<Element>> elements;
1897 ariaLabelledbyElementVector(elements); 1900 ariaLabelledbyElementVector(elements);
1898 if (elements.size() > 0) 1901 if (elements.size() > 0)
1899 return false; 1902 return false;
1900 1903
1901 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 1904 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1
1902 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); 1905 const AtomicString& ariaLabel =
1906 getAomPropertyOrAriaAttribute(AomStringProperty::Label);
1903 if (!ariaLabel.isEmpty()) 1907 if (!ariaLabel.isEmpty())
1904 return false; 1908 return false;
1905 1909
1906 // Based on 1910 // Based on
1907 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an d-description-calculation 1911 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-an d-description-calculation
1908 // 5.1/5.5 Text inputs, Other labelable Elements 1912 // 5.1/5.5 Text inputs, Other labelable Elements
1909 HTMLElement* htmlElement = nullptr; 1913 HTMLElement* htmlElement = nullptr;
1910 if (getNode()->isHTMLElement()) 1914 if (getNode()->isHTMLElement())
1911 htmlElement = toHTMLElement(getNode()); 1915 htmlElement = toHTMLElement(getNode());
1912 if (htmlElement && isLabelableElement(htmlElement)) { 1916 if (htmlElement && isLabelableElement(htmlElement)) {
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 if (isWebArea()) { 2830 if (isWebArea()) {
2827 Document* document = this->getDocument(); 2831 Document* document = this->getDocument();
2828 if (document) { 2832 if (document) {
2829 nameFrom = AXNameFromAttribute; 2833 nameFrom = AXNameFromAttribute;
2830 if (nameSources) { 2834 if (nameSources) {
2831 nameSources->push_back( 2835 nameSources->push_back(
2832 NameSource(foundTextAlternative, aria_labelAttr)); 2836 NameSource(foundTextAlternative, aria_labelAttr));
2833 nameSources->back().type = nameFrom; 2837 nameSources->back().type = nameFrom;
2834 } 2838 }
2835 if (Element* documentElement = document->documentElement()) { 2839 if (Element* documentElement = document->documentElement()) {
2840 AXObject* axDocument = axObjectCache().getOrCreate(documentElement);
2841 DCHECK(axDocument);
2836 const AtomicString& ariaLabel = 2842 const AtomicString& ariaLabel =
2837 documentElement->getAttribute(aria_labelAttr); 2843 axDocument->getAomPropertyOrAriaAttribute(AomStringProperty::Label);
2838 if (!ariaLabel.isEmpty()) { 2844 if (!ariaLabel.isEmpty()) {
2839 textAlternative = ariaLabel; 2845 textAlternative = ariaLabel;
2840 2846
2841 if (nameSources) { 2847 if (nameSources) {
2842 NameSource& source = nameSources->back(); 2848 NameSource& source = nameSources->back();
2843 source.text = textAlternative; 2849 source.text = textAlternative;
2844 source.attributeValue = ariaLabel; 2850 source.attributeValue = ariaLabel;
2845 *foundTextAlternative = true; 2851 *foundTextAlternative = true;
2846 } else { 2852 } else {
2847 return textAlternative; 2853 return textAlternative;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 return String(); 3120 return String();
3115 return toTextControlElement(node)->strippedPlaceholder(); 3121 return toTextControlElement(node)->strippedPlaceholder();
3116 } 3122 }
3117 3123
3118 DEFINE_TRACE(AXNodeObject) { 3124 DEFINE_TRACE(AXNodeObject) {
3119 visitor->trace(m_node); 3125 visitor->trace(m_node);
3120 AXObject::trace(visitor); 3126 AXObject::trace(visitor);
3121 } 3127 }
3122 3128
3123 } // namespace blink 3129 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698