Skip to content
Permalink
Browse files
AX: Include AXKeyShortcutsValue in accessibilityAttributeNames when t…
…here is an aria-keyshortcuts attribute

https://bugs.webkit.org/show_bug.cgi?id=248572
rdar://problem/102834471

Reviewed by Andres Gonzalez.

WebAccessibilityObjectWrapper supports returning the value of aria-keyshortcuts
through the AXKeyShortcutsValue accessibility attribute, but does not return the
attribute name in accessibilityAttributeNames if it is a supported attribute.
Additionally, this attribute is not updated in the isolated tree if it is changed.
This patch fixes that by including AXKeyShortcutsValue in accessibilityAttributeNames if it
is supported through AccessibilityObject::supportsKeyShortcutsValue and updates the AXIsolatedTree
value for AXPropertyName::KeyShortcutsValue if aria-keyshortcuts attribute is changed.

* LayoutTests/accessibility/aria-keyshortcuts-expected.txt: Added.
* LayoutTests/accessibility/aria-keyshortcuts.html: Added.
* LayoutTests/platform/win/TestExpectations:
* Source/WebCore/accessibility/AXLogger.cpp:
(WebCore::operator<<):
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleAttributeChange):
(WebCore::AXObjectCache::updateIsolatedTree):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsKeyShortcuts const):
(WebCore::AccessibilityObject::keyShortcuts const):
(WebCore::AccessibilityObject::keyShortcutsValue const): Deleted.
* Source/WebCore/accessibility/AccessibilityObject.h:
* Source/WebCore/accessibility/AccessibilityObjectInterface.h:
* Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp:
(WebCore::AccessibilityObjectAtspi::attributes const):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeProperties):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateNodeProperties):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:
* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

Canonical link: https://commits.webkit.org/257274@main
  • Loading branch information
tommymchugh authored and AndresGonzalezApple committed Dec 2, 2022
1 parent 21e76d2 commit f7a887f4c25742af054956aec6cf2ef5c2512e14
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 9 deletions.
@@ -0,0 +1,24 @@
This test ensures aria-keyshortcuts is exposed to accessibility correctly.

PASS: axItem1.isAttributeSupported('AXKeyShortcutsValue') === false
PASS: axItem2.isAttributeSupported('AXKeyShortcutsValue') === true
PASS: axItem3.isAttributeSupported('AXKeyShortcutsValue') === true
PASS: axItem1.stringAttributeValue('AXKeyShortcutsValue') === ''
PASS: axItem2.stringAttributeValue('AXKeyShortcutsValue') === 'Shift+2'
PASS: axItem3.stringAttributeValue('AXKeyShortcutsValue') === 'Shift+3 Option+4'
Update aria-keyshortcuts to Command+5 for #test1
PASS: axItem1.isAttributeSupported('AXKeyShortcutsValue') === true
PASS: axItem1.stringAttributeValue('AXKeyShortcutsValue') === 'Command+5'
Remove aria-keyshortcuts for #test2
PASS: axItem2.isAttributeSupported('AXKeyShortcutsValue') === false
PASS: axItem2.stringAttributeValue('AXKeyShortcutsValue') === ''
Update aria-keyshortcuts to Shift+Command+1 for #test3
PASS: axItem3.isAttributeSupported('AXKeyShortcutsValue') === true
PASS: axItem3.stringAttributeValue('AXKeyShortcutsValue') === 'Shift+Command+1'

PASS successfullyParsed is true

TEST COMPLETE
X
X
X
@@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
</head>
<body>
<div id="content">
<div id="test1" role="button">X</div>
<div id="test2" role="button" aria-keyshortcuts="Shift+2">X</div>
<div id="test3" role="button" aria-keyshortcuts="Shift+3 Option+4">X</div>
</div>

