Bug 252941 - AX: Adding display:block to table rows inside a header makes the entire table inaccessible
Summary: AX: Adding display:block to table rows inside a header makes the entire table...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-02-24 19:43 PST by Tyler Wilcock
Modified: 2023-02-27 05:57 PST (History)
10 users (show)

See Also:


Attachments
Patch (7.08 KB, patch)
2023-02-24 20:12 PST, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2023-02-24 19:43:52 PST
Adding display:block to table rows inside a header makes the entire table inaccessible.
Comment 1 Radar WebKit Bug Importer 2023-02-24 19:44:04 PST
<rdar://problem/105912396>
Comment 2 Tyler Wilcock 2023-02-24 20:12:20 PST
Created attachment 465165 [details]
Patch
Comment 3 chris fleizach 2023-02-24 21:06:52 PST
Comment on attachment 465165 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=465165&action=review

> Source/WebCore/accessibility/AccessibilityTableRow.cpp:114
> +    while (isAnonymousTablePart(parent))

Is there a chance patent becomes nil and we loop forever

> Source/WebCore/accessibility/AccessibilityTableRow.cpp:116
> +    return parent;

Do we need to implement this in parent object unignored if we’re already doing it in parent object ?
Comment 4 Andres Gonzalez 2023-02-27 05:57:08 PST
(In reply to Tyler Wilcock from comment #2)
> Created attachment 465165 [details]
> Patch

"Because no `AXIsolatedObject` was created for these anonymous renderers (as expected), `AXIsolatedTree::nodeForID` failed, breaking the tree hierarchy."

Why it is expected that no isolated object is created for an anonymous renderer. Because it is ignored? If so, that's the actual cause of the problem.

--- a/Source/WebCore/accessibility/AccessibilityTableRow.cpp
+++ b/Source/WebCore/accessibility/AccessibilityTableRow.cpp
@@ -90,7 +90,32 @@ bool AccessibilityTableRow::computeAccessibilityIsIgnored() const

     return false;
 }
-
+
+static bool isAnonymousTablePart(AccessibilityObject* axObject)
+{
+    if (auto* renderer = axObject ? axObject->renderer() : nullptr)
+        return renderer->isAnonymous() && renderer->isTablePart();
+    return false;
+}
+
+AccessibilityObject* AccessibilityTableRow::parentObject() const
+{
+    auto* parent = AccessibilityRenderObject::parentObject();
+    // For some combinations of display values given to <tr> / <tbody>, anonymous table rows / cells
+    // can end up parenting non-anonymous table rows in the render tree. Skip past these.
+    while (isAnonymousTablePart(parent))
+        parent = parent->parentObject();
+    return parent;
+}
+

Can we make isAnonymousTablePart() an AccessibilityObject or AccessibilityRenderObject method instead?

+AccessibilityObject* AccessibilityTableRow::parentObjectUnignored() const
+{
+    auto* parent = AccessibilityRenderObject::parentObjectUnignored();
+    while (isAnonymousTablePart(parent))
+        parent = parent->parentObjectUnignored();
+    return parent;
+}
+
We shouldn't need to override parentObjectUnignored since it is a composite of parentObject and isIgnored.