| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 m_detached = true; | 255 m_detached = true; |
| 255 } | 256 } |
| 256 | 257 |
| 257 bool AXObject::isDetached() const | 258 bool AXObject::isDetached() const |
| 258 { | 259 { |
| 259 return m_detached; | 260 return m_detached; |
| 260 } | 261 } |
| 261 | 262 |
| 262 bool AXObject::isARIATextControl() const | 263 bool AXObject::isARIATextControl() const |
| 263 { | 264 { |
| 264 return ariaRoleAttribute() == TextFieldRole || ariaRoleAttribute() == Search
BoxRole; | 265 return ariaRoleAttribute() == TextAreaRole || ariaRoleAttribute() == TextFie
ldRole || ariaRoleAttribute() == SearchBoxRole; |
| 265 } | 266 } |
| 266 | 267 |
| 267 bool AXObject::isButton() const | 268 bool AXObject::isButton() const |
| 268 { | 269 { |
| 269 AccessibilityRole role = roleValue(); | 270 AccessibilityRole role = roleValue(); |
| 270 | 271 |
| 271 return role == ButtonRole || role == PopUpButtonRole || role == ToggleButton
Role; | 272 return role == ButtonRole || role == PopUpButtonRole || role == ToggleButton
Role; |
| 272 } | 273 } |
| 273 | 274 |
| 274 bool AXObject::isLandmarkRelated() const | 275 bool AXObject::isLandmarkRelated() const |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 Settings* settings = document()->settings(); | 312 Settings* settings = document()->settings(); |
| 312 if (!settings || settings->accessibilityPasswordValuesEnabled()) | 313 if (!settings || settings->accessibilityPasswordValuesEnabled()) |
| 313 return false; | 314 return false; |
| 314 | 315 |
| 315 return isPasswordField(); | 316 return isPasswordField(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 bool AXObject::isTextControl() const | 319 bool AXObject::isTextControl() const |
| 319 { | 320 { |
| 320 switch (roleValue()) { | 321 switch (roleValue()) { |
| 322 case TextAreaRole: |
| 321 case TextFieldRole: | 323 case TextFieldRole: |
| 322 case ComboBoxRole: | 324 case ComboBoxRole: |
| 323 case SearchBoxRole: | 325 case SearchBoxRole: |
| 324 return true; | 326 return true; |
| 325 default: | 327 default: |
| 326 return false; | 328 return false; |
| 327 } | 329 } |
| 328 } | 330 } |
| 329 | 331 |
| 330 bool AXObject::isClickable() const | 332 bool AXObject::isClickable() const |
| 331 { | 333 { |
| 332 switch (roleValue()) { | 334 switch (roleValue()) { |
| 333 case ButtonRole: | 335 case ButtonRole: |
| 334 case CheckBoxRole: | 336 case CheckBoxRole: |
| 335 case ColorWellRole: | 337 case ColorWellRole: |
| 336 case ComboBoxRole: | 338 case ComboBoxRole: |
| 337 case ImageMapLinkRole: | 339 case ImageMapLinkRole: |
| 338 case LinkRole: | 340 case LinkRole: |
| 339 case ListBoxOptionRole: | 341 case ListBoxOptionRole: |
| 340 case MenuButtonRole: | 342 case MenuButtonRole: |
| 341 case PopUpButtonRole: | 343 case PopUpButtonRole: |
| 342 case RadioButtonRole: | 344 case RadioButtonRole: |
| 343 case SpinButtonRole: | 345 case SpinButtonRole: |
| 344 case TabRole: | 346 case TabRole: |
| 347 case TextAreaRole: |
| 345 case TextFieldRole: | 348 case TextFieldRole: |
| 346 case ToggleButtonRole: | 349 case ToggleButtonRole: |
| 347 return true; | 350 return true; |
| 348 default: | 351 default: |
| 349 return false; | 352 return false; |
| 350 } | 353 } |
| 351 } | 354 } |
| 352 | 355 |
| 353 bool AXObject::accessibilityIsIgnored() const | 356 bool AXObject::accessibilityIsIgnored() const |
| 354 { | 357 { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 473 |
| 471 String AXObject::actionVerb() const | 474 String AXObject::actionVerb() const |
| 472 { | 475 { |
| 473 // FIXME: Need to add verbs for select elements. | 476 // FIXME: Need to add verbs for select elements. |
| 474 | 477 |
| 475 switch (roleValue()) { | 478 switch (roleValue()) { |
| 476 case ButtonRole: | 479 case ButtonRole: |
| 477 case ToggleButtonRole: | 480 case ToggleButtonRole: |
| 478 return queryString(WebLocalizedString::AXButtonActionVerb); | 481 return queryString(WebLocalizedString::AXButtonActionVerb); |
| 479 case TextFieldRole: | 482 case TextFieldRole: |
| 483 case TextAreaRole: |
| 480 return queryString(WebLocalizedString::AXTextFieldActionVerb); | 484 return queryString(WebLocalizedString::AXTextFieldActionVerb); |
| 481 case RadioButtonRole: | 485 case RadioButtonRole: |
| 482 return queryString(WebLocalizedString::AXRadioButtonActionVerb); | 486 return queryString(WebLocalizedString::AXRadioButtonActionVerb); |
| 483 case CheckBoxRole: | 487 case CheckBoxRole: |
| 484 case SwitchRole: | 488 case SwitchRole: |
| 485 return queryString(isChecked() ? WebLocalizedString::AXCheckedCheckBoxAc
tionVerb : WebLocalizedString::AXUncheckedCheckBoxActionVerb); | 489 return queryString(isChecked() ? WebLocalizedString::AXCheckedCheckBoxAc
tionVerb : WebLocalizedString::AXUncheckedCheckBoxActionVerb); |
| 486 case LinkRole: | 490 case LinkRole: |
| 487 return queryString(WebLocalizedString::AXLinkActionVerb); | 491 return queryString(WebLocalizedString::AXLinkActionVerb); |
| 488 case PopUpButtonRole: | 492 case PopUpButtonRole: |
| 489 // FIXME: Implement. | 493 // FIXME: Implement. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 507 if (equalIgnoringCase(result, "mixed")) { | 511 if (equalIgnoringCase(result, "mixed")) { |
| 508 AccessibilityRole role = ariaRoleAttribute(); | 512 AccessibilityRole role = ariaRoleAttribute(); |
| 509 if (role == RadioButtonRole || role == MenuItemRadioRole || role == Swit
chRole) | 513 if (role == RadioButtonRole || role == MenuItemRadioRole || role == Swit
chRole) |
| 510 return ButtonStateOff; | 514 return ButtonStateOff; |
| 511 return ButtonStateMixed; | 515 return ButtonStateMixed; |
| 512 } | 516 } |
| 513 | 517 |
| 514 return ButtonStateOff; | 518 return ButtonStateOff; |
| 515 } | 519 } |
| 516 | 520 |
| 517 bool AXObject::isMultiline() const | 521 bool AXObject::ariaIsMultiline() const |
| 518 { | 522 { |
| 519 Node* node = this->node(); | |
| 520 if (!node) | |
| 521 return false; | |
| 522 | |
| 523 if (isHTMLTextAreaElement(*node)) | |
| 524 return true; | |
| 525 | |
| 526 if (node->hasEditableStyle()) | |
| 527 return true; | |
| 528 | |
| 529 if (!isNativeTextControl() && !isNonNativeTextControl()) | |
| 530 return false; | |
| 531 | |
| 532 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); | 523 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); |
| 533 } | 524 } |
| 534 | 525 |
| 535 bool AXObject::ariaPressedIsPresent() const | 526 bool AXObject::ariaPressedIsPresent() const |
| 536 { | 527 { |
| 537 return !getAttribute(aria_pressedAttr).isEmpty(); | 528 return !getAttribute(aria_pressedAttr).isEmpty(); |
| 538 } | 529 } |
| 539 | 530 |
| 540 bool AXObject::supportsARIAAttributes() const | 531 bool AXObject::supportsARIAAttributes() const |
| 541 { | 532 { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos,
0, HasEditableAXRole); | 1029 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos,
0, HasEditableAXRole); |
| 1039 currentVisiblePos = prevVisiblePos; | 1030 currentVisiblePos = prevVisiblePos; |
| 1040 ++lineCount; | 1031 ++lineCount; |
| 1041 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, sa
vedVisiblePos))); | 1032 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, sa
vedVisiblePos))); |
| 1042 | 1033 |
| 1043 return lineCount; | 1034 return lineCount; |
| 1044 } | 1035 } |
| 1045 | 1036 |
| 1046 bool AXObject::isARIAControl(AccessibilityRole ariaRole) | 1037 bool AXObject::isARIAControl(AccessibilityRole ariaRole) |
| 1047 { | 1038 { |
| 1048 return isARIAInput(ariaRole) || ariaRole == ButtonRole | 1039 return isARIAInput(ariaRole) || ariaRole == TextAreaRole || ariaRole == Butt
onRole |
| 1049 || ariaRole == ComboBoxRole || ariaRole == SliderRole; | 1040 || ariaRole == ComboBoxRole || ariaRole == SliderRole; |
| 1050 } | 1041 } |
| 1051 | 1042 |
| 1052 bool AXObject::isARIAInput(AccessibilityRole ariaRole) | 1043 bool AXObject::isARIAInput(AccessibilityRole ariaRole) |
| 1053 { | 1044 { |
| 1054 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole =
= TextFieldRole || ariaRole == SwitchRole || ariaRole == SearchBoxRole; | 1045 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole =
= TextFieldRole || ariaRole == SwitchRole || ariaRole == SearchBoxRole; |
| 1055 } | 1046 } |
| 1056 | 1047 |
| 1057 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) | 1048 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) |
| 1058 { | 1049 { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1121 } |
| 1131 | 1122 |
| 1132 const AtomicString& AXObject::roleName(AccessibilityRole role) | 1123 const AtomicString& AXObject::roleName(AccessibilityRole role) |
| 1133 { | 1124 { |
| 1134 static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); | 1125 static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); |
| 1135 | 1126 |
| 1136 return roleNameVector->at(role); | 1127 return roleNameVector->at(role); |
| 1137 } | 1128 } |
| 1138 | 1129 |
| 1139 } // namespace blink | 1130 } // namespace blink |
| OLD | NEW |