Title: [295090] trunk
Revision
295090
Author
[email protected]
Date
2022-06-01 09:20:48 -0700 (Wed, 01 Jun 2022)

Log Message

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

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/accessibility/node-only-inert-object-expected.txt (0 => 295090)


--- trunk/LayoutTests/accessibility/node-only-inert-object-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/node-only-inert-object-expected.txt	2022-06-01 16:20:48 UTC (rev 295090)
@@ -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

Added: trunk/LayoutTests/accessibility/node-only-inert-object.html (0 => 295090)


--- trunk/LayoutTests/accessibility/node-only-inert-object.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/node-only-inert-object.html	2022-06-01 16:20:48 UTC (rev 295090)
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</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>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (295089 => 295090)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-06-01 15:36:18 UTC (rev 295089)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-06-01 16:20:48 UTC (rev 295090)
@@ -2123,6 +2123,7 @@
 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 ]

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (295089 => 295090)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2022-06-01 15:36:18 UTC (rev 295089)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2022-06-01 16:20:48 UTC (rev 295090)
@@ -854,6 +854,9 @@
 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 ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (295089 => 295090)


--- trunk/LayoutTests/platform/win/TestExpectations	2022-06-01 15:36:18 UTC (rev 295089)
+++ trunk/LayoutTests/platform/win/TestExpectations	2022-06-01 16:20:48 UTC (rev 295090)
@@ -462,6 +462,9 @@
 # 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 ]

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (295089 => 295090)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-06-01 15:36:18 UTC (rev 295089)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-06-01 16:20:48 UTC (rev 295090)
@@ -2802,7 +2802,14 @@
         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 @@
     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())

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (295089 => 295090)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2022-06-01 15:36:18 UTC (rev 295089)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2022-06-01 16:20:48 UTC (rev 295090)
@@ -272,6 +272,8 @@
     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; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to