Title: [295307] branches/safari-613-branch
Revision
295307
Author
[email protected]
Date
2022-06-06 17:35:49 -0700 (Mon, 06 Jun 2022)

Log Message

Cherry-pick 077f4d227924. rdar://problem/94034984

    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

Modified Paths

Added Paths

Diff

Added: branches/safari-613-branch/LayoutTests/accessibility/node-only-inert-object-expected.txt (0 => 295307)


--- branches/safari-613-branch/LayoutTests/accessibility/node-only-inert-object-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/accessibility/node-only-inert-object-expected.txt	2022-06-07 00:35:49 UTC (rev 295307)
@@ -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: branches/safari-613-branch/LayoutTests/accessibility/node-only-inert-object.html (0 => 295307)


--- branches/safari-613-branch/LayoutTests/accessibility/node-only-inert-object.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/accessibility/node-only-inert-object.html	2022-06-07 00:35:49 UTC (rev 295307)
@@ -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: branches/safari-613-branch/LayoutTests/platform/ios/TestExpectations (295306 => 295307)


--- branches/safari-613-branch/LayoutTests/platform/ios/TestExpectations	2022-06-07 00:35:44 UTC (rev 295306)
+++ branches/safari-613-branch/LayoutTests/platform/ios/TestExpectations	2022-06-07 00:35:49 UTC (rev 295307)
@@ -2093,6 +2093,7 @@
 # Enable "phone number linkifying" test for iOS
 fast/dom/linkify-phone-numbers.html [ Pass ]
 
+accessibility/node-only-inert-object.html [ Pass ]
 accessibility/video-element-url-attribute.html [ Pass ]
 accessibility/visible-character-range.html [ Pass ]
 accessibility/ancestor-computation.html [ Pass ]

Modified: branches/safari-613-branch/LayoutTests/platform/mac-wk1/TestExpectations (295306 => 295307)


--- branches/safari-613-branch/LayoutTests/platform/mac-wk1/TestExpectations	2022-06-07 00:35:44 UTC (rev 295306)
+++ branches/safari-613-branch/LayoutTests/platform/mac-wk1/TestExpectations	2022-06-07 00:35:49 UTC (rev 295307)
@@ -605,6 +605,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.html [ Skip ]
 accessibility/model-element-attributes.html [ Skip ]

Modified: branches/safari-613-branch/LayoutTests/platform/win/TestExpectations (295306 => 295307)


--- branches/safari-613-branch/LayoutTests/platform/win/TestExpectations	2022-06-07 00:35:44 UTC (rev 295306)
+++ branches/safari-613-branch/LayoutTests/platform/win/TestExpectations	2022-06-07 00:35:49 UTC (rev 295307)
@@ -273,6 +273,9 @@
 # TODO Accept header is handled by the browser
 http/tests/misc/image-checks-for-accept.html [ Skip ]
 
+# Failing since added in https://bugs.webkit.org/show_bug.cgi?id=241022.
+accessibility/node-only-inert-object.html [ Failure ]
+
 # Need to implement AccessibilityUIElement::clearSelectedChildren()
 accessibility/aria-listbox-clear-selection-crash.html [ Skip ]
 accessibility/listbox-clear-selection.html [ Skip ]

Modified: branches/safari-613-branch/Source/WebCore/accessibility/AccessibilityObject.cpp (295306 => 295307)


--- branches/safari-613-branch/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-06-07 00:35:44 UTC (rev 295306)
+++ branches/safari-613-branch/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-06-07 00:35:49 UTC (rev 295307)
@@ -2638,7 +2638,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())
@@ -3546,7 +3553,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: branches/safari-613-branch/Source/WebCore/accessibility/AccessibilityObject.h (295306 => 295307)


--- branches/safari-613-branch/Source/WebCore/accessibility/AccessibilityObject.h	2022-06-07 00:35:44 UTC (rev 295306)
+++ branches/safari-613-branch/Source/WebCore/accessibility/AccessibilityObject.h	2022-06-07 00:35:49 UTC (rev 295307)
@@ -273,6 +273,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