| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 121             builder.append(' '); | 121             builder.append(' '); | 
| 122     } | 122     } | 
| 123     return builder.toString(); | 123     return builder.toString(); | 
| 124 } | 124 } | 
| 125 | 125 | 
| 126 void AXNodeObject::alterSliderValue(bool increase) | 126 void AXNodeObject::alterSliderValue(bool increase) | 
| 127 { | 127 { | 
| 128     if (roleValue() != SliderRole) | 128     if (roleValue() != SliderRole) | 
| 129         return; | 129         return; | 
| 130 | 130 | 
| 131     if (!getAttribute(stepAttr).isEmpty()) | 131     float value = valueForRange(); | 
| 132         changeValueByStep(increase); | 132     float step = stepValueForRange(); | 
| 133     else | 133 | 
| 134         changeValueByPercent(increase ? 5 : -5); | 134     value += increase ? step : -step; | 
|  | 135 | 
|  | 136     setValue(String::number(value)); | 
|  | 137     axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged)
      ; | 
| 135 } | 138 } | 
| 136 | 139 | 
| 137 String AXNodeObject::ariaAccessibilityDescription() const | 140 String AXNodeObject::ariaAccessibilityDescription() const | 
| 138 { | 141 { | 
| 139     String ariaLabeledBy = ariaLabeledByAttribute(); | 142     String ariaLabeledBy = ariaLabeledByAttribute(); | 
| 140     if (!ariaLabeledBy.isEmpty()) | 143     if (!ariaLabeledBy.isEmpty()) | 
| 141         return ariaLabeledBy; | 144         return ariaLabeledBy; | 
| 142 | 145 | 
| 143     const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 146     const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 
| 144     if (!ariaLabel.isEmpty()) | 147     if (!ariaLabel.isEmpty()) | 
| 145         return ariaLabel; | 148         return ariaLabel; | 
| 146 | 149 | 
| 147     return String(); | 150     return String(); | 
| 148 } | 151 } | 
| 149 | 152 | 
| 150 | 153 | 
| 151 void AXNodeObject::ariaLabeledByElements(WillBeHeapVector<RawPtrWillBeMember<Ele
      ment>>& elements) const | 154 void AXNodeObject::ariaLabeledByElements(WillBeHeapVector<RawPtrWillBeMember<Ele
      ment>>& elements) const | 
| 152 { | 155 { | 
| 153     elementsFromAttribute(elements, aria_labeledbyAttr); | 156     elementsFromAttribute(elements, aria_labeledbyAttr); | 
| 154     if (!elements.size()) | 157     if (!elements.size()) | 
| 155         elementsFromAttribute(elements, aria_labelledbyAttr); | 158         elementsFromAttribute(elements, aria_labelledbyAttr); | 
| 156 } | 159 } | 
| 157 | 160 | 
| 158 void AXNodeObject::changeValueByStep(bool increase) |  | 
| 159 { |  | 
| 160     float step = stepValueForRange(); |  | 
| 161     float value = valueForRange(); |  | 
| 162 |  | 
| 163     value += increase ? step : -step; |  | 
| 164 |  | 
| 165     setValue(String::number(value)); |  | 
| 166 |  | 
| 167     axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged)
      ; |  | 
