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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 float value = valueForRange(); | 137 float value = valueForRange(); |
| 138 float step = stepValueForRange(); | 138 float step = stepValueForRange(); |
| 139 | 139 |
| 140 value += increase ? step : -step; | 140 value += increase ? step : -step; |
| 141 | 141 |
| 142 setValue(String::number(value)); | 142 setValue(String::number(value)); |
| 143 axObjectCache().postNotification(getNode(), AXObjectCacheImpl::AXValueChange d); | 143 axObjectCache().postNotification(getNode(), AXObjectCacheImpl::AXValueChange d); |
| 144 } | 144 } |
| 145 | 145 |
| 146 AXObject* AXNodeObject::activeDescendant() const | |
| 147 { | |
| 148 if (!getNode() || !getNode()->isElementNode()) | |
| 149 return nullptr; | |
| 150 | |
| 151 const AtomicString& activeDescendantAttr = getAttribute(aria_activedescendan tAttr); | |
| 152 if (activeDescendantAttr.isNull() || activeDescendantAttr.isEmpty()) | |
| 153 return nullptr; | |
| 154 | |
| 155 Element* element = toElement(getNode()); | |
| 156 Element* descendant = element->treeScope().getElementById(activeDescendantAt tr); | |
| 157 if (!descendant) | |
| 158 return nullptr; | |
| 159 | |
| 160 AXObject* axDescendant = axObjectCache().getOrCreate(descendant); | |
| 161 // An active descendant is only useful if it has a layoutObject, because tha t's what's needed to post the notification. | |
|
dmazzoni
2016/04/05 05:37:22
You can post a notification on any AXObject, so th
| |
| 162 if (axDescendant && axDescendant->isAXLayoutObject()) | |
| 163 return axDescendant; | |
| 164 | |
| 165 return nullptr; | |
| 166 } | |
| 167 | |
| 146 String AXNodeObject::ariaAccessibilityDescription() const | 168 String AXNodeObject::ariaAccessibilityDescription() const |
| 147 { | 169 { |
| 148 String ariaLabelledby = ariaLabelledbyAttribute(); | 170 String ariaLabelledby = ariaLabelledbyAttribute(); |
| 149 if (!ariaLabelledby.isEmpty()) | 171 if (!ariaLabelledby.isEmpty()) |
| 150 return ariaLabelledby; | 172 return ariaLabelledby; |
| 151 | 173 |
| 152 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 174 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 153 if (!ariaLabel.isEmpty()) | 175 if (!ariaLabel.isEmpty()) |
| 154 return ariaLabel; | 176 return ariaLabel; |
| 155 | 177 |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 return toHTMLFormControlElement(n)->isRequired(); | 1080 return toHTMLFormControlElement(n)->isRequired(); |
| 1059 | 1081 |
| 1060 if (equalIgnoringCase(getAttribute(aria_requiredAttr), "true")) | 1082 if (equalIgnoringCase(getAttribute(aria_requiredAttr), "true")) |
| 1061 return true; | 1083 return true; |
| 1062 | 1084 |
| 1063 return false; | 1085 return false; |
| 1064 } | 1086 } |
| 1065 | 1087 |
| 1066 bool AXNodeObject::canSetFocusAttribute() const | 1088 bool AXNodeObject::canSetFocusAttribute() const |
| 1067 { | 1089 { |
| 1068 Node* node = this->getNode(); | 1090 Node* node = getNode(); |
| 1069 if (!node) | 1091 if (!node) |
| 1070 return false; | 1092 return false; |
| 1071 | 1093 |
| 1072 if (isWebArea()) | 1094 if (isWebArea()) |
| 1073 return true; | 1095 return true; |
| 1074 | 1096 |
| 1097 // Children of elements with an aria-activedescendant attribute should be | |
| 1098 // focusable if they have an ARIA role. | |
| 1099 if (ariaRoleAttribute() != UnknownRole && ancestorExposesActiveDescendant()) | |
| 1100 return true; | |
| 1101 | |
| 1075 // NOTE: It would be more accurate to ask the document whether setFocusedNod e() would | 1102 // NOTE: It would be more accurate to ask the document whether setFocusedNod e() would |
| 1076 // do anything. For example, setFocusedNode() will do nothing if the current focused | 1103 // do anything. For example, setFocusedNode() will do nothing if the current focused |
| 1077 // node will not relinquish the focus. | 1104 // node will not relinquish the focus. |
| 1078 if (!node) | |
| 1079 return false; | |
| 1080 | |
| 1081 if (isDisabledFormControl(node)) | 1105 if (isDisabledFormControl(node)) |
| 1082 return false; | 1106 return false; |
| 1083 | 1107 |
| 1084 return node->isElementNode() && toElement(node)->supportsFocus(); | 1108 return node->isElementNode() && toElement(node)->supportsFocus(); |
| 1085 } | 1109 } |
| 1086 | 1110 |
| 1087 bool AXNodeObject::canSetValueAttribute() const | 1111 bool AXNodeObject::canSetValueAttribute() const |
| 1088 { | 1112 { |
| 1089 if (equalIgnoringCase(getAttribute(aria_readonlyAttr), "true")) | 1113 if (equalIgnoringCase(getAttribute(aria_readonlyAttr), "true")) |
| 1090 return false; | 1114 return false; |
| 1091 | 1115 |
| 1092 if (isProgressIndicator() || isSlider()) | 1116 if (isProgressIndicator() || isSlider()) |
| 1093 return true; | 1117 return true; |
| 1094 | 1118 |
| 1095 if (isTextControl() && !isNativeTextControl()) | 1119 if (isTextControl() && !isNativeTextControl()) |
| 1096 return true; | 1120 return true; |
| 1097 | 1121 |
| 1098 // Any node could be contenteditable, so isReadOnly should be relied upon | 1122 // Any node could be contenteditable, so isReadOnly should be relied upon |
| 1099 // for this information for all elements. | 1123 // for this information for all elements. |
| 1100 return !isReadOnly(); | 1124 return !isReadOnly(); |
| 1101 } | 1125 } |
| 1102 | 1126 |
| 1127 bool AXNodeObject::canSetSelectedAttribute() const | |
| 1128 { | |
| 1129 // ARIA list box options can be selected if they are children of an element | |
| 1130 // with an aria-activedescendant attribute. | |
| 1131 if (ariaRoleAttribute() == ListBoxOptionRole && ancestorExposesActiveDescend ant()) | |
| 1132 return true; | |
| 1133 return AXObject::canSetSelectedAttribute(); | |
| 1134 } | |
| 1135 | |
| 1103 bool AXNodeObject::canvasHasFallbackContent() const | 1136 bool AXNodeObject::canvasHasFallbackContent() const |
| 1104 { | 1137 { |
| 1105 Node* node = this->getNode(); | 1138 Node* node = this->getNode(); |
| 1106 if (!isHTMLCanvasElement(node)) | 1139 if (!isHTMLCanvasElement(node)) |
| 1107 return false; | 1140 return false; |
| 1108 | 1141 |
| 1109 // If it has any children that are elements, we'll assume it might be fallba ck | 1142 // If it has any children that are elements, we'll assume it might be fallba ck |
| 1110 // content. If it has no children or its only children are not elements | 1143 // content. If it has no children or its only children are not elements |
| 1111 // (e.g. just text nodes), it doesn't have fallback content. | 1144 // (e.g. just text nodes), it doesn't have fallback content. |
| 1112 return ElementTraversal::firstChild(*node); | 1145 return ElementTraversal::firstChild(*node); |
| (...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2759 return placeholder; | 2792 return placeholder; |
| 2760 } | 2793 } |
| 2761 | 2794 |
| 2762 DEFINE_TRACE(AXNodeObject) | 2795 DEFINE_TRACE(AXNodeObject) |
| 2763 { | 2796 { |
| 2764 visitor->trace(m_node); | 2797 visitor->trace(m_node); |
| 2765 AXObject::trace(visitor); | 2798 AXObject::trace(visitor); |
| 2766 } | 2799 } |
| 2767 | 2800 |
| 2768 } // namespace blink | 2801 } // namespace blink |
| OLD | NEW |