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

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: Fixed some Blink tests. 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 , m_role(UnknownRole) 382 , m_role(UnknownRole)
382 , m_lastKnownIsIgnoredValue(DefaultBehavior) 383 , m_lastKnownIsIgnoredValue(DefaultBehavior)
383 , m_parent(nullptr) 384 , m_parent(nullptr)
384 , m_lastModificationCount(-1) 385 , m_lastModificationCount(-1)
385 , m_cachedIsIgnored(false) 386 , m_cachedIsIgnored(false)
386 , m_cachedIsInertOrAriaHidden(false) 387 , m_cachedIsInertOrAriaHidden(false)
387 , m_cachedIsDescendantOfLeafNode(false) 388 , m_cachedIsDescendantOfLeafNode(false)
388 , m_cachedIsDescendantOfDisabledNode(false) 389 , m_cachedIsDescendantOfDisabledNode(false)
389 , m_cachedHasInheritedPresentationalRole(false) 390 , m_cachedHasInheritedPresentationalRole(false)
390 , m_cachedIsPresentationalChild(false) 391 , m_cachedIsPresentationalChild(false)
392 , m_cachedAncestorExposesActiveDescendant(false)
391 , m_cachedLiveRegionRoot(nullptr) 393 , m_cachedLiveRegionRoot(nullptr)
392 , m_axObjectCache(&axObjectCache) 394 , m_axObjectCache(&axObjectCache)
393 { 395 {
394 ++s_numberOfLiveAXObjects; 396 ++s_numberOfLiveAXObjects;
395 } 397 }
396 398
397 AXObject::~AXObject() 399 AXObject::~AXObject()
398 { 400 {
399 ASSERT(isDetached()); 401 ASSERT(isDetached());
400 --s_numberOfLiveAXObjects; 402 --s_numberOfLiveAXObjects;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 m_lastModificationCount = cache.modificationCount(); 516 m_lastModificationCount = cache.modificationCount();
515 m_cachedIsInertOrAriaHidden = computeIsInertOrAriaHidden(); 517 m_cachedIsInertOrAriaHidden = computeIsInertOrAriaHidden();
516 m_cachedIsDescendantOfLeafNode = (leafNodeAncestor() != 0); 518 m_cachedIsDescendantOfLeafNode = (leafNodeAncestor() != 0);
517 m_cachedIsDescendantOfDisabledNode = (disabledAncestor() != 0); 519 m_cachedIsDescendantOfDisabledNode = (disabledAncestor() != 0);
518 m_cachedHasInheritedPresentationalRole = (inheritsPresentationalRoleFrom() ! = 0); 520 m_cachedHasInheritedPresentationalRole = (inheritsPresentationalRoleFrom() ! = 0);
519 m_cachedIsPresentationalChild = (ancestorForWhichThisIsAPresentationalChild( ) != 0); 521 m_cachedIsPresentationalChild = (ancestorForWhichThisIsAPresentationalChild( ) != 0);
520 m_cachedIsIgnored = computeAccessibilityIsIgnored(); 522 m_cachedIsIgnored = computeAccessibilityIsIgnored();
521 m_cachedLiveRegionRoot = isLiveRegion() ? 523 m_cachedLiveRegionRoot = isLiveRegion() ?
522 this : 524 this :
523 (parentObjectIfExists() ? parentObjectIfExists()->liveRegionRoot() : 0); 525 (parentObjectIfExists() ? parentObjectIfExists()->liveRegionRoot() : 0);
526 m_cachedAncestorExposesActiveDescendant = computeAncestorExposesActiveDescen dant();
524 } 527 }
525 528
526 bool AXObject::accessibilityIsIgnoredByDefault(IgnoredReasons* ignoredReasons) c onst 529 bool AXObject::accessibilityIsIgnoredByDefault(IgnoredReasons* ignoredReasons) c onst
527 { 530 {
528 return defaultObjectInclusion(ignoredReasons) == IgnoreObject; 531 return defaultObjectInclusion(ignoredReasons) == IgnoreObject;
529 } 532 }
530 533
531 AXObjectInclusion AXObject::accessibilityPlatformIncludesObject() const 534 AXObjectInclusion AXObject::accessibilityPlatformIncludesObject() const
532 { 535 {
533 if (isMenuListPopup() || isMenuListOption()) 536 if (isMenuListPopup() || isMenuListOption())
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 updateCachedAttributeValuesIfNeeded(); 672 updateCachedAttributeValuesIfNeeded();
670 return m_cachedHasInheritedPresentationalRole; 673 return m_cachedHasInheritedPresentationalRole;
671 } 674 }
672 675
673 bool AXObject::isPresentationalChild() const 676 bool AXObject::isPresentationalChild() const
674 { 677 {
675 updateCachedAttributeValuesIfNeeded(); 678 updateCachedAttributeValuesIfNeeded();
676 return m_cachedIsPresentationalChild; 679 return m_cachedIsPresentationalChild;
677 } 680 }
678 681
682 bool AXObject::ancestorExposesActiveDescendant() const
683 {
684 updateCachedAttributeValuesIfNeeded();
685 return m_cachedAncestorExposesActiveDescendant;
686 }
687
688 bool AXObject::computeAncestorExposesActiveDescendant() const
689 {
690 const AXObject* parent = parentObjectUnignored();
691 if (!parent)
692 return false;
693
694 if (parent->supportsActiveDescendant()
695 && !parent->getAttribute(aria_activedescendantAttr).isEmpty()) {
696 return true;
697 }
698
699 return parent->ancestorExposesActiveDescendant();
700 }
701
679 // Simplify whitespace, but preserve a single leading and trailing whitespace ch aracter if it's present. 702 // Simplify whitespace, but preserve a single leading and trailing whitespace ch aracter if it's present.
680 // static 703 // static
681 String AXObject::collapseWhitespace(const String& str) 704 String AXObject::collapseWhitespace(const String& str)
682 { 705 {
683 StringBuilder result; 706 StringBuilder result;
684 if (!str.isEmpty() && isHTMLSpace<UChar>(str[0])) 707 if (!str.isEmpty() && isHTMLSpace<UChar>(str[0]))
685 result.append(' '); 708 result.append(' ');
686 result.append(str.simplifyWhiteSpace(isHTMLSpace<UChar>)); 709 result.append(str.simplifyWhiteSpace(isHTMLSpace<UChar>));
687 if (!str.isEmpty() && isHTMLSpace<UChar>(str[str.length() - 1])) 710 if (!str.isEmpty() && isHTMLSpace<UChar>(str[str.length() - 1]))
688 result.append(' '); 711 result.append(' ');
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 return false; 995 return false;
973 996
974 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true"); 997 return equalIgnoringCase(getAttribute(aria_multilineAttr), "true");
975 } 998 }
976 999
977 bool AXObject::ariaPressedIsPresent() const 1000 bool AXObject::ariaPressedIsPresent() const
978 { 1001 {
979 return !getAttribute(aria_pressedAttr).isEmpty(); 1002 return !getAttribute(aria_pressedAttr).isEmpty();
980 } 1003 }
981 1004
1005 bool AXObject::supportsActiveDescendant() const
1006 {
1007 // According to the ARIA Spec, all ARIA composite widgets, ARIA text boxes
1008 // and ARIA groups should be able to expose an active descendant.
1009 // Implicitly, <input> and <textarea> elements should also have this ability .
1010 switch (ariaRoleAttribute()) {
1011 case ComboBoxRole:
1012 case GridRole:
1013 case GroupRole:
1014 case ListBoxRole:
1015 case MenuRole:
1016 case MenuBarRole:
1017 case RadioGroupRole:
1018 case RowRole:
1019 case SearchBoxRole:
1020 case TabListRole:
1021 case TextFieldRole:
1022 case ToolbarRole:
1023 case TreeRole:
1024 case TreeGridRole:
1025 return true;
1026 default:
1027 return false;
1028 }
1029 }
1030
982 bool AXObject::supportsARIAAttributes() const 1031 bool AXObject::supportsARIAAttributes() const
983 { 1032 {
984 return isLiveRegion() 1033 return isLiveRegion()
985 || supportsARIADragging() 1034 || supportsARIADragging()
986 || supportsARIADropping() 1035 || supportsARIADropping()
987 || supportsARIAFlowTo() 1036 || supportsARIAFlowTo()
988 || supportsARIAOwns() 1037 || supportsARIAOwns()
989 || hasAttribute(aria_labelAttr); 1038 || hasAttribute(aria_labelAttr);
990 } 1039 }
991 1040
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 1733
1685 DEFINE_TRACE(AXObject) 1734 DEFINE_TRACE(AXObject)
1686 { 1735 {
1687 visitor->trace(m_children); 1736 visitor->trace(m_children);
1688 visitor->trace(m_parent); 1737 visitor->trace(m_parent);
1689 visitor->trace(m_cachedLiveRegionRoot); 1738 visitor->trace(m_cachedLiveRegionRoot);
1690 visitor->trace(m_axObjectCache); 1739 visitor->trace(m_axObjectCache);
1691 } 1740 }
1692 1741
1693 } // namespace blink 1742 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698