Title: [272490] trunk
Revision
272490
Author
[email protected]
Date
2021-02-08 07:40:52 -0800 (Mon, 08 Feb 2021)

Log Message

Add support for aria-sort change notifications.
https://bugs.webkit.org/show_bug.cgi?id=221495

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/aria-sort-changed-notification.html

This patch adds support for aria-sort changes. Some code cleanup by
using the notificationPlatformName helper function.

* accessibility/AXLogger.cpp:
(WebCore::operator<<):
Logging of the new notification.
* accessibility/AXObjectCache.cpp:
Handles the aria-sort change notification. Updates the isolated tree.
(WebCore::AXObjectCache::handleAttributeChange):
(WebCore::AXObjectCache::updateIsolatedTree):
* accessibility/AXObjectCache.h:
* accessibility/ios/AXObjectCacheIOS.mm:
(WebCore::AXObjectCache::notificationPlatformName):
Helper to map AXCore notifications to platform notifications.
(WebCore::AXObjectCache::postPlatformNotification):
Handles the AXSortDirectionChanged notification. Some code cleanup using
the notificationPlatformName helper.
* accessibility/ios/WebAccessibilityObjectWrapperIOS.h:
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper postNotification:]):
To be overridden by system AX bundles.
(-[WebAccessibilityObjectWrapper accessibilitySortDirection]):
Only ascending and descending sort directions are relevant for clients.
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateNodeProperty):
Updates the SortDirection property.
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::postPlatformNotification):
Handles the AXSortDirectionChanged notification.

Tools:

* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::sortDirection const):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
* WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::sortDirection const):
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::currentStateValue const):
(WTR::AccessibilityUIElement::sortDirection const):

LayoutTests:

* accessibility/aria-sort-changed-notification-expected.txt: Added.
* accessibility/aria-sort-changed-notification.html: Added.
* accessibility/aria-sort-expected.txt:
* accessibility/aria-sort.html:
Calls sortDirection property on the JS accessible element instead of
retrieving the aria-sort attribute. This matches more accurately what an
actual client would do. Changed the expected file accordingly.
* accessibility/ios-simulator/aria-sort-ios-expected.txt:
* accessibility/ios-simulator/aria-sort-ios.html:
Same as in the Mac test above.
* platform/ios/TestExpectations:
Added the new test to be run on the ios-simulator.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272489 => 272490)


--- trunk/LayoutTests/ChangeLog	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/ChangeLog	2021-02-08 15:40:52 UTC (rev 272490)
@@ -1,3 +1,23 @@
+2021-02-08  Andres Gonzalez  <[email protected]>
+
+        Add support for aria-sort change notifications.
+        https://bugs.webkit.org/show_bug.cgi?id=221495
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/aria-sort-changed-notification-expected.txt: Added.
+        * accessibility/aria-sort-changed-notification.html: Added.
+        * accessibility/aria-sort-expected.txt:
+        * accessibility/aria-sort.html:
+        Calls sortDirection property on the JS accessible element instead of
+        retrieving the aria-sort attribute. This matches more accurately what an
+        actual client would do. Changed the expected file accordingly.
+        * accessibility/ios-simulator/aria-sort-ios-expected.txt:
+        * accessibility/ios-simulator/aria-sort-ios.html:
+        Same as in the Mac test above.
+        * platform/ios/TestExpectations:
+        Added the new test to be run on the ios-simulator.
+
 2021-02-08  Manuel Rego Casasnovas  <[email protected]>
 
         [GTK] event.ctrlKey and other are false in keydown event

Added: trunk/LayoutTests/accessibility/aria-sort-changed-notification-expected.txt (0 => 272490)