<script>
let output = "This test ensures aria-keyshortcuts is exposed to accessibility correctly.\n\n";
if (window.accessibilityController) {
window.jsTestIsAsync = true;

var axItem1 = accessibilityController.accessibleElementById("test1");
var axItem2 = accessibilityController.accessibleElementById("test2");
var axItem3 = accessibilityController.accessibleElementById("test3");
output += expect("axItem1.isAttributeSupported('AXKeyShortcutsValue')", "false");
output += expect("axItem2.isAttributeSupported('AXKeyShortcutsValue')", "true");
output += expect("axItem3.isAttributeSupported('AXKeyShortcutsValue')", "true");

output += expect("axItem1.stringAttributeValue('AXKeyShortcutsValue')", "''");
output += expect("axItem2.stringAttributeValue('AXKeyShortcutsValue')", "'Shift+2'");
output += expect("axItem3.stringAttributeValue('AXKeyShortcutsValue')", "'Shift+3 Option+4'");

output += "Update aria-keyshortcuts to Command+5 for #test1\n";
document.getElementById("test1").setAttribute("aria-keyshortcuts", "Command+5");
setTimeout(async function() {
await waitFor(() => axItem1.stringAttributeValue('AXKeyShortcutsValue') === "Command+5");
output += expect("axItem1.isAttributeSupported('AXKeyShortcutsValue')", "true");
output += expect("axItem1.stringAttributeValue('AXKeyShortcutsValue')", "'Command+5'");

output += "Remove aria-keyshortcuts for #test2\n";
document.getElementById("test2").removeAttribute("aria-keyshortcuts");
await waitFor(() => axItem2.stringAttributeValue('AXKeyShortcutsValue') === "");
output += expect("axItem2.isAttributeSupported('AXKeyShortcutsValue')", "false");
output += expect("axItem2.stringAttributeValue('AXKeyShortcutsValue')", "''");

output += "Update aria-keyshortcuts to Shift+Command+1 for #test3\n";
document.getElementById("test3").setAttribute("aria-keyshortcuts", "Shift+Command+1");
await waitFor(() => axItem3.stringAttributeValue('AXKeyShortcutsValue') === "Shift+Command+1");
output += expect("axItem3.isAttributeSupported('AXKeyShortcutsValue')", "true");
output += expect("axItem3.stringAttributeValue('AXKeyShortcutsValue')", "'Shift+Command+1'");

debug(output);
finishJSTest();
}, 0);
}
</script>
</body>
</html>
@@ -454,6 +454,7 @@ webkit.org/b/228915 accessibility/selected-state-changed-notifications.html [ Ti

# Not supported
accessibility/embedded-image-description.html [ Skip ]
accessibility/aria-keyshortcuts.html [ Skip ]

# Not supported. Skipped also in mac-wk1 and win ports.
accessibility/nested-textareas-value-changed-notifications.html [ Skip ]
@@ -1685,6 +1685,7 @@ accessibility/aria-table-with-presentational-elements.html [ Skip ]
webkit.org/b/149177 accessibility/ax-value-with-search.html [ Skip ]

accessibility/aria-roles-unignored.html [ Skip ]
accessibility/aria-keyshortcuts.html [ Skip ]

# Accessibility tests for notifications that don't exist or aren't needed on Mac OS X (or Windows)
accessibility/aria-checkbox-sends-notification.html [ Skip ]
@@ -451,6 +451,9 @@ TextStream& operator<<(TextStream& stream, AXObjectCache::AXNotification notific
case AXObjectCache::AXNotification::AXIsAtomicChanged:
stream << "AXIsAtomicChanged";
break;
case AXObjectCache::AXNotification::AXKeyShortcutsChanged:
stream << "AXKeyShortcutsChanged";
break;
case AXObjectCache::AXNotification::AXLanguageChanged:
stream << "AXLanguageChanged";
break;
@@ -2105,6 +2105,8 @@ void AXObjectCache::handleAttributeChange(Element* element, const QualifiedName&
postNotification(element, AXFlowToChanged);
else if (attrName == aria_grabbedAttr)
postNotification(element, AXGrabbedStateChanged);
else if (attrName == aria_keyshortcutsAttr)
postNotification(element, AXKeyShortcutsChanged);
else if (attrName == aria_levelAttr)
postNotification(element, AXLevelChanged);
else if (attrName == aria_liveAttr)
@@ -3755,6 +3757,9 @@ void AXObjectCache::updateIsolatedTree(const Vector<std::pair<RefPtr<Accessibili
case AXURLChanged:
tree->updateNodeProperty(*notification.first, AXPropertyName::URL);
break;
case AXKeyShortcutsChanged:
tree->updateNodeProperty(*notification.first, AXPropertyName::KeyShortcuts);
break;
case AXActiveDescendantChanged:
case AXRoleChanged:
case AXColumnSpanChanged:
@@ -298,6 +298,7 @@ class AXObjectCache : public CanMakeWeakPtr<AXObjectCache> {
AXIdAttributeChanged,
AXImageOverlayChanged,
AXIsAtomicChanged,
AXKeyShortcutsChanged,
AXLanguageChanged,
AXLayoutComplete,
AXLevelChanged,
@@ -2729,7 +2729,12 @@ bool AccessibilityObject::isInlineText() const
return is<RenderInline>(renderer());
}

const String AccessibilityObject::keyShortcutsValue() const
bool AccessibilityObject::supportsKeyShortcuts() const
{
return hasAttribute(aria_keyshortcutsAttr);
}

String AccessibilityObject::keyShortcuts() const
{
return getAttribute(aria_keyshortcutsAttr);
}
@@ -321,7 +321,8 @@ class AccessibilityObject : public AXCoreObject, public CanMakeWeakPtr<Accessibi
Vector<String> classList() const override;
AccessibilityCurrentState currentState() const override;
bool supportsCurrent() const override;
const String keyShortcutsValue() const override;
bool supportsKeyShortcuts() const override;
String keyShortcuts() const override;

// This function checks if the object should be ignored when there's a modal dialog displayed.
virtual bool ignoredFromModalPresence() const;
@@ -1067,7 +1067,8 @@ class AXCoreObject : public ThreadSafeRefCounted<AXCoreObject> {
virtual AccessibilityCurrentState currentState() const = 0;
virtual bool supportsCurrent() const = 0;
String currentValue() const;
virtual const String keyShortcutsValue() const = 0;
virtual bool supportsKeyShortcuts() const = 0;
virtual String keyShortcuts() const = 0;

virtual bool isModalNode() const = 0;

@@ -1004,7 +1004,7 @@ HashMap<String, String> AccessibilityObjectAtspi::attributes() const
if (m_coreObject->supportsDragging())
map.add("grabbed"_s, m_coreObject->isGrabbed() ? "true"_s : "false"_s);

String keyShortcuts = m_coreObject->keyShortcutsValue();
String keyShortcuts = m_coreObject->keyShortcuts();
if (!keyShortcuts.isEmpty())
map.add("keyshortcuts"_s, keyShortcuts);

@@ -151,7 +151,8 @@ void AXIsolatedObject::initializeProperties(const Ref<AXCoreObject>& coreObject,
setProperty(AXPropertyName::LinkRelValue, object.linkRelValue().isolatedCopy());
setProperty(AXPropertyName::CurrentState, static_cast<int>(object.currentState()));
setProperty(AXPropertyName::SupportsCurrent, object.supportsCurrent());
setProperty(AXPropertyName::KeyShortcutsValue, object.keyShortcutsValue().isolatedCopy());
setProperty(AXPropertyName::SupportsKeyShortcuts, object.supportsKeyShortcuts());
setProperty(AXPropertyName::KeyShortcuts, object.keyShortcuts().isolatedCopy());
setProperty(AXPropertyName::SupportsSetSize, object.supportsSetSize());
setProperty(AXPropertyName::SupportsPath, object.supportsPath());
setProperty(AXPropertyName::SupportsPosInSet, object.supportsPosInSet());
@@ -224,7 +224,8 @@ class AXIsolatedObject final : public AXCoreObject {
Vector<String> classList() const override;
AccessibilityCurrentState currentState() const override { return static_cast<AccessibilityCurrentState>(intAttributeValue(AXPropertyName::CurrentState)); }
bool supportsCurrent() const override { return boolAttributeValue(AXPropertyName::SupportsCurrent); }
const String keyShortcutsValue() const override { return stringAttributeValue(AXPropertyName::KeyShortcutsValue); }
bool supportsKeyShortcuts() const override { return boolAttributeValue(AXPropertyName::SupportsKeyShortcuts); }
String keyShortcuts() const override { return stringAttributeValue(AXPropertyName::KeyShortcuts); }
bool supportsSetSize() const override { return boolAttributeValue(AXPropertyName::SupportsSetSize); }
bool supportsPosInSet() const override { return boolAttributeValue(AXPropertyName::SupportsPosInSet); }
int setSize() const override { return intAttributeValue(AXPropertyName::SetSize); }
@@ -498,6 +498,10 @@ void AXIsolatedTree::updateNodeProperties(AXCoreObject& axObject, const Vector<A
case AXPropertyName::SortDirection:
propertyMap.set(AXPropertyName::SortDirection, static_cast<int>(axObject.sortDirection()));
break;
case AXPropertyName::KeyShortcuts:
propertyMap.set(AXPropertyName::SupportsKeyShortcuts, axObject.supportsKeyShortcuts());
propertyMap.set(AXPropertyName::KeyShortcuts, axObject.keyShortcuts().isolatedCopy());
break;
case AXPropertyName::SupportsPosInSet:
propertyMap.set(AXPropertyName::SupportsPosInSet, axObject.supportsPosInSet());
break;
@@ -187,7 +187,7 @@ enum class AXPropertyName : uint16_t {
IsVisible,
IsVisited,
IsWidget,
KeyShortcutsValue,
KeyShortcuts,
Language,
LinkRelValue,
LinkedObjects,
@@ -245,6 +245,7 @@ enum class AXPropertyName : uint16_t {
SupportsDatetimeAttribute,
SupportsExpanded,
SupportsExpandedTextValue,
SupportsKeyShortcuts,
SupportsLiveRegion,
SupportsPath,
SupportsPosInSet,
@@ -243,6 +243,10 @@
#define NSAccessibilityARIACurrentAttribute @"AXARIACurrent"
#endif

#ifndef NSAccessibilityKeyShortcutsAttribute
#define NSAccessibilityKeyShortcutsAttribute @"AXKeyShortcutsValue"
#endif

// Table/grid attributes
#ifndef NSAccessibilityARIAColumnIndexAttribute
#define NSAccessibilityARIAColumnIndexAttribute @"AXARIAColumnIndex"
@@ -1187,6 +1191,9 @@ - (NSArray*)additionalAccessibilityAttributeNames
if (backingObject->supportsPosInSet())
[additional addObject:NSAccessibilityARIAPosInSetAttribute];

if (backingObject->supportsKeyShortcuts())
[additional addObject:NSAccessibilityKeyShortcutsAttribute];

AccessibilitySortDirection sortDirection = backingObject->sortDirection();
if (sortDirection != AccessibilitySortDirection::None && sortDirection != AccessibilitySortDirection::Invalid)
[additional addObject:NSAccessibilitySortDirectionAttribute];
@@ -2587,8 +2594,8 @@ - (id)accessibilityAttributeValue:(NSString*)attributeName
if ([attributeName isEqualToString:NSAccessibilityPopupValueAttribute])
return backingObject->popupValue();

if ([attributeName isEqualToString:@"AXKeyShortcutsValue"])
return backingObject->keyShortcutsValue();
if ([attributeName isEqualToString:NSAccessibilityKeyShortcutsAttribute])
return backingObject->keyShortcuts();

if ([attributeName isEqualToString:@"AXARIAPressedIsPresent"])
return [NSNumber numberWithBool:backingObject->pressedIsPresent()];

0 comments on commit f7a887f

Please sign in to comment.