Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
AX: AOM: Implement AccessibleNode class and support label and role at…
…tributes https://bugs.webkit.org/show_bug.cgi?id=179494 Reviewed by Ryosuke Niwa. Source/WebCore: Accessibility Object Model Explainer: https://wicg.github.io/aom/explainer.html Spec: https://wicg.github.io/aom/spec/ This change adds an accessibleNode getter on Element, and implements the role and label properties of AccessibleNode. In existing accessibility code, places where we previously retrieve an ARIA attribute are replaced with a new function that first checks the AOM property and then checks the equivalent ARIA attribute. Test: accessibility/accessibility-object-model.html * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * accessibility/AXObjectCache.cpp: (WebCore::nodeHasRole): (WebCore::AXObjectCache::handleLiveRegionCreated): * accessibility/AccessibilityAllInOne.cpp: * accessibility/AccessibilityImageMapLink.cpp: (WebCore::AccessibilityImageMapLink::roleValue const): (WebCore::AccessibilityImageMapLink::accessibilityDescription const): * accessibility/AccessibilityListBoxOption.cpp: (WebCore::AccessibilityListBoxOption::stringValue const): * accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::ariaAccessibilityDescription const): (WebCore::siblingWithAriaRole): (WebCore::AccessibilityNodeObject::textForLabelElement const): (WebCore::AccessibilityNodeObject::alternativeText const): (WebCore::AccessibilityNodeObject::alternativeTextForWebArea const): (WebCore::AccessibilityNodeObject::stringValue const): (WebCore::accessibleNameForNode): (WebCore::AccessibilityNodeObject::determineAriaRoleAttribute const): * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::hasProperty const): (WebCore::AccessibilityObject::stringValueForProperty const): (WebCore::AccessibilityObject::supportsARIAAttributes const): * accessibility/AccessibilityObject.h: * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::stringValue const): (WebCore::AccessibilityRenderObject::exposesTitleUIElement const): (WebCore::AccessibilityRenderObject::determineAccessibilityRole): * accessibility/AccessibleNode.cpp: Added. (WebCore::ariaAttributeMap): (WebCore::isPropertyValueString): (WebCore::AccessibleNode::hasProperty): (WebCore::AccessibleNode::valueForProperty): (WebCore::AccessibleNode::effectiveStringValueForElement): (WebCore::AccessibleNode::stringValueForProperty): (WebCore::AccessibleNode::setStringProperty): (WebCore::AccessibleNode::role const): (WebCore::AccessibleNode::setRole): (WebCore::AccessibleNode::label const): (WebCore::AccessibleNode::setLabel): * accessibility/AccessibleNode.h: Added. (WebCore::AXPropertyHashTraits::emptyValue): (WebCore::AXPropertyHashTraits::constructDeletedValue): (WebCore::AXPropertyHashTraits::isDeletedValue): (WebCore::AccessibleNode::AccessibleNode): (WebCore::AccessibleNode::ref): (WebCore::AccessibleNode::deref): * accessibility/AccessibleNode.idl: Added. * bindings/js/WebCoreBuiltinNames.h: * dom/Element.cpp: (WebCore::Element::canContainRangeEndPoint const): (WebCore::Element::accessibleNode): (WebCore::Element::existingAccessibleNode const): * dom/Element.h: * dom/Element.idl: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::accessibleNode const): (WebCore::ElementRareData::setAccessibleNode): * editing/TextIterator.cpp: (WebCore::isRendererReplacedElement): * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setAccessibilityObjectModelEnabled): (WebCore::RuntimeEnabledFeatures::accessibilityObjectModelEnabled const): * rendering/RenderMenuList.cpp: (RenderMenuList::itemAccessibilityText const): Source/WebKit: * Shared/WebPreferences.yaml: * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetAccessibilityObjectModelEnabled): (WKPreferencesGetAccessibilityObjectModelEnabled): * UIProcess/API/C/WKPreferencesRefPrivate.h: Source/WebKitLegacy/mac: * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences accessibilityObjectModelEnabled]): (-[WebPreferences setAccessibilityObjectModelEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Tools: * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): LayoutTests: * accessibility/accessibility-object-model-expected.txt: Added. * accessibility/accessibility-object-model.html: Added. * js/dom/dom-static-property-for-in-iteration-expected.txt: Canonical link: https://commits.webkit.org/195752@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
721 additions
and 23 deletions.
- +11 −0 LayoutTests/ChangeLog
- +42 −0 LayoutTests/accessibility/accessibility-object-model-expected.txt
- +121 −0 LayoutTests/accessibility/accessibility-object-model.html
- +1 −0 LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt
- +2 −0 Source/WebCore/CMakeLists.txt
- +91 −0 Source/WebCore/ChangeLog
- +1 −0 Source/WebCore/DerivedSources.cpp
- +3 −0 Source/WebCore/DerivedSources.make
- +2 −0 Source/WebCore/Sources.txt
- +6 −0 Source/WebCore/WebCore.xcodeproj/project.pbxproj
- +3 −2 Source/WebCore/accessibility/AXObjectCache.cpp
- +1 −0 Source/WebCore/accessibility/AccessibilityAllInOne.cpp
- +3 −2 Source/WebCore/accessibility/AccessibilityImageMapLink.cpp
- +2 −1 Source/WebCore/accessibility/AccessibilityListBoxOption.cpp
- +10 −9 Source/WebCore/accessibility/AccessibilityNodeObject.cpp
- +17 −2 Source/WebCore/accessibility/AccessibilityObject.cpp
- +5 −0 Source/WebCore/accessibility/AccessibilityObject.h
- +3 −3 Source/WebCore/accessibility/AccessibilityRenderObject.cpp
- +146 −0 Source/WebCore/accessibility/AccessibleNode.cpp
- +91 −0 Source/WebCore/accessibility/AccessibleNode.h
- +32 −0 Source/WebCore/accessibility/AccessibleNode.idl
- +1 −0 Source/WebCore/bindings/js/WebCoreBuiltinNames.h
- +24 −1 Source/WebCore/dom/Element.cpp
- +4 −0 Source/WebCore/dom/Element.h
- +2 −0 Source/WebCore/dom/Element.idl
- +1 −1 Source/WebCore/dom/ElementRareData.cpp
- +6 −0 Source/WebCore/dom/ElementRareData.h
- +2 −1 Source/WebCore/editing/TextIterator.cpp
- +5 −0 Source/WebCore/page/RuntimeEnabledFeatures.h
- +2 −1 Source/WebCore/rendering/RenderMenuList.cpp
- +13 −0 Source/WebKit/ChangeLog
- +8 −0 Source/WebKit/Shared/WebPreferences.yaml
- +10 −0 Source/WebKit/UIProcess/API/C/WKPreferences.cpp
- +4 −0 Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
- +16 −0 Source/WebKitLegacy/mac/ChangeLog
- +1 −0 Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
- +12 −0 Source/WebKitLegacy/mac/WebView/WebPreferences.mm
- +1 −0 Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
- +1 −0 Source/WebKitLegacy/mac/WebView/WebView.mm
- +12 −0 Tools/ChangeLog
- +1 −0 Tools/DumpRenderTree/mac/DumpRenderTree.mm
- +2 −0 Tools/WebKitTestRunner/TestController.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,42 @@ | ||
Click Me | ||
This tests getting and setting Accessibility Object Model properties. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS button.accessibleNode == null is false | ||
|
||
Supported properties on an AccessibleNode are all null by default | ||
PASS button.accessibleNode.role is null | ||
PASS button.accessibleNode.label is null | ||
PASS button.accessibleNode.foo is undefined | ||
|
||
ARIA attributes should not be reflected into AOM properties. | ||
PASS axButton.role is 'AXRole: AXCheckBox' | ||
PASS axButton.description is 'AXDescription: label' | ||
PASS button.accessibleNode.role is null | ||
PASS button.accessibleNode.label is null | ||
|
||
Test setting AOM properties. And make sure AOM takes precedence. | ||
PASS button.accessibleNode.role is 'slider' | ||
PASS button.accessibleNode.label is 'AOM Label' | ||
PASS axButton.role is 'AXRole: AXSlider' | ||
PASS axButton.description is 'AXDescription: AOM Label' | ||
|
||
Setting some of the AOM properties should be able to make an element accessible. | ||
PASS axParagraph == null || axParagraph == undefined is true | ||
PASS axParagraph.isIgnored is false | ||
|
||
An invalid role should be ignored. | ||
PASS button.accessibleNode.role is null | ||
PASS axButton.role is 'AXRole: AXButton' | ||
PASS button.accessibleNode.role is 'badrole' | ||
PASS axButton.role is 'AXRole: AXButton' | ||
|
||
An AccessibleNode keeps its element alive. | ||
PASS aomRemovedButton.role is 'checkbox' | ||
PASS aomRemovedButton.role is 'checkbox' | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,121 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<script src="../resources/js-test-pre.js"></script> | ||
<script src="../resources/accessibility-helper.js"></script> | ||
</head> | ||
<body> | ||
|
||
<button id="button">Click Me</button> | ||
<div id="container"><button id="button2">Button2</button></div> | ||
<p id="paragraph"></p> | ||
|
||
<p id="description"></p> | ||
<div id="console"></div> | ||
|
||
<script> | ||
description("This tests getting and setting Accessibility Object Model properties."); | ||
if (window.accessibilityController) { | ||
var button = document.getElementById("button"); | ||
var axButton = accessibilityController.accessibleElementById("button"); | ||
var aomRemovedButton; | ||
var paragraph = document.getElementById("paragraph"); | ||
var axParagraph; | ||
|
||
shouldBeFalse("button.accessibleNode == null"); | ||
|
||
testPropertiesDefault(); | ||
testNoReflection(); | ||
testSettingProperties(); | ||
testBecomeAccessible(); | ||
testInvalidRole(); | ||
testElementAlive(); | ||
} | ||
|
||
function testPropertiesDefault() { | ||
debug("\nSupported properties on an AccessibleNode are all null by default"); | ||
shouldBeNull("button.accessibleNode.role"); | ||
shouldBeNull("button.accessibleNode.label"); | ||
// Invalid property value should be undefined | ||
shouldBe("button.accessibleNode.foo", "undefined"); | ||
} | ||
|
||
function testNoReflection() { | ||
debug("\nARIA attributes should not be reflected into AOM properties."); | ||
button.setAttribute("role", "checkbox"); | ||
button.setAttribute("aria-label", "label"); | ||
shouldBe("axButton.role", "'AXRole: AXCheckBox'"); | ||
shouldBe("axButton.description", "'AXDescription: label'"); | ||
|
||
// AOM properties should be null even if we have set ARIA attributes. | ||
shouldBeNull("button.accessibleNode.role"); | ||
shouldBeNull("button.accessibleNode.label"); | ||
} | ||
|
||
function testSettingProperties() { | ||
debug("\nTest setting AOM properties. And make sure AOM takes precedence."); | ||
|
||
// Set the ARIA attributes on the element first. | ||
button.setAttribute("role", "checkbox"); | ||
button.setAttribute("aria-label", "label"); | ||
|
||
// Then set the corresponding AOM properties to some different values. | ||
button.accessibleNode.role = "slider"; | ||
shouldBe("button.accessibleNode.role", "'slider'"); | ||
button.accessibleNode.label = "AOM Label"; | ||
shouldBe("button.accessibleNode.label", "'AOM Label'"); | ||
|
||
// The AOM property values should override ARIA attributes. | ||
shouldBe("axButton.role", "'AXRole: AXSlider'"); | ||
shouldBe("axButton.description", "'AXDescription: AOM Label'"); | ||
} | ||
|
||
function testBecomeAccessible() { | ||
debug("\nSetting some of the AOM properties should be able to make an element accessible."); | ||
axParagraph = accessibilityController.accessibleElementById("paragraph"); | ||
shouldBeTrue("axParagraph == null || axParagraph == undefined"); | ||
|
||
// The element should be accessible if it has a label. | ||
paragraph.accessibleNode.label = "test label"; | ||
axParagraph = accessibilityController.accessibleElementById("paragraph"); | ||
shouldBeFalse("axParagraph.isIgnored"); | ||
} | ||
|
||
function testInvalidRole() { | ||
debug("\nAn invalid role should be ignored."); | ||
|
||
// Clear the ARIA attribute and AOM property value. | ||
button.removeAttribute("role"); | ||
button.accessibleNode.role = null; | ||
shouldBe("button.accessibleNode.role", "null"); | ||
shouldBe("axButton.role", "'AXRole: AXButton'"); | ||
|
||
// Accessibility should use the semantic role if an invalid role is provided. | ||
button.accessibleNode.role = "badrole"; | ||
shouldBe("button.accessibleNode.role", "'badrole'"); | ||
shouldBe("axButton.role", "'AXRole: AXButton'"); | ||
} | ||
|
||
function testElementAlive() { | ||
debug("\nAn AccessibleNode keeps its element alive."); | ||
// Get the button to be removed and access its accessibleNode. | ||
(function() { | ||
var button2 = document.getElementById("button2"); | ||
aomRemovedButton = button2.accessibleNode; | ||
aomRemovedButton.role = "checkbox"; | ||
})(); | ||
shouldBe("aomRemovedButton.role", "'checkbox'"); | ||
|
||
// Remove the button make sure we are still able to access the accessibleNode. | ||
(function() { | ||
var button2 = document.getElementById("button2"); | ||
button2.parentElement.removeChild(button2); | ||
})(); | ||
gc(); | ||
shouldBe("aomRemovedButton.role", "'checkbox'"); | ||
} | ||
|
||
</script> | ||
<script src="../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -58,3 +58,4 @@ | ||
#include "AccessibilityTableRow.cpp" | ||
#include "AccessibilityTree.cpp" | ||
#include "AccessibilityTreeItem.cpp" | ||
#include "AccessibleNode.cpp" |
Oops, something went wrong.