--- trunk/LayoutTests/accessibility/aria-sort-changed-notification-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/aria-sort-changed-notification-expected.txt	2021-02-08 15:40:52 UTC (rev 272490)
@@ -0,0 +1,20 @@
+This tests that changing the aria-sort value results in a SortDirectionChanged notification.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS axColumnHeader.sortDirection is 'AXAscendingSortDirection'
+Toggling aria-sort
+AXSortDirectionChanged notification for Account
+PASS axColumnHeader.sortDirection is 'AXDescendingSortDirection'
+Setting aria-sort to a random value
+AXSortDirectionChanged notification for Account
+PASS axColumnHeader.sortDirection is 'AXUnknownSortDirection'
+Toggling aria-sort
+AXSortDirectionChanged notification for Account
+PASS axColumnHeader.sortDirection is 'AXAscendingSortDirection'
+PASS notificationCount is 3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/aria-sort-changed-notification.html (0 => 272490)


--- trunk/LayoutTests/accessibility/aria-sort-changed-notification.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/aria-sort-changed-notification.html	2021-02-08 15:40:52 UTC (rev 272490)
@@ -0,0 +1,78 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<table id="content" role="grid">
+    <thead>
+        <tr aria-label="Header" role="row">
+            <th id="Account" role="columnheader" _onclick_="toggleAriaSort()" aria-sort="ascending" aria-label="Acount Name" title="Account Name">Account Name</th>
+        </tr>
+    </thead>
+</table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that changing the aria-sort value results in a SortDirectionChanged notification.");
+    window.jsTestIsAsync = true;
+
+    if (window.accessibilityController) {
+        var notificationCount = 0;
+
+        accessibilityController.addNotificationListener(function(element, notification) {
+            if (notification != "AXSortDirectionChanged")
+                return;
+
+            ++notificationCount;
+            debug(notification + " notification for " + element.domIdentifier);
+        });
+
+        function toggleAriaSort(element) {
+            var sortingState = element.getAttribute("aria-sort");
+            if (sortingState == "ascending")
+                element.setAttribute("aria-sort", "descending");
+            else
+                element.setAttribute("aria-sort", "ascending");
+        }
+
+        var columnHeader = document.getElementById("Account");
+        var axColumnHeader = accessibilityController.accessibleElementById("Account");
+        shouldBe("axColumnHeader.sortDirection", "'AXAscendingSortDirection'");
+
+        debug("Toggling aria-sort");
+        toggleAriaSort(columnHeader);
+        setTimeout(async function() {
+            await waitFor(() => {
+                return notificationCount == 1;//axColumnHeader.sortDirection == "AXDescendingSortDirection";
+            });
+            shouldBe("axColumnHeader.sortDirection", "'AXDescendingSortDirection'");
+
+            debug("Setting aria-sort to a random value");
+            columnHeader.setAttribute("aria-sort", "blah blah blah");
+            await waitFor(() => {
+                return notificationCount == 2;//axColumnHeader.sortDirection == "AXUnknownSortDirection";
+            });
+            shouldBe("axColumnHeader.sortDirection", "'AXUnknownSortDirection'");
+
+            debug("Toggling aria-sort");
+            toggleAriaSort(columnHeader);
+            await waitFor(() => {
+                return notificationCount == 3;//axColumnHeader.sortDirection == "AXAscendingSortDirection";
+            });
+            shouldBe("axColumnHeader.sortDirection", "'AXAscendingSortDirection'");
+
+            shouldBe("notificationCount", "3");
+
+            document.getElementById("content").style.visibility = "hidden";
+            accessibilityController.removeNotificationListener();
+            finishJSTest();
+        }, 0);
+    }
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/accessibility/aria-sort-expected.txt (272489 => 272490)


--- trunk/LayoutTests/accessibility/aria-sort-expected.txt	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/accessibility/aria-sort-expected.txt	2021-02-08 15:40:52 UTC (rev 272490)
@@ -6,11 +6,11 @@
 
 
 PASS col1.isAttributeSupported('AXSortDirection') is true
-PASS col1.stringAttributeValue('AXSortDirection') is 'AXAscendingSortDirection'
+PASS col1.sortDirection is 'AXAscendingSortDirection'
 PASS col2.isAttributeSupported('AXSortDirection') is true
-PASS col2.stringAttributeValue('AXSortDirection') is 'AXDescendingSortDirection'
+PASS col2.sortDirection is 'AXDescendingSortDirection'
 PASS col3.isAttributeSupported('AXSortDirection') is true
