Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: Source/modules/accessibility/AXObject.cpp

Issue 1045693002: Expose multiline attribute from blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reland Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
32 #include "core/dom/NodeTraversal.h" 31 #include "core/dom/NodeTraversal.h"
33 #include "core/editing/VisibleUnits.h" 32 #include "core/editing/VisibleUnits.h"
34 #include "core/editing/htmlediting.h" 33 #include "core/editing/htmlediting.h"
35 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
36 #include "core/frame/Settings.h" 35 #include "core/frame/Settings.h"
37 #include "core/layout/LayoutListItem.h" 36 #include "core/layout/LayoutListItem.h"
38 #include "core/layout/LayoutTheme.h" 37 #include "core/layout/LayoutTheme.h"
39 #include "core/layout/LayoutView.h" 38 #include "core/layout/LayoutView.h"
40 #include "modules/accessibility/AXObjectCacheImpl.h" 39 #include "modules/accessibility/AXObjectCacheImpl.h"
41 #include "platform/UserGestureIndicator.h" 40 #include "platform/UserGestureIndicator.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 { "searchbox", SearchBoxRole }, 109 { "searchbox", SearchBoxRole },
111 { "separator", SplitterRole }, 110 { "separator", SplitterRole },
112 { "slider", SliderRole }, 111 { "slider", SliderRole },
113 { "spinbutton", SpinButtonRole }, 112 { "spinbutton", SpinButtonRole },
114 { "status", StatusRole }, 113 { "status", StatusRole },
115 { "switch", SwitchRole }, 114 { "switch", SwitchRole },
116 { "tab", TabRole }, 115 { "tab", TabRole },
117 { "tablist", TabListRole }, 116 { "tablist", TabListRole },
118 { "tabpanel", TabPanelRole }, 117 { "tabpanel", TabPanelRole },
119 { "text", StaticTextRole }, 118 { "text", StaticTextRole },
120 { "textbox", TextAreaRole }, 119 { "textbox", TextFieldRole },
121 { "timer", TimerRole }, 120 { "timer", TimerRole },
122 { "toolbar", ToolbarRole }, 121 { "toolbar", ToolbarRole },
123 { "tooltip", UserInterfaceTooltipRole }, 122 { "tooltip", UserInterfaceTooltipRole },
124 { "tree", TreeRole }, 123 { "tree", TreeRole },
125 { "treegrid", TreeGridRole }, 124 { "treegrid", TreeGridRole },
126 { "treeitem", TreeItemRole } 125 { "treeitem", TreeItemRole }
127 }; 126 };
128 127
129 struct InternalRoleEntry { 128 struct InternalRoleEntry {
130 AccessibilityRole webcoreRole; 129 AccessibilityRole webcoreRole;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 m_detached = true; 393 m_detached = true;
395 } 394 }
396 395
397 bool AXObject::isDetached() const 396 bool AXObject::isDetached() const
398 { 397 {
399 return m_detached; 398 return m_detached;
400 } 399 }
401 400
402 bool AXObject::isARIATextControl() const 401 bool AXObject::isARIATextControl() const
403 { 402 {
404 return ariaRoleAttribute() == TextAreaRole || ariaRoleAttribute() == TextFie ldRole || ariaRoleAttribute() == SearchBoxRole; 403 return ariaRoleAttribute() == TextFieldRole || ariaRoleAttribute() == Search BoxRole;
405 } 404 }
406 405
407 bool AXObject::isButton() const 406 bool AXObject::isButton() const
408 { 407 {
409 AccessibilityRole role = roleValue(); 408 AccessibilityRole role = roleValue();
410 409
411 return role == ButtonRole || role == PopUpButtonRole || role == ToggleButton Role; 410 return role == ButtonRole || role == PopUpButtonRole || role == ToggleButton Role;
412 } 411 }
413 412
414 bool AXObject::isLandmarkRelated() const 413 bool AXObject::isLandmarkRelated() const
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 Settings* settings = document()->settings(); 450 Settings* settings = document()->settings();
452 if (!settings || settings->accessibilityPasswordValuesEnabled()) 451 if (!settings || settings->accessibilityPasswordValuesEnabled())
453 return false; 452 return false;
454 453
455 return isPasswordField(); 454 return isPasswordField();
456 } 455 }
457 456
458 bool AXObject::isTextControl() const 457 bool AXObject::isTextControl() const
459 { 458 {
460 switch (roleValue()) { 459 switch (roleValue()) {
461 case TextAreaRole:
462 case TextFieldRole: 460 case TextFieldRole:
463 case ComboBoxRole: 461 case ComboBoxRole:
464 case SearchBoxRole: 462 case SearchBoxRole:
465 return true; 463 return true;
466 default: 464 default:
467 return false; 465 return false;
468 } 466 }
469 } 467 }
470 468
471 bool AXObject::isClickable() const 469 bool AXObject::isClickable() const
472 { 470 {
473 switch (roleValue()) { 471 switch (roleValue()) {
474 case ButtonRole: 472 case ButtonRole:
475 case CheckBoxRole: 473 case CheckBoxRole:
476 case ColorWellRole: 474 case ColorWellRole:
477 case ComboBoxRole: 475 case ComboBoxRole:
478 case ImageMapLinkRole: 476 case ImageMapLinkRole:
479 case LinkRole: 477 case LinkRole:
480 case ListBoxOptionRole: 478 case ListBoxOptionRole:
481 case MenuButtonRole: 479 case MenuButtonRole:
482 case PopUpButtonRole: 480 case PopUpButtonRole:
483 case RadioButtonRole: 481 case RadioButtonRole:
484 case SpinButtonRole: 482 case SpinButtonRole:
485 case TabRole: 483 case TabRole:
486 case TextAreaRole:
487 case TextFieldRole: 484 case TextFieldRole:
488 case ToggleButtonRole: 485 case ToggleButtonRole:
489 return true; 486 return true;
490 default: 487 default:
491 return false; 488 return false;
492 } 489 }
493 } 490 }
494 491
495 bool AXObject::accessibilityIsIgnored() const 492 bool AXObject::accessibilityIsIgnored() const
496 { 493 {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 633
637 String AXObject::actionVerb() const 634 String AXObject::actionVerb() const
638 { 635 {
639 // FIXME: Need to add verbs for select elements. 636 // FIXME: Need to add verbs for select elements.
640 637
641 switch (roleValue()) { 638 switch (roleValue()) {
642 case ButtonRole: 639 case ButtonRole:
643 case ToggleButtonRole: 640 case ToggleButtonRole:
644 return queryString(WebLocalizedString::AXButtonActionVerb); 641 return queryString(WebLocalizedString::AXButtonActionVerb);
645 case TextFieldRole: 642 case TextFieldRole:
646 case TextAreaRole:
647 return queryString(WebLocalizedString::AXTextFieldActionVerb); 643 return queryString(WebLocalizedString::AXTextFieldActionVerb);
648 case RadioButtonRole: 644 case RadioButtonRole:
649 return queryString(WebLocalizedString::AXRadioButtonActionVerb); 645 return queryString(WebLocalizedString::AXRadioButtonActionVerb);
650 case CheckBoxRole: 646 case CheckBoxRole:
651 case SwitchRole: 647 case SwitchRole:
652 return queryString(isChecked() ? WebLocalizedString::AXCheckedCheckBoxAc tionVerb : WebLocalizedString::AXUncheckedCheckBoxActionVerb); 648 return queryString(isChecked() ? WebLocalizedString::AXCheckedCheckBoxAc tionVerb : WebLocalizedString::AXUncheckedCheckBoxActionVerb);
653 case LinkRole: 649 case LinkRole:
654 return queryString(WebLocalizedString::AXLinkActionVerb); 650 return queryString(WebLocalizedString::AXLinkActionVerb);
655 case PopUpButtonRole: 651 case PopUpButtonRole:
656 // FIXME: Implement. 652 // FIXME: Implement.
(...skipping 17 matching lines...) Expand all
674 if (equalIgnoringCase(result, "mixed")) { 670 if (equalIgnoringCase(result, "mixed")) {
675 AccessibilityRole role = ariaRoleAttribute(); 671 AccessibilityRole role = ariaRoleAttribute();
676 if (role == RadioButtonRole || role == MenuItemRadioRole || role == Swit chRole) 672 if (role == RadioButtonRole || role == MenuItemRadioRole || role == Swit chRole)
677 return ButtonStateOff; 673 return ButtonStateOff;
678 return ButtonStateMixed; 674 return ButtonStateMixed;
679 } 675 }
680 676
681 return ButtonStateOff; 677 return ButtonStateOff;
682 } 678 }
683 679
684 bool AXObject::ariaIsMultiline() const 680 bool AXObject::isMultiline() const
685 { 681 {
682 Node* node = this->node();
683 if (!node)
684 return false;
685
686 if (isHTMLTextAreaElement(*node))
687 return true;
688
689 if (node->hasEditableStyle())
690 return true;
691
692 if (!isNativeTextControl() && !isNonNativeTextControl())
693 return false;
694
686 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); 695 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true");
687 } 696 }
688 697
689 bool AXObject::ariaPressedIsPresent() const 698 bool AXObject::ariaPressedIsPresent() const
690 { 699 {
691 return !getAttribute(aria_pressedAttr).isEmpty(); 700 return !getAttribute(aria_pressedAttr).isEmpty();
692 } 701 }
693 702
694 bool AXObject::supportsARIAAttributes() const 703 bool AXObject::supportsARIAAttributes() const
695 { 704 {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos, 0, HasEditableAXRole); 1201 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos, 0, HasEditableAXRole);
1193 currentVisiblePos = prevVisiblePos; 1202 currentVisiblePos = prevVisiblePos;
1194 ++lineCount; 1203 ++lineCount;
1195 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, sa vedVisiblePos))); 1204 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, sa vedVisiblePos)));
1196 1205
1197 return lineCount; 1206 return lineCount;
1198 } 1207 }
1199 1208
1200 bool AXObject::isARIAControl(AccessibilityRole ariaRole) 1209 bool AXObject::isARIAControl(AccessibilityRole ariaRole)
1201 { 1210 {
1202 return isARIAInput(ariaRole) || ariaRole == TextAreaRole || ariaRole == Butt onRole 1211 return isARIAInput(ariaRole) || ariaRole == ButtonRole
1203 || ariaRole == ComboBoxRole || ariaRole == SliderRole; 1212 || ariaRole == ComboBoxRole || ariaRole == SliderRole;
1204 } 1213 }
1205 1214
1206 bool AXObject::isARIAInput(AccessibilityRole ariaRole) 1215 bool AXObject::isARIAInput(AccessibilityRole ariaRole)
1207 { 1216 {
1208 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole = = TextFieldRole || ariaRole == SwitchRole || ariaRole == SearchBoxRole; 1217 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole = = TextFieldRole || ariaRole == SwitchRole || ariaRole == SearchBoxRole;
1209 } 1218 }
1210 1219
1211 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) 1220 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value)
1212 { 1221 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 } 1300 }
1292 1301
1293 const AtomicString& AXObject::internalRoleName(AccessibilityRole role) 1302 const AtomicString& AXObject::internalRoleName(AccessibilityRole role)
1294 { 1303 {
1295 static const Vector<AtomicString>* internalRoleNameVector = createInternalRo leNameVector(); 1304 static const Vector<AtomicString>* internalRoleNameVector = createInternalRo leNameVector();
1296 1305
1297 return internalRoleNameVector->at(role); 1306 return internalRoleNameVector->at(role);
1298 } 1307 }
1299 1308
1300 } // namespace blink 1309 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXObject.h ('k') | Source/modules/accessibility/InspectorAccessibilityAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698