Add accessibility support to WKDataListSuggestionsView.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Jul 2019 17:28:41 +0000 (17:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Jul 2019 17:28:41 +0000 (17:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199772
<rdar://problem/47095851>

Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-07-13
Reviewed by Chris Fleizach.

Source/WebCore:

Localizable strings for accessibility announcements.

* en.lproj/Localizable.strings:

Source/WebKit:

Added accessibility announcement notifications to show, dismiss and selection change for the datalist suggestions view.
* UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
(-[WKDataListSuggestionsView notifyAccessibilityClients:]):
(-[WKDataListSuggestionsView moveSelectionByDirection:]):
(-[WKDataListSuggestionsView invalidate]):
(-[WKDataListSuggestionsView showSuggestionsDropdown:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247418 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/en.lproj/Localizable.strings
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm

index 9e5d9f3..802d6c3 100644 (file)
@@ -1,3 +1,15 @@
+2019-07-13  Andres Gonzalez  <andresg_22@apple.com>
+
+        Add accessibility support to WKDataListSuggestionsView.
+        https://bugs.webkit.org/show_bug.cgi?id=199772
+        <rdar://problem/47095851>
+
+        Reviewed by Chris Fleizach.
+
+        Localizable strings for accessibility announcements.
+
+        * en.lproj/Localizable.strings:
+
 2019-07-13  Chris Dumez  <cdumez@apple.com>
 
         Drop non thread-safe usage of WeakPtr in VideoFullscreenInterfaceAVKit
index a381069..8c9e9d6 100644 (file)
 /* Menu section heading for subtitles */
 "Subtitles" = "Subtitles";
 
+/* Accessibility announcement for the data list suggestions dropdown going away. */
+"Suggestions list hidden." = "Suggestions list hidden.";
+
+/* Accessibility announcement that the suggestions list became visible. The format argument is for the first option in the list. */
+"Suggestions list visible, %@" = "Suggestions list visible, %@";
+
 /* Undo action name */
 "Superscript (Undo action name)" = "Superscript";
 
index 25eef33..800ca2c 100644 (file)
@@ -1,3 +1,18 @@
+2019-07-13  Andres Gonzalez  <andresg_22@apple.com>
+
+        Add accessibility support to WKDataListSuggestionsView.
+        https://bugs.webkit.org/show_bug.cgi?id=199772
+        <rdar://problem/47095851>
+
+        Reviewed by Chris Fleizach.
+
+        Added accessibility announcement notifications to show, dismiss and selection change for the datalist suggestions view.
+        * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
+        (-[WKDataListSuggestionsView notifyAccessibilityClients:]):
+        (-[WKDataListSuggestionsView moveSelectionByDirection:]):
+        (-[WKDataListSuggestionsView invalidate]):
+        (-[WKDataListSuggestionsView showSuggestionsDropdown:]):
+
 2019-07-13  Zalan Bujtas  <zalan@apple.com>
 
         Cannot bring up custom media controls at all on v.youku.com
index 1c273e3..bedd164 100644 (file)
@@ -30,6 +30,7 @@
 
 #import "WebPageProxy.h"
 #import <WebCore/IntRect.h>
+#import <WebCore/LocalizedStrings.h>
 #import <pal/spi/cocoa/NSColorSPI.h>
 
 static const CGFloat dropdownTopMargin = 2;
@@ -352,6 +353,14 @@ void WebDataListSuggestionsDropdownMac::close()
     [_table setVisibleRect:[_enclosingWindow frame]];
 }
 
+- (void)notifyAccessibilityClients:(NSString *)info
+{
+    NSDictionary<NSAccessibilityNotificationUserInfoKey, id> *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+        NSAccessibilityPriorityKey, @(NSAccessibilityPriorityHigh),
+        NSAccessibilityAnnouncementKey, info, nil];
+    NSAccessibilityPostNotificationWithUserInfo(NSApp, NSAccessibilityAnnouncementRequestedNotification, userInfo);
+}
+
 - (void)moveSelectionByDirection:(const String&)direction
 {
     size_t size = _suggestions.size();
@@ -368,6 +377,10 @@ void WebDataListSuggestionsDropdownMac::close()
         newSelection = (direction == "Up") ? (size - 1) : 0;
 
     [_table setActiveRow:newSelection];
+
+    // Notify accessibility clients of new selection.
+    NSString *currentSelectedString = [self currentSelectedString];
+    [self notifyAccessibilityClients:currentSelectedString];
 }
 
 - (void)invalidate
@@ -383,6 +396,10 @@ void WebDataListSuggestionsDropdownMac::close()
     [[_view window] removeChildWindow:_enclosingWindow.get()];
     [_enclosingWindow close];
     _enclosingWindow = nil;
+
+    // Notify accessibility clients that datalist went away.
+    NSString *info = WEB_UI_STRING("Suggestions list hidden.", "Accessibility announcement for the data list suggestions dropdown going away.");
+    [self notifyAccessibilityClients:info];
 }
 
 - (NSRect)dropdownRectForElementRect:(const WebCore::IntRect&)rect
@@ -399,6 +416,11 @@ void WebDataListSuggestionsDropdownMac::close()
     [_table reload];
     [[_view window] addChildWindow:_enclosingWindow.get() ordered:NSWindowAbove];
     [[_table enclosingScrollView] flashScrollers];
+
+    // Notify accessibility clients of datalist becoming visible.
+    NSString *currentSelectedString = [self currentSelectedString];
+    NSString *info = [NSString stringWithFormat:WEB_UI_STRING("Suggestions list visible, %@", "Accessibility announcement that the suggestions list became visible. The format argument is for the first option in the list."), currentSelectedString];
+    [self notifyAccessibilityClients:info];
 }
 
 - (void)selectedRow:(NSTableView *)sender