Changeset 288117 in webkit


Ignore:
Timestamp:
Jan 18, 2022 8:45:07 AM (6 months ago)
Author:
commit-queue@webkit.org
Message:

AX: Improve support for aria-owns in aria trees
https://bugs.webkit.org/show_bug.cgi?id=233383

Patch by Sepand Parhami <sparhami@apple.com> on 2022-01-18
Reviewed by Chris Fleizach.

Source/WebCore:

Better supports aria-owns in trees by following children specified through ownership similar
to how DOM children are handled. Previously, you could use aria-owns for only one level of
ownership. This change also fixes tree items being included twice (once as a DOM child and
another time via aria-owns) and supports using both DOM children and aria-owns on a single
element. This change only affects trees via a change to ariaTreeRows and does not change
aria-owns behavior in general.

Tests: accessibility/mac/treeitem-row-delegation.html

accessibility/mac/treeitem-row-delegation-poorly-formed.html

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::ariaTreeRows):

  • accessibility/AccessibilityObject.h:

LayoutTests:

Adds test cases for additional specified behavior of aria-owns in trees as well as tests to
make sure incorrect aria-owns usage does not cause crashes.

  • accessibility/mac/treeitem-row-delegation-expected.txt:
  • accessibility/mac/treeitem-row-delegation-poorly-formed-expected.txt: Added.
  • accessibility/mac/treeitem-row-delegation-poorly-formed.html: Added.
  • accessibility/mac/treeitem-row-delegation.html:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r288112 r288117  
     12022-01-18  Sepand Parhami  <sparhami@apple.com>
     2
     3        AX: Improve support for aria-owns in aria trees
     4        https://bugs.webkit.org/show_bug.cgi?id=233383
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Adds test cases for additional specified behavior of aria-owns in trees as well as tests to
     9        make sure incorrect aria-owns usage does not cause crashes.
     10
     11        * accessibility/mac/treeitem-row-delegation-expected.txt:
     12        * accessibility/mac/treeitem-row-delegation-poorly-formed-expected.txt: Added.
     13        * accessibility/mac/treeitem-row-delegation-poorly-formed.html: Added.
     14        * accessibility/mac/treeitem-row-delegation.html:
     15
    1162022-01-18  Arcady Goldmints-Orlov  <agoldmints@igalia.com>
    217
  • trunk/LayoutTests/accessibility/mac/treeitem-row-delegation-expected.txt

    r273328 r288117  
    1 This tests that a treeitem was a group that uses aria-owns will report its disclosed rows correctly.
     1This tests that a treeitem with a group that uses aria-owns will report its disclosed rows correctly.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    55
    6 PASS treeitem2.isEqual(accessibilityController.accessibleElementById('group1-item1')) is true
     6PASS tree.childrenCount is 7
     7PASS treeitem1.isEqual(accessibilityController.accessibleElementById('item-1')) is true
     8PASS treeitem1_1.isEqual(accessibilityController.accessibleElementById('group1-item1')) is true
     9PASS treeitem1_2.isEqual(accessibilityController.accessibleElementById('group1-item2')) is true
     10PASS treeitem1_3.isEqual(accessibilityController.accessibleElementById('group1-item3')) is true
     11PASS treeitem1_2_1.isEqual(accessibilityController.accessibleElementById('group2-item1')) is true
     12PASS treeitem1_2_2.isEqual(accessibilityController.accessibleElementById('group2-item2')) is true
     13PASS treeitem2.isEqual(accessibilityController.accessibleElementById('item-2')) is true
    714PASS successfullyParsed is true
    815
    916TEST COMPLETE
     17Jaguar
    1018Jungle Animals
    11 Lions
     19Birds
     20Reptiles
     21Cats
     22Lion
     23Domestic Animals
  • trunk/LayoutTests/accessibility/mac/treeitem-row-delegation.html

    r273328 r288117  
    99
    1010<div id="tree" role="tree">
     11    <div id="group2-item2" role="treeitem" aria-level="3" aria-setsize="2" aria-posinset="2" aria-current="page">Jaguar</div>
    1112    <div id="item-1" role="treeitem" aria-level="1" aria-expanded="true" tabindex="0">Jungle Animals
    12         <div role="group" aria-owns="group1-item1 group1-item2 group1-item3"></div>
     13        <div role="group" aria-owns="group1-item2 group1-item3 non-existent-item1">
     14          <div id="group1-item3" role="treeitem" aria-level="2" aria-setsize="3" aria-posinset="3" aria-current="page">Birds</div>
     15          <div id="group1-item1" role="treeitem" aria-level="2" aria-setsize="3" aria-posinset="1" aria-current="page">Reptiles</div>
     16        </div>
    1317    </div>
    14     <div id="group1-item1" role="treeitem" aria-level="2" aria-setsize="3" aria-posinset="1" aria-current="page">Lions</div>
     18    <div id="group1-item2" role="treeitem" aria-level="2" aria-expanded="true" aria-setsize="1" aria-posinset="2" aria-current="page">Cats
     19        <div role="group" aria-owns="group2-item1 group2-item2"></div>
     20    </div>
     21    <div id="group2-item1" role="treeitem" aria-level="3" aria-posinset="1" aria-setsize="2" aria-current="page">Lion</div>
     22    <div id="item-2" role="treeitem" aria-level="1" aria-expanded="false" tabindex="-1">Domestic Animals</div>
    1523</div>
    1624
    1725<script>
    18     description("This tests that a treeitem was a group that uses aria-owns will report its disclosed rows correctly.");
     26    description("This tests that a treeitem with a group that uses aria-owns will report its disclosed rows correctly.");
    1927
    2028    if (window.accessibilityController) {
    21        var treeitem = accessibilityController.accessibleElementById("item-1");
    22        var treeitem2 = treeitem.disclosedRowAtIndex(0);
    23        shouldBeTrue("treeitem2.isEqual(accessibilityController.accessibleElementById('group1-item1'))");
     29       var tree = accessibilityController.accessibleElementById("tree");
     30       var treeitem1 = tree.rowAtIndex(0);
     31       var treeitem1_1 = treeitem1.disclosedRowAtIndex(0);
     32       var treeitem1_2 = treeitem1.disclosedRowAtIndex(1);
     33       var treeitem1_3 = treeitem1.disclosedRowAtIndex(4);
     34       var treeitem1_2_1 = treeitem1_2.disclosedRowAtIndex(0);
     35       var treeitem1_2_2 = treeitem1_2.disclosedRowAtIndex(1);
     36       var treeitem2 = tree.rowAtIndex(6);
     37       shouldBe("tree.childrenCount", "7");
     38       shouldBeTrue("treeitem1.isEqual(accessibilityController.accessibleElementById('item-1'))");
     39       shouldBeTrue("treeitem1_1.isEqual(accessibilityController.accessibleElementById('group1-item1'))");
     40       shouldBeTrue("treeitem1_2.isEqual(accessibilityController.accessibleElementById('group1-item2'))");
     41       shouldBeTrue("treeitem1_3.isEqual(accessibilityController.accessibleElementById('group1-item3'))");
     42       shouldBeTrue("treeitem1_2_1.isEqual(accessibilityController.accessibleElementById('group2-item1'))");
     43       shouldBeTrue("treeitem1_2_2.isEqual(accessibilityController.accessibleElementById('group2-item2'))");
     44       shouldBeTrue("treeitem2.isEqual(accessibilityController.accessibleElementById('item-2'))");
    2445    }
    2546</script>
  • trunk/Source/WebCore/ChangeLog

    r288116 r288117  
     12022-01-18  Sepand Parhami  <sparhami@apple.com>
     2
     3        AX: Improve support for aria-owns in aria trees
     4        https://bugs.webkit.org/show_bug.cgi?id=233383
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Better supports aria-owns in trees by following children specified through ownership similar
     9        to how DOM children are handled. Previously, you could use aria-owns for only one level of
     10        ownership. This change also fixes tree items being included twice (once as a DOM child and
     11        another time via aria-owns) and supports using both DOM children and aria-owns on a single
     12        element. This change only affects trees via a change to ariaTreeRows and does not change
     13        aria-owns behavior in general.
     14
     15        Tests: accessibility/mac/treeitem-row-delegation.html
     16               accessibility/mac/treeitem-row-delegation-poorly-formed.html
     17
     18        * accessibility/AccessibilityObject.cpp:
     19        (WebCore::AccessibilityObject::ariaTreeRows):
     20        * accessibility/AccessibilityObject.h:
     21
    1222022-01-18  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r288100 r288117  
    18941894}
    18951895
    1896 void AccessibilityObject::ariaTreeRows(AccessibilityChildrenVector& result)
    1897 {
    1898     // If the element specifies its tree rows through aria-owns, return that first.
     1896void AccessibilityObject::ariaTreeRows(AccessibilityChildrenVector& rows, AccessibilityChildrenVector& ancestors)
     1897{
    18991898    AccessibilityChildrenVector ariaOwns;
    19001899    ariaOwnsElements(ariaOwns);
    1901     if (ariaOwns.size()) {
    1902         result.appendVector(ariaOwns);
    1903         return;
    1904     }
    1905    
     1900   
     1901    ancestors.append(this);
     1902
     1903    // The ordering of rows is first DOM children *not* in aria-owns, followed by all specified
     1904    // in aria-owns.
    19061905    for (const auto& child : children()) {
    19071906        // Add tree items as the rows.
    1908         if (child->roleValue() == AccessibilityRole::TreeItem)
    1909             result.append(child);
     1907        if (child->roleValue() == AccessibilityRole::TreeItem) {
     1908            // Child appears both as a direct child and aria-owns, we should use the ordering as
     1909            // described in aria-owns for this child.
     1910            if (ariaOwns.contains(child))
     1911                continue;
     1912           
     1913            // The result set may already contain the child through aria-owns. For example,
     1914            // a treeitem sitting under the tree root, which is owned elsewhere in the tree.
     1915            if (rows.contains(child))
     1916                continue;
     1917
     1918            rows.append(child);
     1919        }
    19101920
    19111921        // Now see if this item also has rows hiding inside of it.
    1912         child->ariaTreeRows(result);
    1913     }
     1922        if (is<AccessibilityObject>(*child))
     1923            downcast<AccessibilityObject>(*child).ariaTreeRows(rows, ancestors);
     1924    }
     1925
     1926    // Now go through the aria-owns elements.
     1927    for (const auto& child : ariaOwns) {
     1928        // Avoid a circular reference via aria-owns by checking if our parent
     1929        // path includes this child. Currently, looking up the aria-owns parent
     1930        // path itself could be expensive, so we track it separately.
     1931        if (ancestors.contains(child))
     1932            continue;
     1933       
     1934        // Add tree items as the rows.
     1935        if (child->roleValue() == AccessibilityRole::TreeItem) {
     1936            // Hopefully a flow that does not occur often in practice, but if someone were to include
     1937            // the owned child ealier in the top level of the tree, then reference via aria-owns later,
     1938            // move it to the right place.
     1939            if (rows.contains(child))
     1940                rows.removeFirst(child);
     1941           
     1942            rows.append(child);
     1943        }
     1944
     1945        // Now see if this item also has rows hiding inside of it.
     1946        if (is<AccessibilityObject>(*child))
     1947            downcast<AccessibilityObject>(*child).ariaTreeRows(rows, ancestors);
     1948    }
     1949   
     1950    ancestors.removeLast();
     1951}
     1952
     1953void AccessibilityObject::ariaTreeRows(AccessibilityChildrenVector& rows    )
     1954{
     1955    AccessibilityChildrenVector ancestors;
     1956    ariaTreeRows(rows, ancestors);
    19141957}
    19151958   
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r288027 r288117  
    827827    std::optional<SimpleRange> visibleCharacterRange() const override;
    828828
     829    void ariaTreeRows(AccessibilityChildrenVector& rows, AccessibilityChildrenVector& ancestors);
     830   
    829831#if PLATFORM(COCOA) && ENABLE(MODEL_ELEMENT)
    830832    Vector<RetainPtr<id>> modelElementChildren() override;
Note: See TracChangeset for help on using the changeset viewer.