Skip to content
Permalink
Browse files
AX: inert attribute doesn't cause display:contents element to be ignored
https://bugs.webkit.org/show_bug.cgi?id=241022

Reviewed by Chris Fleizach.

Prior to this patch, the inert attribute didn't cause node-only objects
(like those with display:contents) to be ignored. This was because
AccessibilityObject::defaultObjectInclusion only checked `effectiveInert`
for elements with renderers, even though you only need an element to
have style (not a renderer).

This patch fixes this by adding a new AccessibilityObject::style()
method which uses AccessibilityObject::element() to get
Element::computedStyle() and checking effectiveInert on that, which
works for both renderer and renderer-less objects.

* LayoutTests/accessibility/node-only-inert-object-expected.txt: Added.
* LayoutTests/accessibility/node-only-inert-object.html: Added.
* LayoutTests/platform/ios/TestExpectations: Enable new test.
* LayoutTests/platform/mac-wk1/TestExpectations: Skip new test.
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::style const): Added.
(WebCore::AccessibilityObject::defaultObjectInclusion const):
* Source/WebCore/accessibility/AccessibilityObject.h:

Canonical link: https://commits.webkit.org/251185@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
twilco committed Jun 1, 2022
1 parent 8072caf commit 077f4d2279246224dcdf80f76c039d6bbbdd8a88
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 2 deletions.
@@ -0,0 +1,11 @@
This test ensures that a node-only object (e.g. one with display:contents) that is inert is ignored.

PASS: accessibilityController.accessibleElementById('button') === null

Removing inert from #button
PASS: accessibilityController.accessibleElementById('button').role.includes('Button') === true

PASS successfullyParsed is true

TEST COMPLETE
Click me
@@ -0,0 +1,31 @@
<!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>

<button inert id="button" style="display:contents">Click me</button>

<script>
var testOutput = "This test ensures that a node-only object (e.g. one with display:contents) that is inert is ignored.\n\n";

if (window.accessibilityController) {
window.jsTestIsAsync = true;

testOutput += expect("accessibilityController.accessibleElementById('button')", "null");

testOutput += "\nRemoving inert from #button\n";
document.getElementById("button").removeAttribute("inert");
setTimeout(async function() {
await waitFor(() => accessibilityController.accessibleElementById("button"));
testOutput += expect("accessibilityController.accessibleElementById('button').role.includes('Button')", "true");

debug(testOutput);
finishJSTest();
}, 0);
}
</script>
</body>
</html>
@@ -2123,6 +2123,7 @@ accessibility/aria-required-updates-after-dynamic-change.html [ Pass ]
accessibility/display-contents-element-roles.html [ Pass ]
accessibility/element-haspopup.html [ Pass ]
accessibility/list-with-dynamically-changing-content.html [ Pass ]
accessibility/node-only-inert-object.html [ Pass ]
accessibility/node-only-object-element-rect.html [ Pass ]
accessibility/text-updates-after-dynamic-change.html [ Pass ]
accessibility/video-element-url-attribute.html [ Pass ]
@@ -854,6 +854,9 @@ editing/spelling/spelling-insert-html.html [ Pass Timeout ]
editing/spelling/spellcheck-async.html [ Failure ]
editing/spelling/spelling-unified-emulation.html [ Failure ]

# The inert attribute isn't making objects inaccessible on WK1.
accessibility/node-only-inert-object.html [ Failure ]

# Skip due to lack of DumpRenderTree `AccessibilityUIElement::stringDescriptionOfAttributeValue` implementation.
accessibility/visible-character-range-basic.html [ Skip ]
accessibility/visible-character-range-height-changes.html [ Skip ]
@@ -462,6 +462,9 @@ http/tests/misc/image-checks-for-accept.html [ Skip ]
# Timing out since added in https://bugs.webkit.org/show_bug.cgi?id=240750 (likely some missing AccessibilityUIElement implementation).
accessibility/table-exposure-updates-dynamically.html [ Skip ]

# Failing since added in https://bugs.webkit.org/show_bug.cgi?id=241022.
accessibility/node-only-inert-object.html [ Failure ]

# Probably wrong role after adding children to list (AXGroup instead of AXList).
accessibility/list-with-dynamically-changing-content.html [ Skip ]
accessibility/ignored-aria-role-description.html [ Skip ]
@@ -2802,7 +2802,14 @@ Element* AccessibilityObject::element() const
return downcast<Element>(node);
return nullptr;
}


const RenderStyle* AccessibilityObject::style() const
{
if (auto* element = this->element())
return element->computedStyle();
return nullptr;
}

bool AccessibilityObject::isValueAutofillAvailable() const
{
if (!isNativeTextControl())
@@ -3714,7 +3721,8 @@ AccessibilityObjectInclusion AccessibilityObject::defaultObjectInclusion() const
if (useParentData ? m_isIgnoredFromParentData.isAXHidden : isAXHidden())
return AccessibilityObjectInclusion::IgnoreObject;

if (renderer() && renderer()->style().effectiveInert())
auto* style = this->style();
if (style && style->effectiveInert())
return AccessibilityObjectInclusion::IgnoreObject;

if (useParentData ? m_isIgnoredFromParentData.isPresentationalChildOfAriaRole : isPresentationalChildOfAriaRole())
@@ -272,6 +272,8 @@ class AccessibilityObject : public AXCoreObject {
Element* element() const override;
Node* node() const override { return nullptr; }
RenderObject* renderer() const override { return nullptr; }
const RenderStyle* style() const;

// Note: computeAccessibilityIsIgnored does not consider whether an object is ignored due to presence of modals.
// Use accessibilityIsIgnored as the word of law when determining if an object is ignored.
virtual bool computeAccessibilityIsIgnored() const { return true; }

0 comments on commit 077f4d2

Please sign in to comment.