AX: Make form validation accessible on iOS
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2017 18:07:17 +0000 (18:07 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2017 18:07:17 +0000 (18:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168400

Reviewed by Chris Dumez.

Hide the popover content of form validation from accessibility (since its not interactable)
and instead announce the message.

* platform/ios/ValidationBubbleIOS.mm:
(WebCore::ValidationBubble::show):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/ios/ValidationBubbleIOS.mm

index 01d4586..34de653 100644 (file)
@@ -1,3 +1,16 @@
+2017-02-16  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Make form validation accessible on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=168400
+
+        Reviewed by Chris Dumez.
+
+        Hide the popover content of form validation from accessibility (since its not interactable)
+        and instead announce the message.
+
+        * platform/ios/ValidationBubbleIOS.mm:
+        (WebCore::ValidationBubble::show):
+
 2017-02-16  Simon Fraser  <simon.fraser@apple.com>
 
         Clean up use of some CALayer-related SPI
index 95806dc..d2ceb14 100644 (file)
@@ -41,6 +41,9 @@ SOFT_LINK_CLASS(UIKit, UITapGestureRecognizer);
 SOFT_LINK_CLASS(UIKit, UIView);
 SOFT_LINK_CLASS(UIKit, UIViewController);
 SOFT_LINK_CONSTANT(UIKit, UIFontTextStyleCallout, UIFontTextStyle);
+SOFT_LINK_CONSTANT(UIKit, UIAccessibilityAnnouncementNotification, UIAccessibilityNotifications);
+#define UIAccessibilityPostNotification getUIAccessibilityPostNotification
+SOFT_LINK(UIKit, UIAccessibilityPostNotification, void, (UIAccessibilityNotifications n, id argument), (n, argument));
 
 @interface WebValidationBubbleTapRecognizer : NSObject
 @end
@@ -134,7 +137,12 @@ void ValidationBubble::show()
     // Protect the validation bubble so it stays alive until it is effectively presented. UIKit does not deal nicely with
     // dismissing a popover that is being presented.
     RefPtr<ValidationBubble> protectedThis(this);
-    [m_presentingViewController presentViewController:m_popoverController.get() animated:NO completion:[protectedThis]() { }];
+    [m_presentingViewController presentViewController:m_popoverController.get() animated:NO completion:[protectedThis]() {
+        // Hide this popover from VoiceOver and instead announce the message.
+        [protectedThis->m_popoverController.get().view setAccessibilityElementsHidden:YES];
+    }];
+
+    UIAccessibilityPostNotification(getUIAccessibilityAnnouncementNotification(), m_message);
 }
 
 static UIViewController *fallbackViewController(UIView *view)