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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return true; | 170 return true; |
171 | 171 |
172 // Ignore labels that are already referenced by a control's title UI element
. | 172 // Ignore labels that are already referenced by a control's title UI element
. |
173 AXObject* controlObject = correspondingControlForLabelElement(); | 173 AXObject* controlObject = correspondingControlForLabelElement(); |
174 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec
t->isCheckboxOrRadio()) | 174 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec
t->isCheckboxOrRadio()) |
175 return true; | 175 return true; |
176 | 176 |
177 return m_role == UnknownRole; | 177 return m_role == UnknownRole; |
178 } | 178 } |
179 | 179 |
180 AccessibilityRole AXNodeObject::determineAccessibilityRole() | 180 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil() |
181 { | 181 { |
182 if (!node()) | 182 if (!node()) |
183 return UnknownRole; | 183 return UnknownRole; |
184 | |
185 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) | |
186 return m_ariaRole; | |
187 | |
188 if (node()->isLink()) | 184 if (node()->isLink()) |
189 return LinkRole; | 185 return LinkRole; |
190 if (node()->isTextNode()) | |
191 return StaticTextRole; | |
192 if (isHTMLButtonElement(*node())) | 186 if (isHTMLButtonElement(*node())) |
193 return buttonRoleType(); | 187 return buttonRoleType(); |
194 if (isHTMLDetailsElement(*node())) | 188 if (isHTMLDetailsElement(*node())) |
195 return DetailsRole; | 189 return DetailsRole; |
196 if (isHTMLSummaryElement(*node())) { | 190 if (isHTMLSummaryElement(*node())) { |
197 if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode())) | 191 if (node()->parentNode() && isHTMLDetailsElement(node()->parentNode())) |
198 return DisclosureTriangleRole; | 192 return DisclosureTriangleRole; |
199 return UnknownRole; | 193 return UnknownRole; |
200 } | 194 } |
201 | 195 |
202 if (isHTMLInputElement(*node())) { | 196 if (isHTMLInputElement(*node())) { |
203 HTMLInputElement& input = toHTMLInputElement(*node()); | 197 HTMLInputElement& input = toHTMLInputElement(*node()); |
204 const AtomicString& type = input.type(); | 198 const AtomicString& type = input.type(); |
| 199 if (input.dataList()) |
| 200 return ComboBoxRole; |
205 if (type == InputTypeNames::button) { | 201 if (type == InputTypeNames::button) { |
206 if ((node()->parentNode() && isHTMLMenuElement(node()->parentNode())
) || (parentObject() && parentObject()->roleValue() == MenuRole)) | 202 if ((node()->parentNode() && isHTMLMenuElement(node()->parentNode())
) || (parentObject() && parentObject()->roleValue() == MenuRole)) |
207 return MenuItemRole; | 203 return MenuItemRole; |
208 return buttonRoleType(); | 204 return buttonRoleType(); |
209 } | 205 } |
210 if (type == InputTypeNames::checkbox) { | 206 if (type == InputTypeNames::checkbox) { |
211 if ((node()->parentNode() && isHTMLMenuElement(node()->parentNode())
) || (parentObject() && parentObject()->roleValue() == MenuRole)) | 207 if ((node()->parentNode() && isHTMLMenuElement(node()->parentNode())
) || (parentObject() && parentObject()->roleValue() == MenuRole)) |
212 return MenuItemCheckBoxRole; | 208 return MenuItemCheckBoxRole; |
213 return CheckBoxRole; | 209 return CheckBoxRole; |
214 } | 210 } |
215 if (type == InputTypeNames::date) | 211 if (type == InputTypeNames::date) |
216 return DateRole; | 212 return DateRole; |
217 if (type == InputTypeNames::datetime | 213 if (type == InputTypeNames::datetime |
218 || type == InputTypeNames::datetime_local | 214 || type == InputTypeNames::datetime_local |
219 || type == InputTypeNames::month | 215 || type == InputTypeNames::month |
220 || type == InputTypeNames::week) | 216 || type == InputTypeNames::week) |
221 return DateTimeRole; | 217 return DateTimeRole; |
| 218 if (type == InputTypeNames::file) |
| 219 return ButtonRole; |
222 if (type == InputTypeNames::radio) { | 220 if (type == InputTypeNames::radio) { |
223 if ((node()->parentNode() && isHTMLMenuElement(node()->parentNode())
) || (parentObject() && parentObject()->roleValue() == MenuRole)) | 221 if ((node()->parentNode() && isHTMLMenuElement(node()->parentNode())
) || (parentObject() && parentObject()->roleValue() == MenuRole)) |
224 return MenuItemRadioRole; | 222 return MenuItemRadioRole; |
225 return RadioButtonRole; | 223 return RadioButtonRole; |
226 } | 224 } |
227 if (type == InputTypeNames::number) | 225 if (type == InputTypeNames::number) |
228 return SpinButtonRole; | 226 return SpinButtonRole; |
229 if (input.isTextButton()) | 227 if (input.isTextButton()) |
230 return buttonRoleType(); | 228 return buttonRoleType(); |
231 if (type == InputTypeNames::range) | 229 if (type == InputTypeNames::range) |
(...skipping 25 matching lines...) Expand all Loading... |
257 if (isHTMLRubyElement(*node())) | 255 if (isHTMLRubyElement(*node())) |
258 return RubyRole; | 256 return RubyRole; |
259 if (isHTMLDListElement(*node())) | 257 if (isHTMLDListElement(*node())) |
260 return DescriptionListRole; | 258 return DescriptionListRole; |
261 if (node()->isElementNode() && node()->hasTagName(blockquoteTag)) | 259 if (node()->isElementNode() && node()->hasTagName(blockquoteTag)) |
262 return BlockquoteRole; | 260 return BlockquoteRole; |
263 if (node()->isElementNode() && node()->hasTagName(figcaptionTag)) | 261 if (node()->isElementNode() && node()->hasTagName(figcaptionTag)) |
264 return FigcaptionRole; | 262 return FigcaptionRole; |
265 if (node()->isElementNode() && node()->hasTagName(figureTag)) | 263 if (node()->isElementNode() && node()->hasTagName(figureTag)) |
266 return FigureRole; | 264 return FigureRole; |
267 if (node()->isElementNode() && toElement(node())->isFocusable()) | |
268 return GroupRole; | |
269 if (isHTMLAnchorElement(*node()) && isClickable()) | 265 if (isHTMLAnchorElement(*node()) && isClickable()) |
270 return LinkRole; | 266 return LinkRole; |
271 if (isHTMLIFrameElement(*node())) | 267 if (isHTMLIFrameElement(*node())) |
272 return IframeRole; | 268 return IframeRole; |
273 if (isEmbeddedObject()) | 269 if (isEmbeddedObject()) |
274 return EmbeddedObjectRole; | 270 return EmbeddedObjectRole; |
275 | |
276 return UnknownRole; | 271 return UnknownRole; |
277 } | 272 } |
278 | 273 |
| 274 AccessibilityRole AXNodeObject::determineAccessibilityRole() |
| 275 { |
| 276 if (!node()) |
| 277 return UnknownRole; |
| 278 |
| 279 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) |
| 280 return m_ariaRole; |
| 281 if (node()->isTextNode()) |
| 282 return StaticTextRole; |
| 283 |
| 284 AccessibilityRole role = determineAccessibilityRoleUtil(); |
| 285 if (role != UnknownRole) |
| 286 return role; |
| 287 if (node()->isElementNode() && toElement(node())->isFocusable()) |
| 288 return GroupRole; |
| 289 return UnknownRole; |
| 290 } |
| 291 |
279 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const | 292 AccessibilityRole AXNodeObject::determineAriaRoleAttribute() const |
280 { | 293 { |
281 const AtomicString& ariaRole = getAttribute(roleAttr); | 294 const AtomicString& ariaRole = getAttribute(roleAttr); |
282 if (ariaRole.isNull() || ariaRole.isEmpty()) | 295 if (ariaRole.isNull() || ariaRole.isEmpty()) |
283 return UnknownRole; | 296 return UnknownRole; |
284 | 297 |
285 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); | 298 AccessibilityRole role = ariaRoleToWebCoreRole(ariaRole); |
286 | 299 |
287 // ARIA states if an item can get focus, it should not be presentational. | 300 // ARIA states if an item can get focus, it should not be presentational. |
288 if ((role == NoneRole || role == PresentationalRole) && canSetFocusAttribute
()) | 301 if ((role == NoneRole || role == PresentationalRole) && canSetFocusAttribute
()) |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 | 1630 |
1618 HTMLLabelElement* AXNodeObject::labelElementContainer() const | 1631 HTMLLabelElement* AXNodeObject::labelElementContainer() const |
1619 { | 1632 { |
1620 if (!node()) | 1633 if (!node()) |
1621 return 0; | 1634 return 0; |
1622 | 1635 |
1623 // the control element should not be considered part of the label | 1636 // the control element should not be considered part of the label |
1624 if (isControl()) | 1637 if (isControl()) |
1625 return 0; | 1638 return 0; |
1626 | 1639 |
| 1640 // the link element should not be considered part of the label |
| 1641 if (isLink()) |
| 1642 return 0; |
| 1643 |
1627 // find if this has a ancestor that is a label | 1644 // find if this has a ancestor that is a label |
1628 return Traversal<HTMLLabelElement>::firstAncestorOrSelf(*node()); | 1645 return Traversal<HTMLLabelElement>::firstAncestorOrSelf(*node()); |
1629 } | 1646 } |
1630 | 1647 |
1631 void AXNodeObject::setFocused(bool on) | 1648 void AXNodeObject::setFocused(bool on) |
1632 { | 1649 { |
1633 if (!canSetFocusAttribute()) | 1650 if (!canSetFocusAttribute()) |
1634 return; | 1651 return; |
1635 | 1652 |
1636 Document* document = this->document(); | 1653 Document* document = this->document(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 float range = maxValueForRange() - minValueForRange(); | 1837 float range = maxValueForRange() - minValueForRange(); |
1821 float value = valueForRange(); | 1838 float value = valueForRange(); |
1822 | 1839 |
1823 value += range * (percentChange / 100); | 1840 value += range * (percentChange / 100); |
1824 setValue(String::number(value)); | 1841 setValue(String::number(value)); |
1825 | 1842 |
1826 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged,
true); | 1843 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged,
true); |
1827 } | 1844 } |
1828 | 1845 |
1829 } // namespace blink | 1846 } // namespace blink |
OLD | NEW |