-PASS col3.stringAttributeValue('AXSortDirection') is 'AXUnknownSortDirection'
+PASS col3.sortDirection is 'AXUnknownSortDirection'
 PASS row1.isAttributeSupported('AXSortDirection') is false
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/accessibility/aria-sort.html (272489 => 272490)


--- trunk/LayoutTests/accessibility/aria-sort.html	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/accessibility/aria-sort.html	2021-02-08 15:40:52 UTC (rev 272490)
@@ -30,25 +30,24 @@
 
 <script>
     description("This tests that aria-sort is exposed correctly to the Mac accessibility API.");
-    
+
     if (window.accessibilityController) {
         var col1 = accessibilityController.accessibleElementById("col1");
         shouldBe("col1.isAttributeSupported('AXSortDirection')", "true");
-        shouldBe("col1.stringAttributeValue('AXSortDirection')", "'AXAscendingSortDirection'");
-        
+        shouldBe("col1.sortDirection", "'AXAscendingSortDirection'");
+
         var col2 = accessibilityController.accessibleElementById("col2");
         shouldBe("col2.isAttributeSupported('AXSortDirection')", "true");
-        shouldBe("col2.stringAttributeValue('AXSortDirection')", "'AXDescendingSortDirection'");
-        
+        shouldBe("col2.sortDirection", "'AXDescendingSortDirection'");
+
         var col3 = accessibilityController.accessibleElementById("col3");
         shouldBe("col3.isAttributeSupported('AXSortDirection')", "true");
-        shouldBe("col3.stringAttributeValue('AXSortDirection')", "'AXUnknownSortDirection'");
-        
+        shouldBe("col3.sortDirection", "'AXUnknownSortDirection'");
+
         var row1 = accessibilityController.accessibleElementById("row1");
         shouldBe("row1.isAttributeSupported('AXSortDirection')", "false");
     }
 </script>
-
 <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/accessibility/ios-simulator/aria-sort-ios-expected.txt (272489 => 272490)


--- trunk/LayoutTests/accessibility/ios-simulator/aria-sort-ios-expected.txt	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/accessibility/ios-simulator/aria-sort-ios-expected.txt	2021-02-08 15:40:52 UTC (rev 272490)
@@ -5,10 +5,10 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS col1.stringAttributeValue('AXSortDirection') is 'ascending'
-PASS col2.stringAttributeValue('AXSortDirection') is 'descending'
-PASS col3.stringAttributeValue('AXSortDirection') is 'other'
-PASS row1.stringAttributeValue('AXSortDirection') is null
+PASS col1.sortDirection is 'AXAscendingSortDirection'
+PASS col2.sortDirection is 'AXDescendingSortDirection'
+PASS col3.sortDirection is 'AXUnknownSortDirection'
+PASS row1.sortDirection is 'AXUnknownSortDirection'
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/accessibility/ios-simulator/aria-sort-ios.html (272489 => 272490)


--- trunk/LayoutTests/accessibility/ios-simulator/aria-sort-ios.html	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/accessibility/ios-simulator/aria-sort-ios.html	2021-02-08 15:40:52 UTC (rev 272490)
@@ -27,22 +27,21 @@
 
 <script>
     description("This tests that aria-sort is exposed correctly to the iOS accessibility API.");
-    
+
     if (window.accessibilityController) {
         var col1 = accessibilityController.accessibleElementById("col1");
-        shouldBe("col1.stringAttributeValue('AXSortDirection')", "'ascending'");
-        
+        shouldBe("col1.sortDirection", "'AXAscendingSortDirection'");
+
         var col2 = accessibilityController.accessibleElementById("col2");
-        shouldBe("col2.stringAttributeValue('AXSortDirection')", "'descending'");
-        
+        shouldBe("col2.sortDirection", "'AXDescendingSortDirection'");
+
         var col3 = accessibilityController.accessibleElementById("col3");
-        shouldBe("col3.stringAttributeValue('AXSortDirection')", "'other'");
-        
+        shouldBe("col3.sortDirection", "'AXUnknownSortDirection'");
+
         var row1 = accessibilityController.accessibleElementById("row1");
-        shouldBe("row1.stringAttributeValue('AXSortDirection')", "null");
+        shouldBe("row1.sortDirection", "'AXUnknownSortDirection'");
     }
 </script>
