Title: [293291] trunk
Revision
293291
Author
andresg...@apple.com
Date
2022-04-23 09:30:25 -0700 (Sat, 23 Apr 2022)

Log Message

AX ITM: Table row objects should return a non-null unignored parent even when a table object is not found in its ancestry.
https://bugs.webkit.org/show_bug.cgi?id=239606
<rdar://problem/92094205>

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/aria-expanded-supported-roles.html.
In addition, fixed test accessibility/mac/heading-clickpoint.html.

AccessibilityARIAGridRow::parentObjectUnignored was returning nullptr
if there was no table ancestor. This caused problems in isolated tree
mode where only the root object should have a null parent. With this
patch this method will return the table ancestor if one exists, its
parent in the AX tree otherwise.
Changed all classes in the AXObject hierarchy to return an AXObject for
the parentObjectUnignored method instead of an AXCoreObject.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::focusedObjectForPage):
Removed unnecessary downcast.
* accessibility/AccessibilityARIAGridRow.cpp:
(WebCore::AccessibilityARIAGridRow::parentObjectUnignored const):
(WebCore::AccessibilityARIAGridRow::parentTable const):
Rewrote this method using Accessibility::findAncestor.
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::parentObjectUnignored const):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::parentObjectUnignored const):
* accessibility/AccessibilityRenderObject.h:
* accessibility/AccessibilityTableCell.cpp:
(WebCore::AccessibilityTableCell::parentObjectUnignored const):
* accessibility/AccessibilityTableCell.h:

LayoutTests:

* accessibility/aria-expanded-supported-roles.html:
* accessibility/mac/heading-clickpoint-expected.txt:
* accessibility/mac/heading-clickpoint.html:
* platform/mac/accessibility/aria-expanded-supported-roles-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293290 => 293291)


--- trunk/LayoutTests/ChangeLog	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/LayoutTests/ChangeLog	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,3 +1,16 @@
+2022-04-23  Andres Gonzalez  <andresg...@apple.com>
+
+        AX ITM: Table row objects should return a non-null unignored parent even when a table object is not found in its ancestry.
+        https://bugs.webkit.org/show_bug.cgi?id=239606
+        <rdar://problem/92094205>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/aria-expanded-supported-roles.html:
+        * accessibility/mac/heading-clickpoint-expected.txt:
+        * accessibility/mac/heading-clickpoint.html:
+        * platform/mac/accessibility/aria-expanded-supported-roles-expected.txt:
+
 2022-04-23  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [ATSPI] WTR: add implementation for AccessibilityUIElement::domIdentifier

Modified: trunk/LayoutTests/accessibility/aria-expanded-supported-roles.html (293290 => 293291)


--- trunk/LayoutTests/accessibility/aria-expanded-supported-roles.html	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/LayoutTests/accessibility/aria-expanded-supported-roles.html	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,7 +1,10 @@
 <!DOCTYPE HTML>
 <html>
+<head>
+<script src=""
+</head>
 <body>
-<script src=""
+
 <div id="content">
 <div id="alert" role="alert" aria-expanded="true"></div>
 <div id="alertdialog" role="alertdialog" aria-expanded="true"></div>
@@ -87,19 +90,20 @@
 <div id="treegrid" role="treegrid" aria-expanded="true"></div>
 <div id="treeitem" role="treeitem" aria-expanded="true"></div>
 </div>
-<p id="description"></p>
-<div id="console"></div>
+
 <script>
-description("Verify which roles support aria-expanded.");
-if (window.accessibilityController) {
-    Array.from(document.getElementById("content").children).forEach(element => {
-        var axElement = accessibilityController.accessibleElementById(element.id);
-        if (axElement && axElement.isExpanded)
-            debug(axElement.role + " is expanded");
-    });
-    document.getElementById("content").style.visibility = "hidden";
-}
+    if (window.accessibilityController) {
+        let output = "Verify which roles support aria-expanded.\n";
+
+        Array.from(document.getElementById("content").children).forEach((element) => {
+            let axElement = accessibilityController.accessibleElementById(element.id);
+            if (axElement && axElement.isExpanded)
+                output += `${axElement.role} is expanded\n`;
+        });
+
+        debug(output);
+        document.getElementById("content").style.visibility = "hidden";
+    }
 </script>
-<script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/accessibility/mac/heading-clickpoint-expected.txt (293290 => 293291)


