Title: [280633] trunk
Revision
280633
Author
[email protected]
Date
2021-08-04 07:04:38 -0700 (Wed, 04 Aug 2021)

Log Message

Add support for aria-selected value changes in table cells.
https://bugs.webkit.org/show_bug.cgi?id=228756
<rdar://problem/81483071>

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/selected-state-changed-notifications.html

- Added the AXSelectedStateChangedNotification to notify AX clients that
the selected state of an object has changed.
- This notification is used in this patch for aria-selected value
changes in table cells.

* accessibility/AXLogger.cpp:
(WebCore::operator<<):
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::selectedStateChanged):
(WebCore::AXObjectCache::handleAttributeChange):
* accessibility/AXObjectCache.h:
* accessibility/ios/AXObjectCacheIOS.mm:
(WebCore::AXObjectCache::notificationPlatformName):
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::postPlatformNotification):

LayoutTests:

* accessibility/selected-state-changed-notifications-expected.txt: Added.
* accessibility/selected-state-changed-notifications.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280632 => 280633)


--- trunk/LayoutTests/ChangeLog	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/LayoutTests/ChangeLog	2021-08-04 14:04:38 UTC (rev 280633)
@@ -1,3 +1,14 @@
+2021-08-04  Andres Gonzalez  <[email protected]>
+
+        Add support for aria-selected value changes in table cells.
+        https://bugs.webkit.org/show_bug.cgi?id=228756
+        <rdar://problem/81483071>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/selected-state-changed-notifications-expected.txt: Added.
+        * accessibility/selected-state-changed-notifications.html: Added.
+
 2021-08-04  Cathie Chen  <[email protected]>
 
         REGRESSION (r277997) Images get stretched with aspect-ratio and max-width: x%

Added: trunk/LayoutTests/accessibility/selected-state-changed-notifications-expected.txt (0 => 280633)


--- trunk/LayoutTests/accessibility/selected-state-changed-notifications-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/selected-state-changed-notifications-expected.txt	2021-08-04 14:04:38 UTC (rev 280633)
@@ -0,0 +1,15 @@
+This is not aria-selected.	XYZ
+This test ensures that the AXSelectedStateChanged notification is fired when the value for the aria-selected attribute changes in grid cells.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS axSelectable.isSelected is false
+1 AXSelectedCellsChanged for element selectable
+PASS axSelectable.isSelected is true
+2 AXSelectedCellsChanged for element selectable
+PASS axSelectable.isSelected is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/selected-state-changed-notifications.html (0 => 280633)


--- trunk/LayoutTests/accessibility/selected-state-changed-notifications.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/selected-state-changed-notifications.html	2021-08-04 14:04:38 UTC (rev 280633)
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<table role="grid">
+    <tbody>
+        <tr role="row">
+            <td id="selectable" role="gridcell" aria-selected="false">This cell is not aria-selected.</td>
+            <td role="gridcell">XYZ</td>
+        </tr>
+    </tbody>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This test ensures that the AXSelectedStateChanged notification is fired when the value for the aria-selected attribute changes in grid cells.");
+
+    function toggleAriaSelectedState() {
+        var selectable = document.getElementById("selectable");
+        var isSelected = selectable.getAttribute('aria-selected') === 'true';
+        selectable.setAttribute('aria-selected', !isSelected);
+        selectable.textContent = isSelected ? "This is not aria-selected." : "This is aria-selected.";
+    };
+    selectable.addEventListener('click', toggleAriaSelectedState);
+
+    if (window.accessibilityController) {
+        window.jsTestIsAsync = true;
+
+        var notificationCount = 0;
+        accessibilityController.addNotificationListener((axElement, notification) => {
+            if (notification != "AXSelectedCellsChanged")
+                return;
+
+            debug(`${++notificationCount} ${notification} for element ${axElement.domIdentifier}`);
+        });
+
+        var axSelectable = accessibilityController.accessibleElementById("selectable");
+        shouldBeFalse("axSelectable.isSelected");
+
+        axSelectable.press();
+        setTimeout(async () => {
+            await waitFor(() => {
+                return notificationCount == 1;
+            });
+            shouldBeTrue("axSelectable.isSelected");
+
+            axSelectable.press();
+            await waitFor(() => {
+                return notificationCount == 2;
+            });
+            shouldBeFalse("axSelectable.isSelected");
+
+            finishJSTest();
+        }, 0);
+    }
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (280632 => 280633)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-08-04 14:04:38 UTC (rev 280633)
@@ -970,6 +970,7 @@
 accessibility/mac/aria-errormessage.html [ Skip ]
 accessibility/mac/pseudo-element-text-markers.html [ Skip ]
 accessibility/nested-textareas-value-changed-notifications.html [ Skip ]
+accessibility/selected-state-changed-notifications.html [ Skip ]
 
 # <rdar://problem/61066929> [ Stress GC ] flaky JSC::ExceptionScope::assertNoException crash under WebCore::ReadableStreamDefaultController
 webkit.org/b/211923 imported/w3c/web-platform-tests/fetch/api/basic/stream-safe-creation.any.html [ Pass Crash ]