-
 <script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (272489 => 272490)


--- trunk/LayoutTests/platform/ios/TestExpectations	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2021-02-08 15:40:52 UTC (rev 272490)
@@ -2166,6 +2166,7 @@
 # Enable "aria-current" tests for iOS.
 webkit.org/b/149297 accessibility/aria-current.html [ Pass ]
 accessibility/aria-current-state-changed-notification.html [ Pass ]
+accessibility/aria-sort-changed-notification.html [ Pass ]
 
 # Enable "aria-table-attributes" test for iOS
 webkit.org/b/150366 accessibility/aria-table-attributes.html [ Pass ]

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (272489 => 272490)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-02-08 15:40:52 UTC (rev 272490)
@@ -968,6 +968,8 @@
 accessibility/mac/isolated-tree-mode-on-off.html [ Skip ]
 accessibility/aria-current-state-changed-notification.html [ Skip ]
 accessibility/aria-current.html [ Skip ]
+accessibility/aria-sort-changed-notification.html [ Skip ]
+accessibility/aria-sort.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 ]
@@ -1236,4 +1238,4 @@
 webkit.org/b/221300 [ BigSur ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framerate.html [ Failure ]
 webkit.org/b/221300 [ BigSur ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framesize.html [ Failure ]
 
-webkit.org/b/221369 [ BigSur+ ] media/media-source/media-source-webm-append-buffer-after-abort.html [ Skip ]
\ No newline at end of file
+webkit.org/b/221369 [ BigSur+ ] media/media-source/media-source-webm-append-buffer-after-abort.html [ Skip ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (272489 => 272490)


--- trunk/LayoutTests/platform/win/TestExpectations	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/LayoutTests/platform/win/TestExpectations	2021-02-08 15:40:52 UTC (rev 272490)
@@ -1422,6 +1422,7 @@
 webkit.org/b/140798 [ Debug ] accessibility/aria-namefrom-author.html [ Skip ] # Debug assertion
 webkit.org/b/140798 [ Release ] accessibility/aria-sort.html [ Failure ]
 webkit.org/b/140798 [ Debug ] accessibility/aria-sort.html [ Skip ] # Debug assertion
+accessibility/aria-sort-changed-notification.html [ Skip ]
 webkit.org/b/140798 [ Release ] accessibility/aria-tables.html [ Failure ]
 webkit.org/b/140798 [ Debug ] accessibility/aria-tables.html [ Skip ] # Debug assertion
 webkit.org/b/140798 [ Release ] accessibility/aria-text-role.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (272489 => 272490)


--- trunk/Source/WebCore/ChangeLog	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/ChangeLog	2021-02-08 15:40:52 UTC (rev 272490)
@@ -1,3 +1,42 @@
+2021-02-08  Andres Gonzalez  <[email protected]>
+
+        Add support for aria-sort change notifications.
+        https://bugs.webkit.org/show_bug.cgi?id=221495
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/aria-sort-changed-notification.html
+
+        This patch adds support for aria-sort changes. Some code cleanup by
+        using the notificationPlatformName helper function.
+
+        * accessibility/AXLogger.cpp:
+        (WebCore::operator<<):
+        Logging of the new notification.
+        * accessibility/AXObjectCache.cpp:
+        Handles the aria-sort change notification. Updates the isolated tree.
+        (WebCore::AXObjectCache::handleAttributeChange):
+        (WebCore::AXObjectCache::updateIsolatedTree):
+        * accessibility/AXObjectCache.h:
+        * accessibility/ios/AXObjectCacheIOS.mm:
+        (WebCore::AXObjectCache::notificationPlatformName):
+        Helper to map AXCore notifications to platform notifications.
+        (WebCore::AXObjectCache::postPlatformNotification):
+        Handles the AXSortDirectionChanged notification. Some code cleanup using
+        the notificationPlatformName helper.
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.h:
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper postNotification:]):
+        To be overridden by system AX bundles.
+        (-[WebAccessibilityObjectWrapper accessibilitySortDirection]):
+        Only ascending and descending sort directions are relevant for clients.
+        * accessibility/isolatedtree/AXIsolatedTree.cpp:
+        (WebCore::AXIsolatedTree::updateNodeProperty):
+        Updates the SortDirection property.
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+        Handles the AXSortDirectionChanged notification.
+
 2021-02-08  Frédéric Wang  <[email protected]>
 
         Perform layout before running Editor::findString

Modified: trunk/Source/WebCore/accessibility/AXLogger.cpp (272489 => 272490)


--- trunk/Source/WebCore/accessibility/AXLogger.cpp	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/AXLogger.cpp	2021-02-08 15:40:52 UTC (rev 272490)
@@ -444,6 +444,9 @@
     case AXObjectCache::AXNotification::AXRequiredStatusChanged:
         stream << "AXRequiredStatusChanged";
         break;
+    case AXObjectCache::AXNotification::AXSortDirectionChanged:
+        stream << "AXSortDirectionChanged";
+        break;
     case AXObjectCache::AXNotification::AXTextChanged:
         stream << "AXTextChanged";
         break;

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (272489 => 272490)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-02-08 15:40:52 UTC (rev 272490)
@@ -1782,6 +1782,8 @@
         postNotification(element, AXObjectCache::AXReadOnlyStatusChanged);
     else if (attrName == aria_requiredAttr)
         postNotification(element, AXObjectCache::AXRequiredStatusChanged);
+    else if (attrName == aria_sortAttr)
+        postNotification(element, AXObjectCache::AXSortDirectionChanged);
     else
         postNotification(element, AXObjectCache::AXAriaAttributeChanged);
 }