--- trunk/LayoutTests/accessibility/mac/heading-clickpoint-expected.txt	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/LayoutTests/accessibility/mac/heading-clickpoint-expected.txt	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,20 +1,13 @@
-Small heading
-
-A heading that is just a little bit wider
-
-Small heading Small heading
-
 This tests that the click points for headings should use the only child's clickpoint instead of taking the mid point (which may be on nothing).
+PASS: heading1.clickPointX === heading1.childAtIndex(0).clickPointX
+PASS: heading1.clickPointY === heading1.childAtIndex(0).clickPointY
+PASS: heading2.clickPointX === heading2.childAtIndex(0).clickPointX
+PASS: heading2.clickPointY === heading2.childAtIndex(0).clickPointY
+PASS: heading3.clickPointX == heading3.childAtIndex(0).clickPointX === false
 
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS heading1.clickPointX is heading1.childAtIndex(0).clickPointX
-PASS heading1.clickPointY is heading1.childAtIndex(0).clickPointY
-PASS heading2.clickPointX is heading2.childAtIndex(0).clickPointX
-PASS heading2.clickPointY is heading2.childAtIndex(0).clickPointY
-PASS heading3.clickPointX == heading3.childAtIndex(0).clickPointX is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
 
+
+

Modified: trunk/LayoutTests/accessibility/mac/heading-clickpoint.html (293290 => 293291)


--- trunk/LayoutTests/accessibility/mac/heading-clickpoint.html	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/LayoutTests/accessibility/mac/heading-clickpoint.html	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,47 +1,38 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
-<script src=""
+<script src=""
+<script src=""
 </head>
-<body id="body">
+<body>
 
-<h1 tabindex="0" id="heading1">Small heading</h1>
-<h1 tabindex="0" id="heading2"><a href="" heading that is just a little bit wider</a></h1>
+<div id="content">
+<h1 id="heading1">Small heading</h1>
+<h1 id="heading2"><a href="" heading that is just a little bit wider</a></h1>
 
-<h1 tabindex="0" id="heading3"><a href="" heading</a> <a href="" heading</a></h1>
+<h1 id="heading3"><a href="" heading</a> <a href="" heading</a></h1>
+</div>
 
-<p id="description"></p>
-<div id="console"></div>
-
 <script>
-
-    description("This tests that the click points for headings should use the only child's clickpoint instead of taking the mid point (which may be on nothing).");
-
     if (window.accessibilityController) {
+        let output = "This tests that the click points for headings should use the only child's clickpoint instead of taking the mid point (which may be on nothing).\n";
 
-        document.getElementById("heading1").focus();
-        var heading1 = accessibilityController.focusedElement;
-
+        var heading1 = accessibilityController.accessibleElementById("heading1");
         // Verify that the click point is the same as the child.
-        shouldBe("heading1.clickPointX", "heading1.childAtIndex(0).clickPointX");
-        shouldBe("heading1.clickPointY", "heading1.childAtIndex(0).clickPointY");
+        output += expect("heading1.clickPointX", "heading1.childAtIndex(0).clickPointX");
+        output += expect("heading1.clickPointY", "heading1.childAtIndex(0).clickPointY");
 
-        document.getElementById("heading2").focus();
-        var heading2 = accessibilityController.focusedElement;
+        var heading2 = accessibilityController.accessibleElementById("heading2");
+        output += expect("heading2.clickPointX", "heading2.childAtIndex(0).clickPointX");
+        output += expect("heading2.clickPointY", "heading2.childAtIndex(0).clickPointY");
 
-        shouldBe("heading2.clickPointX", "heading2.childAtIndex(0).clickPointX");
-        shouldBe("heading2.clickPointY", "heading2.childAtIndex(0).clickPointY");
-
-        document.getElementById("heading3").focus();
-        var heading3 = accessibilityController.focusedElement;
-
+        var heading3 = accessibilityController.accessibleElementById("heading3");
         // If there is more than one child, the click point should be the middle again, which means X point will be different.
-        shouldBeFalse("heading3.clickPointX == heading3.childAtIndex(0).clickPointX");
+        output += expect("heading3.clickPointX == heading3.childAtIndex(0).clickPointX", "false");
 
+        debug(output);
+        document.getElementById("content").style.visibility = "hidden";
     }
-
 </script>
-
-<script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/platform/glib/accessibility/aria-expanded-supported-roles-expected.txt (293290 => 293291)


