| 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 return axDescendant; |
| 162 } |
| 163 |
| 146 String AXNodeObject::ariaAccessibilityDescription() const | 164 String AXNodeObject::ariaAccessibilityDescription() const |
| 147 { | 165 { |
| 148 String ariaLabelledby = ariaLabelledbyAttribute(); | 166 String ariaLabelledby = ariaLabelledbyAttribute(); |
| 149 if (!ariaLabelledby.isEmpty()) | 167 if (!ariaLabelledby.isEmpty()) |
| 150 return ariaLabelledby; | 168 return ariaLabelledby; |
| 151 | 169 |
| 152 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 170 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 153 if (!ariaLabel.isEmpty()) | 171 if (!ariaLabel.isEmpty()) |
| 154 return ariaLabel; | 172 return ariaLabel; |
| 155 | 173 |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 return toHTMLFormControlElement(n)->isRequired(); | 1076 return toHTMLFormControlElement(n)->isRequired(); |
| 1059 | 1077 |
| 1060 if (equalIgnoringCase(getAttribute(aria_requiredAttr), "true")) | 1078 if (equalIgnoringCase(getAttribute(aria_requiredAttr), "true")) |
| 1061 return true; | 1079 return true; |
| 1062 | 1080 |
| 1063 return false; | 1081 return false; |
| 1064 } | 1082 } |
| 1065 | 1083 |
| 1066 bool AXNodeObject::canSetFocusAttribute() const | 1084 bool AXNodeObject::canSetFocusAttribute() const |
| 1067 { | 1085 { |
| 1068 Node* node = this->getNode(); | 1086 Node* node = getNode(); |
| 1069 if (!node) | 1087 if (!node) |
| 1070 return false; | 1088 return false; |
| 1071 | 1089 |
| 1072 if (isWebArea()) | 1090 if (isWebArea()) |
| 1073 return true; | 1091 return true; |
| 1074 | 1092 |
| 1093 // Children of elements with an aria-activedescendant attribute should be |
| 1094 // focusable if they have an ARIA role. |
| 1095 if (ariaRoleAttribute() != UnknownRole && ancestorExposesActiveDescendant()) |
| 1096 return true; |
| 1097 |
| 1075 // NOTE: It would be more accurate to ask the document whether setFocusedNod
e() would | 1098 // 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 | 1099 // do anything. For example, setFocusedNode() will do nothing if the current
focused |
| 1077 // node will not relinquish the focus. | 1100 // node will not relinquish the focus. |
| 1078 if (!node) | |
| 1079 return false; | |
| 1080 | |
| 1081 if (isDisabledFormControl(node)) | 1101 if (isDisabledFormControl(node)) |
| 1082 return false; | 1102 return false; |
| 1083 | 1103 |
| 1084 return node->isElementNode() && toElement(node)->supportsFocus(); | 1104 return node->isElementNode() && toElement(node)->supportsFocus(); |
| 1085 } | 1105 } |
| 1086 | 1106 |
| 1087 bool AXNodeObject::canSetValueAttribute() const | 1107 bool AXNodeObject::canSetValueAttribute() const |
| 1088 { | 1108 { |
| 1089 if (equalIgnoringCase(getAttribute(aria_readonlyAttr), "true")) | 1109 if (equalIgnoringCase(getAttribute(aria_readonlyAttr), "true")) |
| 1090 return false; | 1110 return false; |
| 1091 | 1111 |
| 1092 if (isProgressIndicator() || isSlider()) | 1112 if (isProgressIndicator() || isSlider()) |
| 1093 return true; | 1113 return true; |
| 1094 | 1114 |
| 1095 if (isTextControl() && !isNativeTextControl()) | 1115 if (isTextControl() && !isNativeTextControl()) |
| 1096 return true; | 1116 return true; |
| 1097 | 1117 |
| 1098 // Any node could be contenteditable, so isReadOnly should be relied upon | 1118 // Any node could be contenteditable, so isReadOnly should be relied upon |
| 1099 // for this information for all elements. | 1119 // for this information for all elements. |
| 1100 return !isReadOnly(); | 1120 return !isReadOnly(); |
| 1101 } | 1121 } |
| 1102 | 1122 |
| 1123 bool AXNodeObject::canSetSelectedAttribute() const |
| 1124 { |
| 1125 // ARIA list box options can be selected if they are children of an element |
| 1126 // with an aria-activedescendant attribute. |
| 1127 if (ariaRoleAttribute() == ListBoxOptionRole && ancestorExposesActiveDescend
ant()) |
| 1128 return true; |
| 1129 return AXObject::canSetSelectedAttribute(); |
| 1130 } |
| 1131 |
| 1103 bool AXNodeObject::canvasHasFallbackContent() const | 1132 bool AXNodeObject::canvasHasFallbackContent() const |
| 1104 { | 1133 { |
| 1105 Node* node = this->getNode(); | 1134 Node* node = this->getNode(); |
| 1106 if (!isHTMLCanvasElement(node)) | 1135 if (!isHTMLCanvasElement(node)) |
| 1107 return false; | 1136 return false; |
| 1108 | 1137 |
| 1109 // If it has any children that are elements, we'll assume it might be fallba
ck | 1138 // 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 | 1139 // 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. | 1140 // (e.g. just text nodes), it doesn't have fallback content. |
| 1112 return ElementTraversal::firstChild(*node); | 1141 return ElementTraversal::firstChild(*node); |
| (...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2759 return placeholder; | 2788 return placeholder; |
| 2760 } | 2789 } |
| 2761 | 2790 |
| 2762 DEFINE_TRACE(AXNodeObject) | 2791 DEFINE_TRACE(AXNodeObject) |
| 2763 { | 2792 { |
| 2764 visitor->trace(m_node); | 2793 visitor->trace(m_node); |
| 2765 AXObject::trace(visitor); | 2794 AXObject::trace(visitor); |
| 2766 } | 2795 } |
| 2767 | 2796 |
| 2768 } // namespace blink | 2797 } // namespace blink |
| OLD | NEW |