@@ -3197,6 +3199,9 @@
     case AXCheckedStateChanged:
         tree->updateNodeProperty(object, AXPropertyName::IsChecked);
         break;
+    case AXSortDirectionChanged:
+        tree->updateNodeProperty(object, AXPropertyName::SortDirection);
+        break;
     case AXIdAttributeChanged:
         tree->updateNodeProperty(object, AXPropertyName::IdentifierAttribute);
         break;
@@ -3266,6 +3271,9 @@
         case AXCheckedStateChanged:
             tree->updateNodeProperty(*notification.first, AXPropertyName::IsChecked);
             break;
+        case AXSortDirectionChanged:
+            tree->updateNodeProperty(*notification.first, AXPropertyName::SortDirection);
+            break;
         case AXIdAttributeChanged:
             tree->updateNodeProperty(*notification.first, AXPropertyName::IdentifierAttribute);
             break;

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (272489 => 272490)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2021-02-08 15:40:52 UTC (rev 272490)
@@ -307,6 +307,7 @@
         AXPressedStateChanged,
         AXReadOnlyStatusChanged,
         AXRequiredStatusChanged,
+        AXSortDirectionChanged,
         AXTextChanged,
         AXElementBusyChanged,
         AXDraggingStarted,
@@ -382,6 +383,7 @@
 #endif
 
 protected:
+    static String notificationPlatformName(AXNotification);
     void postPlatformNotification(AXCoreObject*, AXNotification);
     void platformHandleFocusedUIElementChanged(Node* oldFocusedNode, Node* newFocusedNode);
 

Modified: trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm (272489 => 272490)


--- trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2021-02-08 15:40:52 UTC (rev 272490)
@@ -42,17 +42,42 @@
     obj->setWrapper(wrapper.get());
 }
 
