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

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

Issue 1841333002: Various fixes for aria-activedescendant. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added selectable and selected states to ARIA list box options. Created 4 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 "scrollbar", 323 "scrollbar",
324 "slider", 324 "slider",
325 "spinbutton", 325 "spinbutton",
326 "status", 326 "status",
327 "tab", 327 "tab",
328 "tabpanel", 328 "tabpanel",
329 "textbox", 329 "textbox",
330 "timer", 330 "timer",
331 "tooltip", 331 "tooltip",
332 "treeitem", 332 "treeitem",
333 // Composite user interface widgets. This list is also from w3.org site ref rerenced above. 333 // Composite user interface widgets.
334 // This list is also from the w3.org site referenced above.
334 "combobox", 335 "combobox",
335 "grid", 336 "grid",
336 "listbox", 337 "listbox",
337 "menu", 338 "menu",
338 "menubar", 339 "menubar",
339 "radiogroup", 340 "radiogroup",
340 "tablist", 341 "tablist",
341 "tree", 342 "tree",
342 "treegrid" 343 "treegrid"
343 }; 344 };
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 updateCachedAttributeValuesIfNeeded(); 670 updateCachedAttributeValuesIfNeeded();
670 return m_cachedHasInheritedPresentationalRole; 671 return m_cachedHasInheritedPresentationalRole;
671 } 672 }
672 673
673 bool AXObject::isPresentationalChild() const 674 bool AXObject::isPresentationalChild() const
674 { 675 {
675 updateCachedAttributeValuesIfNeeded(); 676 updateCachedAttributeValuesIfNeeded();
676 return m_cachedIsPresentationalChild; 677 return m_cachedIsPresentationalChild;
677 } 678 }
678 679
680 bool AXObject::ancestorExposesActiveDescendant() const
dmazzoni 2016/03/31 05:48:30 To be correct, shouldn't we check the role of the
681 {
682 for (const AXObject* object = this; object; object = object->parentObjectUni gnored()) {
683 if (object->supportsActiveDescendant()
684 && !object->getAttribute(aria_activedescendantAttr).isEmpty()) {
685 return true;
686 }
687 }
688
689 return false;
690 }
691
679 // Simplify whitespace, but preserve a single leading and trailing whitespace ch aracter if it's present. 692 // Simplify whitespace, but preserve a single leading and trailing whitespace ch aracter if it's present.
680 // static 693 // static
681 String AXObject::collapseWhitespace(const String& str) 694 String AXObject::collapseWhitespace(const String& str)
682 { 695 {
683 StringBuilder result; 696 StringBuilder result;
684 if (!str.isEmpty() && isHTMLSpace<UChar>(str[0])) 697 if (!str.isEmpty() && isHTMLSpace<UChar>(str[0]))
685 result.append(' '); 698 result.append(' ');
686 result.append(str.simplifyWhiteSpace(isHTMLSpace<UChar>)); 699 result.append(str.simplifyWhiteSpace(isHTMLSpace<UChar>));
687 if (!str.isEmpty() && isHTMLSpace<UChar>(str[str.length() - 1])) 700 if (!str.isEmpty() && isHTMLSpace<UChar>(str[str.length() - 1]))
688 result.append(' '); 701 result.append(' ');
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 return false; 985 return false;
973 986
974 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); 987 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true");
975 } 988 }
976 989
977 bool AXObject::ariaPressedIsPresent() const 990 bool AXObject::ariaPressedIsPresent() const
978 { 991 {
979 return !getAttribute(aria_pressedAttr).isEmpty(); 992 return !getAttribute(aria_pressedAttr).isEmpty();
980 } 993 }
981 994
995 bool AXObject::supportsActiveDescendant() const
996 {
997 // According to the ARIA Spec, all ARIA composite widgets, ARIA text boxes
998 // and ARIA groups should be able to expose an active descendant.
999 // Implicitly, <input> and <textarea> elements should also have this ability .
1000 switch (ariaRoleAttribute()) {
1001 case ComboBoxRole:
1002 case GridRole:
1003 case GroupRole:
1004 case ListBoxRole:
1005 case MenuRole:
1006 case MenuBarRole:
1007 case RadioGroupRole:
1008 case TabListRole:
1009 case TextFieldRole:
dmazzoni 2016/03/31 05:48:30 You deleted toolbar and some others, but the ARIA
1010 case TreeRole:
1011 case TreeGridRole:
1012 return true;
1013 default:
1014 return false;
1015 }
1016 }
1017
982 bool AXObject::supportsARIAAttributes() const 1018 bool AXObject::supportsARIAAttributes() const
983 { 1019 {
984 return isLiveRegion() 1020 return isLiveRegion()
985 || supportsARIADragging() 1021 || supportsARIADragging()
986 || supportsARIADropping() 1022 || supportsARIADropping()
987 || supportsARIAFlowTo() 1023 || supportsARIAFlowTo()
988 || supportsARIAOwns() 1024 || supportsARIAOwns()
989 || hasAttribute(aria_labelAttr); 1025 || hasAttribute(aria_labelAttr);
990 } 1026 }
991 1027
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 1721
1686 DEFINE_TRACE(AXObject) 1722 DEFINE_TRACE(AXObject)
1687 { 1723 {
1688 visitor->trace(m_children); 1724 visitor->trace(m_children);
1689 visitor->trace(m_parent); 1725 visitor->trace(m_parent);
1690 visitor->trace(m_cachedLiveRegionRoot); 1726 visitor->trace(m_cachedLiveRegionRoot);
1691 visitor->trace(m_axObjectCache); 1727 visitor->trace(m_axObjectCache);
1692 } 1728 }
1693 1729
1694 } // namespace blink 1730 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698