--- trunk/LayoutTests/platform/glib/accessibility/aria-expanded-supported-roles-expected.txt	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/LayoutTests/platform/glib/accessibility/aria-expanded-supported-roles-expected.txt	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,8 +1,4 @@
 Verify which roles support aria-expanded.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
 AXRole: AXEmbedded is expanded
 AXRole: AXButton is expanded
 AXRole: AXCheckBox is expanded
@@ -17,6 +13,7 @@
 AXRole: AXRowHeader is expanded
 AXRole: AXToggleButton is expanded
 AXRole: AXTab is expanded
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-expanded-supported-roles-expected.txt (293290 => 293291)


--- trunk/LayoutTests/platform/mac/accessibility/aria-expanded-supported-roles-expected.txt	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-expanded-supported-roles-expected.txt	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,8 +1,4 @@
 Verify which roles support aria-expanded.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
 AXRole: AXGroup is expanded
 AXRole: AXButton is expanded
 AXRole: AXCheckBox is expanded
@@ -17,6 +13,7 @@
 AXRole: AXCell is expanded
 AXRole: AXCheckBox is expanded
 AXRole: AXRadioButton is expanded
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (293290 => 293291)


--- trunk/Source/WebCore/ChangeLog	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/ChangeLog	2022-04-23 16:30:25 UTC (rev 293291)
@@ -1,3 +1,39 @@
+2022-04-23  Andres Gonzalez  <andresg...@apple.com>
+
+        AX ITM: Table row objects should return a non-null unignored parent even when a table object is not found in its ancestry.
+        https://bugs.webkit.org/show_bug.cgi?id=239606
+        <rdar://problem/92094205>
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/aria-expanded-supported-roles.html.
+        In addition, fixed test accessibility/mac/heading-clickpoint.html.
+
+        AccessibilityARIAGridRow::parentObjectUnignored was returning nullptr
+        if there was no table ancestor. This caused problems in isolated tree
+        mode where only the root object should have a null parent. With this
+        patch this method will return the table ancestor if one exists, its
+        parent in the AX tree otherwise.
+        Changed all classes in the AXObject hierarchy to return an AXObject for
+        the parentObjectUnignored method instead of an AXCoreObject.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::focusedObjectForPage):
+        Removed unnecessary downcast.
+        * accessibility/AccessibilityARIAGridRow.cpp:
+        (WebCore::AccessibilityARIAGridRow::parentObjectUnignored const):
+        (WebCore::AccessibilityARIAGridRow::parentTable const):
+        Rewrote this method using Accessibility::findAncestor.
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::parentObjectUnignored const):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::parentObjectUnignored const):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/AccessibilityTableCell.cpp:
+        (WebCore::AccessibilityTableCell::parentObjectUnignored const):
+        * accessibility/AccessibilityTableCell.h:
+
 2022-04-23  Devin Rousso  <drou...@apple.com>
 
         fix a few ObjC memory management issues after r291361

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-04-23 16:30:25 UTC (rev 293291)
@@ -438,7 +438,7 @@
 
     // the HTML element, for example, is focusable but has an AX object that is ignored
     if (focus->accessibilityIsIgnored())
-        focus = downcast<AccessibilityObject>(focus->parentObjectUnignored());
+        focus = focus->parentObjectUnignored();
 
     return focus;
 }
@@ -1529,9 +1529,7 @@
 #elif USE(ATSPI)
         // ATSPI doesn't expose text nodes, so we need the parent
         // object which is the one implementing the text interface.
-        auto* parent = object->parentObjectUnignored();
-        if (is<AccessibilityObject>(parent))
-            object = downcast<AccessibilityObject>(parent);
+        object = object->parentObjectUnignored();
 #endif
     }
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp	2022-04-23 16:30:25 UTC (rev 293291)
@@ -113,27 +113,28 @@
 
     return nullptr;
 }
-    
+
 AccessibilityObject* AccessibilityARIAGridRow::parentObjectUnignored() const
 {
-    return parentTable();
+    if (auto* table = parentTable())
+        return table;
+    return AccessibilityTableRow::parentObjectUnignored();
 }