+String AXObjectCache::notificationPlatformName(AXNotification notification)
+{
+    String name;
+
+    switch (notification) {
+    case AXActiveDescendantChanged:
+    case AXFocusedUIElementChanged:
+        name = "AXFocusChanged";
+        break;
+    case AXCheckedStateChanged:
+    case AXValueChanged:
+        name = "AXValueChanged";
+        break;
+    case AXCurrentStateChanged:
+        name = "AXCurrentStateChanged";
+        break;
+    case AXSortDirectionChanged:
+        name = "AXSortDirectionChanged";
+        break;
+    default:
+        break;
+    }
+
+    return name;
+}
+
 void AXObjectCache::postPlatformNotification(AXCoreObject* obj, AXNotification notification)
 {
     if (!obj)
         return;
 
-    NSString *notificationString = nil;
+    String notificationName = AXObjectCache::notificationPlatformName(notification);
     switch (notification) {
     case AXActiveDescendantChanged:
     case AXFocusedUIElementChanged:
         [obj->wrapper() postFocusChangeNotification];
-        notificationString = @"AXFocusChanged";
         break;
     case AXSelectedTextChanged:
         [obj->wrapper() postSelectedTextChangeNotification];
@@ -78,7 +103,6 @@
     case AXCheckedStateChanged:
     case AXValueChanged:
         [obj->wrapper() postValueChangedNotification];
-        notificationString = @"AXValueChanged";
         break;
     case AXExpandedChanged:
         [obj->wrapper() postExpandedChangedNotification];
@@ -85,15 +109,17 @@
         break;
     case AXCurrentStateChanged:
         [obj->wrapper() postCurrentStateChangedNotification];
-        notificationString = @"AXCurrentStateChanged";
         break;
+    case AXSortDirectionChanged:
+        [obj->wrapper() postNotification:notificationName];
+        break;
     default:
         break;
     }
 
     // Used by DRT to know when notifications are posted.
-    if (notificationString)
-        [obj->wrapper() accessibilityPostedNotification:notificationString];
+    if (!notificationName.isEmpty())
+        [obj->wrapper() accessibilityPostedNotification:notificationName];
 }
 
 void AXObjectCache::postTextStateChangePlatformNotification(AXCoreObject* object, const AXTextStateChangeIntent&, const VisibleSelection&)

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h (272489 => 272490)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h	2021-02-08 15:40:52 UTC (rev 272490)
@@ -67,7 +67,7 @@
 - (void)postValueChangedNotification;
 - (void)postExpandedChangedNotification;
 - (void)postCurrentStateChangedNotification;
-
+- (void)postNotification:(NSString *)notificationName;
 @end
 
 #endif // ENABLE(ACCESSIBILITY) && PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (272489 => 272490)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2021-02-08 15:40:52 UTC (rev 272490)
@@ -2017,6 +2017,11 @@
     // The UIKit accessibility wrapper will override and post appropriate notification.
 }
 