Modified: trunk/Source/WebCore/ChangeLog (280632 => 280633)


--- trunk/Source/WebCore/ChangeLog	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/Source/WebCore/ChangeLog	2021-08-04 14:04:38 UTC (rev 280633)
@@ -1,3 +1,29 @@
+2021-08-04  Andres Gonzalez  <[email protected]>
+
+        Add support for aria-selected value changes in table cells.
+        https://bugs.webkit.org/show_bug.cgi?id=228756
+        <rdar://problem/81483071>
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/selected-state-changed-notifications.html
+
+        - Added the AXSelectedStateChangedNotification to notify AX clients that
+        the selected state of an object has changed.
+        - This notification is used in this patch for aria-selected value
+        changes in table cells.
+
+        * accessibility/AXLogger.cpp:
+        (WebCore::operator<<):
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::selectedStateChanged):
+        (WebCore::AXObjectCache::handleAttributeChange):
+        * accessibility/AXObjectCache.h:
+        * accessibility/ios/AXObjectCacheIOS.mm:
+        (WebCore::AXObjectCache::notificationPlatformName):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+
 2021-08-04  Martin Robinson  <[email protected]>
 
         Add a HashTraits implementation for LayoutUnit

Modified: trunk/Source/WebCore/accessibility/AXLogger.cpp (280632 => 280633)


--- trunk/Source/WebCore/accessibility/AXLogger.cpp	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/Source/WebCore/accessibility/AXLogger.cpp	2021-08-04 14:04:38 UTC (rev 280633)
@@ -393,6 +393,9 @@
     case AXObjectCache::AXNotification::AXSelectedChildrenChanged:
         stream << "AXSelectedChildrenChanged";
         break;
+    case AXObjectCache::AXNotification::AXSelectedStateChanged:
+        stream << "AXSelectedStateChanged";
+        break;
     case AXObjectCache::AXNotification::AXSelectedTextChanged:
         stream << "AXSelectedTextChanged";
         break;

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (280632 => 280633)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-08-04 14:04:38 UTC (rev 280633)
@@ -1299,6 +1299,17 @@
     postNotification(renderer, AXSelectedChildrenChanged, PostTarget::ObservableParent);
 }
 
+void AXObjectCache::selectedStateChanged(Node* node)
+{
+    // For a table cell, post AXSelectedStateChanged on the cell itself.
+    // For any other element, post AXSelectedChildrenChanged on the parent.
+    if (nodeHasRole(node, "gridcell") || nodeHasRole(node, "cell")
+        || nodeHasRole(node, "columnheader") || nodeHasRole(node, "rowheader"))
+        postNotification(node, AXSelectedStateChanged);
+    else
+        selectedChildrenChanged(node);
+}
+
 #ifndef NDEBUG
 void AXObjectCache::showIntent(const AXTextStateChangeIntent &intent)
 {
@@ -1806,7 +1817,7 @@
     else if (attrName == aria_checkedAttr)
         checkedStateChanged(element);
     else if (attrName == aria_selectedAttr)
-        selectedChildrenChanged(element);
+        selectedStateChanged(element);
     else if (attrName == aria_expandedAttr)
         handleAriaExpandedChange(element);
     else if (attrName == aria_hiddenAttr) {

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (280632 => 280633)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2021-08-04 14:04:38 UTC (rev 280633)
@@ -291,6 +291,7 @@
         AXNewDocumentLoadComplete,
         AXPageScrolled,
         AXSelectedChildrenChanged,
+        AXSelectedStateChanged,
         AXSelectedTextChanged,
         AXValueChanged,
         AXScrolledToAnchor,
@@ -463,6 +464,7 @@
     bool shouldProcessAttributeChange(const QualifiedName&, Element*);
     void selectedChildrenChanged(Node*);
     void selectedChildrenChanged(RenderObject*);
+    void selectedStateChanged(Node*);
     // Called by a node when text or a text equivalent (e.g. alt) attribute is changed.
     void textChanged(Node*);
     void handleActiveDescendantChanged(Node*);

Modified: trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm (280632 => 280633)


--- trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2021-08-04 14:04:38 UTC (rev 280633)
@@ -57,6 +57,9 @@
     case AXPageScrolled:
         name = "AXPageScrolled";
         break;
+    case AXSelectedStateChanged:
+        name = "AXSelectedCellsChanged";
+        break;
     case AXSelectedTextChanged:
         name = "AXSelectedTextChanged";
         break;

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (280632 => 280633)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2021-08-04 12:57:03 UTC (rev 280632)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2021-08-04 14:04:38 UTC (rev 280633)
@@ -343,6 +343,9 @@
         else
             macNotification = NSAccessibilitySelectedChildrenChangedNotification;
         break;
+    case AXSelectedStateChanged:
+        macNotification = NSAccessibilitySelectedCellsChangedNotification;
+        break;
     case AXSelectedTextChanged:
         macNotification = NSAccessibilitySelectedTextChangedNotification;
         break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to