⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 293291 in webkit


Ignore:
Timestamp:
Apr 23, 2022, 9:30:25 AM (4 years ago)
Author:
Andres Gonzalez
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:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293289 r293291  
     12022-04-23  Andres Gonzalez  <andresg_22@apple.com>
     2
     3        AX ITM: Table row objects should return a non-null unignored parent even when a table object is not found in its ancestry.
     4        https://bugs.webkit.org/show_bug.cgi?id=239606
     5        <rdar://problem/92094205>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        * accessibility/aria-expanded-supported-roles.html:
     10        * accessibility/mac/heading-clickpoint-expected.txt:
     11        * accessibility/mac/heading-clickpoint.html:
     12        * platform/mac/accessibility/aria-expanded-supported-roles-expected.txt:
     13
    1142022-04-23  Carlos Garcia Campos  <cgarcia@igalia.com>
    215
  • trunk/LayoutTests/accessibility/aria-expanded-supported-roles.html

    r283078 r293291  
    11<!DOCTYPE HTML>
    22<html>
     3<head>
     4<script src="../resources/js-test.js"></script>
     5</head>
    36<body>
    4 <script src="../resources/js-test-pre.js"></script>
     7
    58<div id="content">
    69<div id="alert" role="alert" aria-expanded="true"></div>
     
    8891<div id="treeitem" role="treeitem" aria-expanded="true"></div>
    8992</div>
    90 <p id="description"></p>
    91 <div id="console"></div>
     93
    9294<script>
    93 description("Verify which roles support aria-expanded.");
    94 if (window.accessibilityController) {
    95     Array.from(document.getElementById("content").children).forEach(element => {
    96         var axElement = accessibilityController.accessibleElementById(element.id);
    97         if (axElement && axElement.isExpanded)
    98             debug(axElement.role + " is expanded");
    99     });
    100     document.getElementById("content").style.visibility = "hidden";
    101 }
     95    if (window.accessibilityController) {
     96        let output = "Verify which roles support aria-expanded.\n";
     97
     98        Array.from(document.getElementById("content").children).forEach((element) => {
     99            let axElement = accessibilityController.accessibleElementById(element.id);
     100            if (axElement && axElement.isExpanded)
     101                output += `${axElement.role} is expanded\n`;
     102        });
     103
     104        debug(output);
     105        document.getElementById("content").style.visibility = "hidden";
     106    }
    102107</script>
    103 <script src="../resources/js-test-post.js"></script>
    104108</body>
    105109</html>
  • trunk/LayoutTests/accessibility/mac/heading-clickpoint-expected.txt

    r187799 r293291  
    1 Small heading
     1This 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).
     2PASS: heading1.clickPointX === heading1.childAtIndex(0).clickPointX
     3PASS: heading1.clickPointY === heading1.childAtIndex(0).clickPointY
     4PASS: heading2.clickPointX === heading2.childAtIndex(0).clickPointX
     5PASS: heading2.clickPointY === heading2.childAtIndex(0).clickPointY
     6PASS: heading3.clickPointX == heading3.childAtIndex(0).clickPointX === false
    27
    3 A heading that is just a little bit wider
    4 
    5 Small heading Small heading
    6 
    7 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).
    8 
    9 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    10 
    11 
    12 PASS heading1.clickPointX is heading1.childAtIndex(0).clickPointX
    13 PASS heading1.clickPointY is heading1.childAtIndex(0).clickPointY
    14 PASS heading2.clickPointX is heading2.childAtIndex(0).clickPointX
    15 PASS heading2.clickPointY is heading2.childAtIndex(0).clickPointY
    16 PASS heading3.clickPointX == heading3.childAtIndex(0).clickPointX is false
    178PASS successfullyParsed is true
    189
    1910TEST COMPLETE
    2011
     12
     13
  • trunk/LayoutTests/accessibility/mac/heading-clickpoint.html

    r187799 r293291  
    22<html>
    33<head>
    4 <script src="../../resources/js-test-pre.js"></script>
     4<script src="../../resources/js-test.js"></script>
     5<script src="../../resources/accessibility-helper.js"></script>
    56</head>
    6 <body id="body">
     7<body>
    78
    8 <h1 tabindex="0" id="heading1">Small heading</h1>
    9 <h1 tabindex="0" id="heading2"><a href="#">A heading that is just a little bit wider</a></h1>
     9<div id="content">
     10<h1 id="heading1">Small heading</h1>
     11<h1 id="heading2"><a href="#">A heading that is just a little bit wider</a></h1>
    1012
    11 <h1 tabindex="0" id="heading3"><a href="#">Small heading</a> <a href="#">Small heading</a></h1>
    12 
    13 <p id="description"></p>
    14 <div id="console"></div>
     13<h1 id="heading3"><a href="#">Small heading</a> <a href="#">Small heading</a></h1>
     14</div>
    1515
    1616<script>
     17    if (window.accessibilityController) {
     18        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";
    1719
    18     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).");
     20        var heading1 = accessibilityController.accessibleElementById("heading1");
     21        // Verify that the click point is the same as the child.
     22        output += expect("heading1.clickPointX", "heading1.childAtIndex(0).clickPointX");
     23        output += expect("heading1.clickPointY", "heading1.childAtIndex(0).clickPointY");
    1924
    20     if (window.accessibilityController) {
     25        var heading2 = accessibilityController.accessibleElementById("heading2");
     26        output += expect("heading2.clickPointX", "heading2.childAtIndex(0).clickPointX");
     27        output += expect("heading2.clickPointY", "heading2.childAtIndex(0).clickPointY");
    2128
    22         document.getElementById("heading1").focus();
    23         var heading1 = accessibilityController.focusedElement;
     29        var heading3 = accessibilityController.accessibleElementById("heading3");
     30        // If there is more than one child, the click point should be the middle again, which means X point will be different.
     31        output += expect("heading3.clickPointX == heading3.childAtIndex(0).clickPointX", "false");
    2432
    25         // Verify that the click point is the same as the child.
    26         shouldBe("heading1.clickPointX", "heading1.childAtIndex(0).clickPointX");
    27         shouldBe("heading1.clickPointY", "heading1.childAtIndex(0).clickPointY");
    28 
    29         document.getElementById("heading2").focus();
    30         var heading2 = accessibilityController.focusedElement;
    31 
    32         shouldBe("heading2.clickPointX", "heading2.childAtIndex(0).clickPointX");
    33         shouldBe("heading2.clickPointY", "heading2.childAtIndex(0).clickPointY");
    34 
    35         document.getElementById("heading3").focus();
    36         var heading3 = accessibilityController.focusedElement;
    37 
    38         // If there is more than one child, the click point should be the middle again, which means X point will be different.
    39         shouldBeFalse("heading3.clickPointX == heading3.childAtIndex(0).clickPointX");
    40 
     33        debug(output);
     34        document.getElementById("content").style.visibility = "hidden";
    4135    }
    42 
    4336</script>
    44 
    45 <script src="../../resources/js-test-post.js"></script>
    4637</body>
    4738</html>
  • trunk/LayoutTests/platform/glib/accessibility/aria-expanded-supported-roles-expected.txt

    r283078 r293291  
    11Verify which roles support aria-expanded.
    2 
    3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    4 
    5 
    62AXRole: AXEmbedded is expanded
    73AXRole: AXButton is expanded
     
    1814AXRole: AXToggleButton is expanded
    1915AXRole: AXTab is expanded
     16
    2017PASS successfullyParsed is true
    2118
  • trunk/LayoutTests/platform/mac/accessibility/aria-expanded-supported-roles-expected.txt

    r283078 r293291  
    11Verify which roles support aria-expanded.
    2 
    3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    4 
    5 
    62AXRole: AXGroup is expanded
    73AXRole: AXButton is expanded
     
    1814AXRole: AXCheckBox is expanded
    1915AXRole: AXRadioButton is expanded
     16
    2017PASS successfullyParsed is true
    2118
  • trunk/Source/WebCore/ChangeLog

    r293290 r293291  
     12022-04-23  Andres Gonzalez  <andresg_22@apple.com>
     2
     3        AX ITM: Table row objects should return a non-null unignored parent even when a table object is not found in its ancestry.
     4        https://bugs.webkit.org/show_bug.cgi?id=239606
     5        <rdar://problem/92094205>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        Test: accessibility/aria-expanded-supported-roles.html.
     10        In addition, fixed test accessibility/mac/heading-clickpoint.html.
     11
     12        AccessibilityARIAGridRow::parentObjectUnignored was returning nullptr
     13        if there was no table ancestor. This caused problems in isolated tree
     14        mode where only the root object should have a null parent. With this
     15        patch this method will return the table ancestor if one exists, its
     16        parent in the AX tree otherwise.
     17        Changed all classes in the AXObject hierarchy to return an AXObject for
     18        the parentObjectUnignored method instead of an AXCoreObject.
     19
     20        * accessibility/AXObjectCache.cpp:
     21        (WebCore::AXObjectCache::focusedObjectForPage):
     22        Removed unnecessary downcast.
     23        * accessibility/AccessibilityARIAGridRow.cpp:
     24        (WebCore::AccessibilityARIAGridRow::parentObjectUnignored const):
     25        (WebCore::AccessibilityARIAGridRow::parentTable const):
     26        Rewrote this method using Accessibility::findAncestor.
     27        * accessibility/AccessibilityObject.cpp:
     28        (WebCore::AccessibilityObject::parentObjectUnignored const):
     29        * accessibility/AccessibilityObject.h:
     30        * accessibility/AccessibilityRenderObject.cpp:
     31        (WebCore::AccessibilityRenderObject::parentObjectUnignored const):
     32        * accessibility/AccessibilityRenderObject.h:
     33        * accessibility/AccessibilityTableCell.cpp:
     34        (WebCore::AccessibilityTableCell::parentObjectUnignored const):
     35        * accessibility/AccessibilityTableCell.h:
     36
    1372022-04-23  Devin Rousso  <drousso@apple.com>
    238
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r293186 r293291  
    439439    // the HTML element, for example, is focusable but has an AX object that is ignored
    440440    if (focus->accessibilityIsIgnored())
    441         focus = downcast<AccessibilityObject>(focus->parentObjectUnignored());
     441        focus = focus->parentObjectUnignored();
    442442
    443443    return focus;
     
    15301530        // ATSPI doesn't expose text nodes, so we need the parent
    15311531        // object which is the one implementing the text interface.
    1532         auto* parent = object->parentObjectUnignored();
    1533         if (is<AccessibilityObject>(parent))
    1534             object = downcast<AccessibilityObject>(parent);
     1532        object = object->parentObjectUnignored();
    15351533#endif
    15361534    }
  • trunk/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp

    r257589 r293291  
    114114    return nullptr;
    115115}
    116    
     116
    117117AccessibilityObject* AccessibilityARIAGridRow::parentObjectUnignored() const
    118118{
    119     return parentTable();
     119    if (auto* table = parentTable())
     120        return table;
     121    return AccessibilityTableRow::parentObjectUnignored();
    120122}
    121    
     123
    122124AccessibilityTable* AccessibilityARIAGridRow::parentTable() const
    123125{
    124126    // The parent table might not be the direct ancestor of the row unfortunately. ARIA states that role="grid" should
    125127    // only have "row" elements, but if not, we still should handle it gracefully by finding the right table.
    126     for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
     128    return downcast<AccessibilityTable>(Accessibility::findAncestor<AccessibilityObject>(*this, false, [this] (const auto& ancestor) {
    127129        // The parent table for an ARIA grid row should be an ARIA table.
    128130        // Unless the row is a native tr element.
    129         if (is<AccessibilityTable>(*parent)) {
    130             AccessibilityTable& tableParent = downcast<AccessibilityTable>(*parent);
    131             if (tableParent.isExposable() && (tableParent.isAriaTable() || node()->hasTagName(HTMLNames::trTag)))
    132                 return &tableParent;
     131        if (is<AccessibilityTable>(ancestor)) {
     132            auto& ancestorTable = downcast<AccessibilityTable>(ancestor);
     133            return ancestorTable.isExposable() && (ancestorTable.isAriaTable() || node()->hasTagName(HTMLNames::trTag));
    133134        }
    134     }
    135    
    136     return nullptr;
     135
     136        return false;
     137    }));
    137138}
    138139
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r292963 r293291  
    442442}
    443443
    444 AXCoreObject* AccessibilityObject::parentObjectUnignored() const
     444AccessibilityObject* AccessibilityObject::parentObjectUnignored() const
    445445{
    446446    return Accessibility::findAncestor<AccessibilityObject>(*this, false, [] (const AccessibilityObject& object) {
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r292774 r293291  
    371371    AccessibilityObject* parentObject() const override { return nullptr; }
    372372    AccessibilityObject* displayContentsParent() const;
    373     AXCoreObject* parentObjectUnignored() const override;
     373    AccessibilityObject* parentObjectUnignored() const override;
    374374    AccessibilityObject* parentObjectIfExists() const override { return nullptr; }
    375375    static AccessibilityObject* firstAccessibleObjectFromNode(const Node*);
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r293212 r293291  
    536536}
    537537
    538 AXCoreObject* AccessibilityRenderObject::parentObjectUnignored() const
     538AccessibilityObject* AccessibilityRenderObject::parentObjectUnignored() const
    539539{
    540540#if USE(ATSPI)
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h

    r293006 r293291  
    9090    AccessibilityObject* parentObject() const override;
    9191    AccessibilityObject* parentObjectIfExists() const override;
    92     AXCoreObject* parentObjectUnignored() const override;
     92    AccessibilityObject* parentObjectUnignored() const override;
    9393    AccessibilityObject* observableObject() const override;
    9494    void linkedUIElements(AccessibilityChildrenVector&) const override;
  • trunk/Source/WebCore/accessibility/AccessibilityTableCell.cpp

    r291863 r293291  
    305305}
    306306
    307 AXCoreObject* AccessibilityTableCell::parentObjectUnignored() const
     307AccessibilityObject* AccessibilityTableCell::parentObjectUnignored() const
    308308{
    309309    if (auto ownerParent = ariaOwnedByParent())
  • trunk/Source/WebCore/accessibility/AccessibilityTableCell.h

    r273715 r293291  
    6666    virtual AccessibilityTable* parentTable() const;
    6767    AccessibilityRole determineAccessibilityRole() final;
    68     AXCoreObject* parentObjectUnignored() const override;
     68    AccessibilityObject* parentObjectUnignored() const override;
    6969
    7070    int m_rowIndex;
Note: See TracChangeset for help on using the changeset viewer.