+- (void)postNotification:(NSString *)notificationName
+{
+    // The UIKit accessibility wrapper will override and post appropriate notification.
+}
+
 // These will be used by the UIKit wrapper to calculate an appropriate description of scroll status.
 - (CGPoint)_accessibilityScrollPosition
 {
@@ -3056,17 +3061,14 @@
 {
     if (![self _prepareAccessibilityCall])
         return nil;
-    
+
     switch (self.axBackingObject->sortDirection()) {
     case AccessibilitySortDirection::Ascending:
-        return @"ascending";
+        return @"AXAscendingSortDirection";
     case AccessibilitySortDirection::Descending:
-        return @"descending";
-    case AccessibilitySortDirection::Other:
-        return @"other";
-    case AccessibilitySortDirection::Invalid:
-    case AccessibilitySortDirection::None:
-        return nil;
+        return @"AXDescendingSortDirection";
+    default:
+        return @"AXUnknownSortDirection";
     }
 }
 

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (272489 => 272490)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2021-02-08 15:40:52 UTC (rev 272490)
@@ -260,6 +260,9 @@
     case AXPropertyName::IsChecked:
         propertyMap.set(AXPropertyName::IsChecked, axObject.isChecked());
         break;
+    case AXPropertyName::SortDirection:
+        propertyMap.set(AXPropertyName::SortDirection, static_cast<int>(axObject.sortDirection()));
+        break;
     case AXPropertyName::IdentifierAttribute:
         propertyMap.set(AXPropertyName::IdentifierAttribute, axObject.identifierAttribute().isolatedCopy());
         break;

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (272489 => 272490)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2021-02-08 15:40:52 UTC (rev 272490)
@@ -368,6 +368,9 @@
     case AXExpandedChanged:
         macNotification = @"AXExpandedChanged";
         break;
+    case AXSortDirectionChanged:
+        macNotification = @"AXSortDirectionChanged";
+        break;
     case AXMenuClosed:
         macNotification = (id)kAXMenuClosedNotification;
         break;

Modified: trunk/Tools/ChangeLog (272489 => 272490)


--- trunk/Tools/ChangeLog	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Tools/ChangeLog	2021-02-08 15:40:52 UTC (rev 272490)
@@ -1,3 +1,20 @@
+2021-02-08  Andres Gonzalez  <[email protected]>
+
+        Add support for aria-sort change notifications.
+        https://bugs.webkit.org/show_bug.cgi?id=221495
+
+        Reviewed by Chris Fleizach.
+
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+        (WTR::AccessibilityUIElement::sortDirection const):
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::sortDirection const):
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::currentStateValue const):
+        (WTR::AccessibilityUIElement::sortDirection const):
+
 2021-02-08  Philippe Normand  <[email protected]>
 
         [GLib] Permission request API for MediaKeySystem access support

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (272489 => 272490)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp	2021-02-08 15:40:52 UTC (rev 272490)
@@ -113,6 +113,7 @@
 #if !PLATFORM(COCOA) || !HAVE(ACCESSIBILITY)
 JSRetainPtr<JSStringRef> AccessibilityUIElement::domIdentifier() const { return nullptr; }
 JSRetainPtr<JSStringRef> AccessibilityUIElement::currentStateValue() const { return nullptr; }
+JSRetainPtr<JSStringRef> AccessibilityUIElement::sortDirection() const { return nullptr; }
 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker(AccessibilityTextMarker*) { return nullptr; }
 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker(AccessibilityTextMarker*) { return nullptr; }
 RefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousWordStartTextMarkerForTextMarker(AccessibilityTextMarker*) { return nullptr; }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (272489 => 272490)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h	2021-02-08 15:40:52 UTC (rev 272490)
@@ -174,6 +174,7 @@
     bool isExpanded() const;
     bool isChecked() const;
     JSRetainPtr<JSStringRef> currentStateValue() const;
+    JSRetainPtr<JSStringRef> sortDirection() const;
     bool isIndeterminate() const;
     bool isVisible() const;
     bool isOnScreen() const;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (272489 => 272490)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl	2021-02-08 15:40:52 UTC (rev 272490)
@@ -93,6 +93,7 @@
     readonly attribute boolean isExpanded;
     readonly attribute boolean isChecked;
     readonly attribute DOMString currentStateValue;
+    readonly attribute DOMString sortDirection;
     readonly attribute boolean isIndeterminate;
     readonly attribute boolean isVisible;
     readonly attribute boolean isCollapsed;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (272489 => 272490)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2021-02-08 15:40:52 UTC (rev 272490)
@@ -627,6 +627,14 @@
     return nullptr;
 }
 
+JSRetainPtr<JSStringRef> AccessibilityUIElement::sortDirection() const
+{
+    id value = [m_element accessibilitySortDirection];
+    if ([value isKindOfClass:[NSString class]])
+        return [value createJSStringRef];
+    return nullptr;
+}
+
 int AccessibilityUIElement::hierarchicalLevel() const
 {
     return 0;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (272489 => 272490)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2021-02-08 13:52:53 UTC (rev 272489)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2021-02-08 15:40:52 UTC (rev 272490)
@@ -998,6 +998,14 @@
     return nullptr;
 }
 
+JSRetainPtr<JSStringRef> AccessibilityUIElement::sortDirection() const
+{
+    id value = attributeValue(m_element.get(), NSAccessibilitySortDirectionAttribute);
+    if ([value isKindOfClass:[NSString class]])
+        return [value createJSStringRef];
+    return nullptr;
+}
+
 int AccessibilityUIElement::hierarchicalLevel() const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to