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 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(); |
|
dmazzoni
2015/04/10 17:14:28
It looks like stepValueForRange is implemented nai
| |
| 133 else | 133 |
| 134 changeValueByPercent(increase ? 5 : -5); | 134 if (getAttribute(stepAttr).isEmpty()) { |
| 135 const float percentChange = 5; | |
| 136 float range = maxValueForRange() - minValueForRange(); | |
| 137 step = range * (percentChange / 100); | |
| 138 if (step < 1) | |
| 139 step = 1; | |
| 140 } | |
| 141 | |
| 142 value += increase ? step : -step; | |
| 143 setValue(String::number(value)); | |
| 144 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged) ; | |
| 135 } | 145 } |
| 136 | 146 |
| 137 String AXNodeObject::ariaAccessibilityDescription() const | 147 String AXNodeObject::ariaAccessibilityDescription() const |
| 138 { | 148 { |
| 139 String ariaLabeledBy = ariaLabeledByAttribute(); | 149 String ariaLabeledBy = ariaLabeledByAttribute(); |
| 140 if (!ariaLabeledBy.isEmpty()) | 150 if (!ariaLabeledBy.isEmpty()) |
| 141 return ariaLabeledBy; | 151 return ariaLabeledBy; |
| 142 | 152 |
| 143 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 153 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 144 if (!ariaLabel.isEmpty()) | 154 if (!ariaLabel.isEmpty()) |
| 145 return ariaLabel; | 155 return ariaLabel; |
| 146 | 156 |
| 147 return String(); | 157 return String(); |
| 148 } | 158 } |
| 149 | 159 |
| 150 | 160 |
| 151 void AXNodeObject::ariaLabeledByElements(WillBeHeapVector<RawPtrWillBeMember<Ele ment>>& elements) const | 161 void AXNodeObject::ariaLabeledByElements(WillBeHeapVector<RawPtrWillBeMember<Ele ment>>& elements) const |
| 152 { | 162 { |
| 153 elementsFromAttribute(elements, aria_labeledbyAttr); | 163 elementsFromAttribute(elements, aria_labeledbyAttr); |
| 154 if (!elements.size()) | 164 if (!elements.size()) |
| 155 elementsFromAttribute(elements, aria_labelledbyAttr); | 165 elementsFromAttribute(elements, aria_labelledbyAttr); |
| 156 } | 166 } |
| 157 | 167 |
| 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 | 168 bool AXNodeObject::computeAccessibilityIsIgnored() const |
| 171 { | 169 { |
| 172 #if ENABLE(ASSERT) | 170 #if ENABLE(ASSERT) |
| 173 // Double-check that an AXObject is never accessed before | 171 // Double-check that an AXObject is never accessed before |
| 174 // it's been initialized. | 172 // it's been initialized. |
| 175 ASSERT(m_initialized); | 173 ASSERT(m_initialized); |
| 176 #endif | 174 #endif |
| 177 | 175 |
| 178 // If this element is within a parent that cannot have children, it should n ot be exposed. | 176 // If this element is within a parent that cannot have children, it should n ot be exposed. |
| 179 if (isDescendantOfBarrenParent()) | 177 if (isDescendantOfBarrenParent()) |
| (...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2070 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 2068 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; |
| 2071 ariaLabeledByElements(elements); | 2069 ariaLabeledByElements(elements); |
| 2072 | 2070 |
| 2073 for (const auto& element : elements) { | 2071 for (const auto& element : elements) { |
| 2074 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); | 2072 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); |
| 2075 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a xElement)); | 2073 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a xElement)); |
| 2076 } | 2074 } |
| 2077 } | 2075 } |
| 2078 } | 2076 } |
| 2079 | 2077 |
| 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 | 2078 } // namespace blink |
| OLD | NEW |