| 168 } |  | 
| 169 |  | 
| 170 bool AXNodeObject::computeAccessibilityIsIgnored() const | 161 bool AXNodeObject::computeAccessibilityIsIgnored() const | 
| 171 { | 162 { | 
| 172 #if ENABLE(ASSERT) | 163 #if ENABLE(ASSERT) | 
| 173     // Double-check that an AXObject is never accessed before | 164     // Double-check that an AXObject is never accessed before | 
| 174     // it's been initialized. | 165     // it's been initialized. | 
| 175     ASSERT(m_initialized); | 166     ASSERT(m_initialized); | 
| 176 #endif | 167 #endif | 
| 177 | 168 | 
| 178     // If this element is within a parent that cannot have children, it should n
      ot be exposed. | 169     // If this element is within a parent that cannot have children, it should n
      ot be exposed. | 
| 179     if (isDescendantOfBarrenParent()) | 170     if (isDescendantOfBarrenParent()) | 
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 763 bool AXNodeObject::isProgressIndicator() const | 754 bool AXNodeObject::isProgressIndicator() const | 
| 764 { | 755 { | 
| 765     return roleValue() == ProgressIndicatorRole; | 756     return roleValue() == ProgressIndicatorRole; | 
| 766 } | 757 } | 
| 767 | 758 | 
| 768 bool AXNodeObject::isSlider() const | 759 bool AXNodeObject::isSlider() const | 
| 769 { | 760 { | 
| 770     return roleValue() == SliderRole; | 761     return roleValue() == SliderRole; | 
| 771 } | 762 } | 
| 772 | 763 | 
|  | 764 bool AXNodeObject::isNativeSlider() const | 
|  | 765 { | 
|  | 766     Node* node = this->node(); | 
|  | 767     if (!node) | 
|  | 768         return false; | 
|  | 769 | 
|  | 770     if (!isHTMLInputElement(node)) | 
|  | 771         return false; | 
|  | 772 | 
|  | 773     return toHTMLInputElement(node)->type() == InputTypeNames::range; | 
|  | 774 } | 
|  | 775 | 
| 773 bool AXNodeObject::isChecked() const | 776 bool AXNodeObject::isChecked() const | 
| 774 { | 777 { | 
| 775     Node* node = this->node(); | 778     Node* node = this->node(); | 
| 776     if (!node) | 779     if (!node) | 
| 777         return false; | 780         return false; | 
| 778 | 781 | 
| 779     // First test for native checkedness semantics | 782     // First test for native checkedness semantics | 
| 780     if (isHTMLInputElement(*node)) | 783     if (isHTMLInputElement(*node)) | 
| 781         return toHTMLInputElement(*node).shouldAppearChecked(); | 784         return toHTMLInputElement(*node).shouldAppearChecked(); | 
| 782 | 785 | 
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1203         return toHTMLMeterElement(*node()).value(); | 1206         return toHTMLMeterElement(*node()).value(); | 
| 1204 | 1207 | 
| 1205     return 0.0; | 1208     return 0.0; | 
| 1206 } | 1209 } | 
| 1207 | 1210 | 
| 1208 float AXNodeObject::maxValueForRange() const | 1211 float AXNodeObject::maxValueForRange() const | 
| 1209 { | 1212 { | 
| 1210     if (hasAttribute(aria_valuemaxAttr)) | 1213     if (hasAttribute(aria_valuemaxAttr)) | 
| 1211         return getAttribute(aria_valuemaxAttr).toFloat(); | 1214         return getAttribute(aria_valuemaxAttr).toFloat(); | 
| 1212 | 1215 | 
| 1213     if (isHTMLInputElement(node())) { | 1216     if (isNativeSlider()) | 
| 1214         HTMLInputElement& input = toHTMLInputElement(*node()); | 1217         return toHTMLInputElement(*node()).maximum(); | 
| 1215         if (input.type() == InputTypeNames::range) |  | 
| 1216             return input.maximum(); |  | 
| 1217     } |  | 
| 1218 | 1218 | 
| 1219     if (isHTMLMeterElement(node())) | 1219     if (isHTMLMeterElement(node())) | 
| 1220         return toHTMLMeterElement(*node()).max(); | 1220         return toHTMLMeterElement(*node()).max(); | 
| 1221 | 1221 | 
| 1222     return 0.0; | 1222     return 0.0; | 
| 1223 } | 1223 } | 
| 1224 | 1224 | 
| 1225 float AXNodeObject::minValueForRange() const | 1225 float AXNodeObject::minValueForRange() const | 
| 1226 { | 1226 { | 
| 1227     if (hasAttribute(aria_valueminAttr)) | 1227     if (hasAttribute(aria_valueminAttr)) | 
| 1228         return getAttribute(aria_valueminAttr).toFloat(); | 1228         return getAttribute(aria_valueminAttr).toFloat(); | 
| 1229 | 1229 | 
| 1230     if (isHTMLInputElement(node())) { | 1230     if (isNativeSlider()) | 
| 1231         HTMLInputElement& input = toHTMLInputElement(*node()); | 1231         return toHTMLInputElement(*node()).minimum(); | 
| 1232         if (input.type() == InputTypeNames::range) |  | 
| 1233             return input.minimum(); |  | 
| 1234     } |  | 
| 1235 | 1232 | 
| 1236     if (isHTMLMeterElement(node())) | 1233     if (isHTMLMeterElement(node())) | 
| 1237         return toHTMLMeterElement(*node()).min(); | 1234         return toHTMLMeterElement(*node()).min(); | 
| 1238 | 1235 | 
| 1239     return 0.0; | 1236     return 0.0; | 
| 1240 } | 1237 } | 
| 1241 | 1238 | 
| 1242 float AXNodeObject::stepValueForRange() const | 1239 float AXNodeObject::stepValueForRange() const | 
| 1243 { | 1240 { | 
| 1244     return getAttribute(stepAttr).toFloat(); | 1241     if (!isNativeSlider()) | 
|  | 1242         return 0.0; | 
|  | 1243 | 
|  | 1244     Decimal step = toHTMLInputElement(*node()).createStepRange(RejectAny).step()
      ; | 
|  | 1245     return step.toString().toFloat(); | 
| 1245 } | 1246 } | 
| 1246 | 1247 | 
| 1247 String AXNodeObject::stringValue() const | 1248 String AXNodeObject::stringValue() const | 
| 1248 { | 1249 { | 
| 1249     Node* node = this->node(); | 1250     Node* node = this->node(); | 
| 1250     if (!node) | 1251     if (!node) | 
| 1251         return String(); | 1252         return String(); | 
| 1252 | 1253 | 
| 1253     if (ariaRoleAttribute() == StaticTextRole) { | 1254     if (ariaRoleAttribute() == StaticTextRole) { | 
| 1254         String staticText = text(); | 1255         String staticText = text(); | 
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2070         WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 2071         WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 
| 2071         ariaLabeledByElements(elements); | 2072         ariaLabeledByElements(elements); | 
| 2072 | 2073 | 
| 2073         for (const auto& element : elements) { | 2074         for (const auto& element : elements) { | 
| 2074             RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); | 2075             RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); | 
| 2075             textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
      xElement)); | 2076             textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
      xElement)); | 
| 2076         } | 2077         } | 
| 2077     } | 2078     } | 
| 2078 } | 2079 } | 
| 2079 | 2080 | 
| 2080 void AXNodeObject::changeValueByPercent(float percentChange) |  | 
| 2081 { |  | 
| 2082     float range = maxValueForRange() - minValueForRange(); |  | 
| 2083     float value = valueForRange(); |  | 
| 2084 |  | 
| 2085     value += range * (percentChange / 100); |  | 
| 2086     setValue(String::number(value)); |  | 
| 2087 |  | 
| 2088     axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged)
      ; |  | 
| 2089 } |  | 
| 2090 |  | 
| 2091 } // namespace blink | 2081 } // namespace blink | 
| OLD | NEW | 
|---|