-    
+
 AccessibilityTable* AccessibilityARIAGridRow::parentTable() const
 {
     // The parent table might not be the direct ancestor of the row unfortunately. ARIA states that role="grid" should
     // only have "row" elements, but if not, we still should handle it gracefully by finding the right table.
-    for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
+    return downcast<AccessibilityTable>(Accessibility::findAncestor<AccessibilityObject>(*this, false, [this] (const auto& ancestor) {
         // The parent table for an ARIA grid row should be an ARIA table.
         // Unless the row is a native tr element.
-        if (is<AccessibilityTable>(*parent)) {
-            AccessibilityTable& tableParent = downcast<AccessibilityTable>(*parent);
-            if (tableParent.isExposable() && (tableParent.isAriaTable() || node()->hasTagName(HTMLNames::trTag)))
-                return &tableParent;
+        if (is<AccessibilityTable>(ancestor)) {
+            auto& ancestorTable = downcast<AccessibilityTable>(ancestor);
+            return ancestorTable.isExposable() && (ancestorTable.isAriaTable() || node()->hasTagName(HTMLNames::trTag));
         }
-    }
-    
-    return nullptr;
+
+        return false;
+    }));
 }
 
 AXCoreObject* AccessibilityARIAGridRow::headerObject()

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-04-23 16:30:25 UTC (rev 293291)
@@ -441,7 +441,7 @@
     return level;
 }
 
-AXCoreObject* AccessibilityObject::parentObjectUnignored() const
+AccessibilityObject* AccessibilityObject::parentObjectUnignored() const
 {
     return Accessibility::findAncestor<AccessibilityObject>(*this, false, [] (const AccessibilityObject& object) {
         return !object.accessibilityIsIgnored();

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2022-04-23 16:30:25 UTC (rev 293291)
@@ -370,7 +370,7 @@
     virtual AccessibilityObject* previousSiblingUnignored(int limit) const;
     AccessibilityObject* parentObject() const override { return nullptr; }
     AccessibilityObject* displayContentsParent() const;
-    AXCoreObject* parentObjectUnignored() const override;
+    AccessibilityObject* parentObjectUnignored() const override;
     AccessibilityObject* parentObjectIfExists() const override { return nullptr; }
     static AccessibilityObject* firstAccessibleObjectFromNode(const Node*);
     void findMatchingObjects(AccessibilitySearchCriteria*, AccessibilityChildrenVector&) override;

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2022-04-23 16:30:25 UTC (rev 293291)
@@ -535,7 +535,7 @@
     return nullptr;
 }
 
-AXCoreObject* AccessibilityRenderObject::parentObjectUnignored() const
+AccessibilityObject* AccessibilityRenderObject::parentObjectUnignored() const
 {
 #if USE(ATSPI)
     // Expose markers that are not direct children of a list item too.

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2022-04-23 16:30:25 UTC (rev 293291)
@@ -89,7 +89,7 @@
     AccessibilityObject* nextSibling() const override;
     AccessibilityObject* parentObject() const override;
     AccessibilityObject* parentObjectIfExists() const override;
-    AXCoreObject* parentObjectUnignored() const override;
+    AccessibilityObject* parentObjectUnignored() const override;
     AccessibilityObject* observableObject() const override;
     void linkedUIElements(AccessibilityChildrenVector&) const override;
     AccessibilityObject* titleUIElement() const override;

Modified: trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp	2022-04-23 16:30:25 UTC (rev 293291)
@@ -304,7 +304,7 @@
     return nullptr;
 }
 
-AXCoreObject* AccessibilityTableCell::parentObjectUnignored() const
+AccessibilityObject* AccessibilityTableCell::parentObjectUnignored() const
 {
     if (auto ownerParent = ariaOwnedByParent())
         return ownerParent;

Modified: trunk/Source/WebCore/accessibility/AccessibilityTableCell.h (293290 => 293291)


--- trunk/Source/WebCore/accessibility/AccessibilityTableCell.h	2022-04-23 15:09:11 UTC (rev 293290)
+++ trunk/Source/WebCore/accessibility/AccessibilityTableCell.h	2022-04-23 16:30:25 UTC (rev 293291)
@@ -65,7 +65,7 @@
     AccessibilityTableRow* parentRow() const;
     virtual AccessibilityTable* parentTable() const;
     AccessibilityRole determineAccessibilityRole() final;
-    AXCoreObject* parentObjectUnignored() const override;
+    AccessibilityObject* parentObjectUnignored() const override;
 
     int m_rowIndex;
     int m_axColIndexFromRow;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to