OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Apple 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 10 matching lines...) Expand all Loading... |
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "modules/accessibility/AXObject.h" | 30 #include "modules/accessibility/AXObject.h" |
| 31 |
31 #include "core/dom/NodeTraversal.h" | 32 #include "core/dom/NodeTraversal.h" |
32 #include "core/editing/VisibleUnits.h" | 33 #include "core/editing/VisibleUnits.h" |
33 #include "core/editing/htmlediting.h" | 34 #include "core/editing/htmlediting.h" |
34 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
35 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
36 #include "core/layout/LayoutListItem.h" | 37 #include "core/layout/LayoutListItem.h" |
37 #include "core/layout/LayoutTheme.h" | 38 #include "core/layout/LayoutTheme.h" |
38 #include "core/layout/LayoutView.h" | 39 #include "core/layout/LayoutView.h" |
39 #include "modules/accessibility/AXObjectCacheImpl.h" | 40 #include "modules/accessibility/AXObjectCacheImpl.h" |
40 #include "platform/UserGestureIndicator.h" | 41 #include "platform/UserGestureIndicator.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 { "searchbox", SearchBoxRole }, | 110 { "searchbox", SearchBoxRole }, |
110 { "separator", SplitterRole }, | 111 { "separator", SplitterRole }, |
111 { "slider", SliderRole }, | 112 { "slider", SliderRole }, |
112 { "spinbutton", SpinButtonRole }, | 113 { "spinbutton", SpinButtonRole }, |
113 { "status", StatusRole }, | 114 { "status", StatusRole }, |
114 { "switch", SwitchRole }, | 115 { "switch", SwitchRole }, |
115 { "tab", TabRole }, | 116 { "tab", TabRole }, |
116 { "tablist", TabListRole }, | 117 { "tablist", TabListRole }, |
117 { "tabpanel", TabPanelRole }, | 118 { "tabpanel", TabPanelRole }, |
118 { "text", StaticTextRole }, | 119 { "text", StaticTextRole }, |
119 { "textbox", TextFieldRole }, | 120 { "textbox", TextAreaRole }, |
120 { "timer", TimerRole }, | 121 { "timer", TimerRole }, |
121 { "toolbar", ToolbarRole }, | 122 { "toolbar", ToolbarRole }, |
122 { "tooltip", UserInterfaceTooltipRole }, | 123 { "tooltip", UserInterfaceTooltipRole }, |
123 { "tree", TreeRole }, | 124 { "tree", TreeRole }, |
124 { "treegrid", TreeGridRole }, | 125 { "treegrid", TreeGridRole }, |
125 { "treeitem", TreeItemRole } | 126 { "treeitem", TreeItemRole } |
126 }; | 127 }; |
127 | 128 |
128 // Roles which we need to map in the other direction | 129 // Roles which we need to map in the other direction |
129 const RoleEntry reverseRoles[] = { | 130 const RoleEntry reverseRoles[] = { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 m_detached = true; | 256 m_detached = true; |
256 } | 257 } |
257 | 258 |
258 bool AXObject::isDetached() const | 259 bool AXObject::isDetached() const |
259 { | 260 { |
260 return m_detached; | 261 return m_detached; |
261 } | 262 } |
262 | 263 |
263 bool AXObject::isARIATextControl() const | 264 bool AXObject::isARIATextControl() const |
264 { | 265 { |
265 return ariaRoleAttribute() == TextFieldRole || ariaRoleAttribute() == Search
BoxRole; | 266 return ariaRoleAttribute() == TextAreaRole || ariaRoleAttribute() == TextFie
ldRole || ariaRoleAttribute() == SearchBoxRole; |
266 } | 267 } |
267 | 268 |
268 bool AXObject::isButton() const | 269 bool AXObject::isButton() const |
269 { | 270 { |
270 AccessibilityRole role = roleValue(); | 271 AccessibilityRole role = roleValue(); |
271 | 272 |
272 return role == ButtonRole || role == PopUpButtonRole || role == ToggleButton
Role; | 273 return role == ButtonRole || role == PopUpButtonRole || role == ToggleButton
Role; |
273 } | 274 } |
274 | 275 |
275 bool AXObject::isLandmarkRelated() const | 276 bool AXObject::isLandmarkRelated() const |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 Settings* settings = document()->settings(); | 313 Settings* settings = document()->settings(); |
313 if (!settings || settings->accessibilityPasswordValuesEnabled()) | 314 if (!settings || settings->accessibilityPasswordValuesEnabled()) |
314 return false; | 315 return false; |
315 | 316 |
316 return isPasswordField(); | 317 return isPasswordField(); |
317 } | 318 } |
318 | 319 |
319 bool AXObject::isTextControl() const | 320 bool AXObject::isTextControl() const |
320 { | 321 { |
321 switch (roleValue()) { | 322 switch (roleValue()) { |
| 323 case TextAreaRole: |
322 case TextFieldRole: | 324 case TextFieldRole: |
323 case ComboBoxRole: | 325 case ComboBoxRole: |
324 case SearchBoxRole: | 326 case SearchBoxRole: |
325 return true; | 327 return true; |
326 default: | 328 default: |
327 return false; | 329 return false; |
328 } | 330 } |
329 } | 331 } |
330 | 332 |
331 bool AXObject::isClickable() const | 333 bool AXObject::isClickable() const |
332 { | 334 { |
333 switch (roleValue()) { | 335 switch (roleValue()) { |
334 case ButtonRole: | 336 case ButtonRole: |
335 case CheckBoxRole: | 337 case CheckBoxRole: |
336 case ColorWellRole: | 338 case ColorWellRole: |
337 case ComboBoxRole: | 339 case ComboBoxRole: |
338 case ImageMapLinkRole: | 340 case ImageMapLinkRole: |
339 case LinkRole: | 341 case LinkRole: |
340 case ListBoxOptionRole: | 342 case ListBoxOptionRole: |
341 case MenuButtonRole: | 343 case MenuButtonRole: |
342 case PopUpButtonRole: | 344 case PopUpButtonRole: |
343 case RadioButtonRole: | 345 case RadioButtonRole: |
344 case SpinButtonRole: | 346 case SpinButtonRole: |
345 case TabRole: | 347 case TabRole: |
| 348 case TextAreaRole: |
346 case TextFieldRole: | 349 case TextFieldRole: |
347 case ToggleButtonRole: | 350 case ToggleButtonRole: |
348 return true; | 351 return true; |
349 default: | 352 default: |
350 return false; | 353 return false; |
351 } | 354 } |
352 } | 355 } |
353 | 356 |
354 bool AXObject::accessibilityIsIgnored() const | 357 bool AXObject::accessibilityIsIgnored() const |
355 { | 358 { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 497 |
495 String AXObject::actionVerb() const | 498 String AXObject::actionVerb() const |
496 { | 499 { |
497 // FIXME: Need to add verbs for select elements. | 500 // FIXME: Need to add verbs for select elements. |
498 | 501 |
499 switch (roleValue()) { | 502 switch (roleValue()) { |
500 case ButtonRole: | 503 case ButtonRole: |
501 case ToggleButtonRole: | 504 case ToggleButtonRole: |
502 return queryString(WebLocalizedString::AXButtonActionVerb); | 505 return queryString(WebLocalizedString::AXButtonActionVerb); |
503 case TextFieldRole: | 506 case TextFieldRole: |
| 507 case TextAreaRole: |
504 return queryString(WebLocalizedString::AXTextFieldActionVerb); | 508 return queryString(WebLocalizedString::AXTextFieldActionVerb); |
505 case RadioButtonRole: | 509 case RadioButtonRole: |
506 return queryString(WebLocalizedString::AXRadioButtonActionVerb); | 510 return queryString(WebLocalizedString::AXRadioButtonActionVerb); |
507 case CheckBoxRole: | 511 case CheckBoxRole: |
508 case SwitchRole: | 512 case SwitchRole: |
509 return queryString(isChecked() ? WebLocalizedString::AXCheckedCheckBoxAc
tionVerb : WebLocalizedString::AXUncheckedCheckBoxActionVerb); | 513 return queryString(isChecked() ? WebLocalizedString::AXCheckedCheckBoxAc
tionVerb : WebLocalizedString::AXUncheckedCheckBoxActionVerb); |
510 case LinkRole: | 514 case LinkRole: |
511 return queryString(WebLocalizedString::AXLinkActionVerb); | 515 return queryString(WebLocalizedString::AXLinkActionVerb); |
512 case PopUpButtonRole: | 516 case PopUpButtonRole: |
513 // FIXME: Implement. | 517 // FIXME: Implement. |
(...skipping 17 matching lines...) Expand all Loading... |
531 if (equalIgnoringCase(result, "mixed")) { | 535 if (equalIgnoringCase(result, "mixed")) { |
532 AccessibilityRole role = ariaRoleAttribute(); | 536 AccessibilityRole role = ariaRoleAttribute(); |
533 if (role == RadioButtonRole || role == MenuItemRadioRole || role == Swit
chRole) | 537 if (role == RadioButtonRole || role == MenuItemRadioRole || role == Swit
chRole) |
534 return ButtonStateOff; | 538 return ButtonStateOff; |
535 return ButtonStateMixed; | 539 return ButtonStateMixed; |
536 } | 540 } |
537 | 541 |
538 return ButtonStateOff; | 542 return ButtonStateOff; |
539 } | 543 } |
540 | 544 |
541 bool AXObject::isMultiline() const | 545 bool AXObject::ariaIsMultiline() const |
542 { | 546 { |
543 Node* node = this->node(); | |
544 if (!node) | |
545 return false; | |
546 | |
547 if (isHTMLTextAreaElement(*node)) | |
548 return true; | |
549 | |
550 if (node->hasEditableStyle()) | |
551 return true; | |
552 | |
553 if (!isNativeTextControl() && !isNonNativeTextControl()) | |
554 return false; | |
555 | |
556 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); | 547 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); |
557 } | 548 } |
558 | 549 |
559 bool AXObject::ariaPressedIsPresent() const | 550 bool AXObject::ariaPressedIsPresent() const |
560 { | 551 { |
561 return !getAttribute(aria_pressedAttr).isEmpty(); | 552 return !getAttribute(aria_pressedAttr).isEmpty(); |
562 } | 553 } |
563 | 554 |
564 bool AXObject::supportsARIAAttributes() const | 555 bool AXObject::supportsARIAAttributes() const |
565 { | 556 { |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos,
0, HasEditableAXRole); | 1053 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos,
0, HasEditableAXRole); |
1063 currentVisiblePos = prevVisiblePos; | 1054 currentVisiblePos = prevVisiblePos; |
1064 ++lineCount; | 1055 ++lineCount; |
1065 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, sa
vedVisiblePos))); | 1056 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, sa
vedVisiblePos))); |
1066 | 1057 |
1067 return lineCount; | 1058 return lineCount; |
1068 } | 1059 } |
1069 | 1060 |
1070 bool AXObject::isARIAControl(AccessibilityRole ariaRole) | 1061 bool AXObject::isARIAControl(AccessibilityRole ariaRole) |
1071 { | 1062 { |
1072 return isARIAInput(ariaRole) || ariaRole == ButtonRole | 1063 return isARIAInput(ariaRole) || ariaRole == TextAreaRole || ariaRole == Butt
onRole |
1073 || ariaRole == ComboBoxRole || ariaRole == SliderRole; | 1064 || ariaRole == ComboBoxRole || ariaRole == SliderRole; |
1074 } | 1065 } |
1075 | 1066 |
1076 bool AXObject::isARIAInput(AccessibilityRole ariaRole) | 1067 bool AXObject::isARIAInput(AccessibilityRole ariaRole) |
1077 { | 1068 { |
1078 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole =
= TextFieldRole || ariaRole == SwitchRole || ariaRole == SearchBoxRole; | 1069 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole =
= TextFieldRole || ariaRole == SwitchRole || ariaRole == SearchBoxRole; |
1079 } | 1070 } |
1080 | 1071 |
1081 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) | 1072 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) |
1082 { | 1073 { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 } | 1145 } |
1155 | 1146 |
1156 const AtomicString& AXObject::roleName(AccessibilityRole role) | 1147 const AtomicString& AXObject::roleName(AccessibilityRole role) |
1157 { | 1148 { |
1158 static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); | 1149 static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); |
1159 | 1150 |
1160 return roleNameVector->at(role); | 1151 return roleNameVector->at(role); |
1161 } | 1152 } |
1162 | 1153 |
1163 } // namespace blink | 1154 } // namespace blink |
OLD | NEW |