AX: iOS: VoiceOver can't access attachments in mail messages
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jun 2016 21:27:04 +0000 (21:27 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jun 2016 21:27:04 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158198

Reviewed by Joanmarie Diggs.

Source/WebCore:

Replaced elements, like attachemnts, were not being exposed in the attributed string returned to VoiceOver.
Make sure they are exposed with the attachment character, pointing to the actual element.

Test: accessibility/ios-simulator/attributed-string-for-range.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(AccessibilityUnignoredAncestor):
(-[WebAccessibilityObjectWrapper _stringForRange:attributed:]):

Tools:

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::stringForRange):
(AccessibilityUIElement::attributedStringForRange):
(AccessibilityUIElement::attributedStringRangeIsMisspelled):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::attributedStringForRange):
(WTR::AccessibilityUIElement::attributedStringRangeIsMisspelled):

LayoutTests:

* accessibility/ios-simulator/attributed-string-for-range.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ios-simulator/attributed-string-for-range-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/attributed-string-for-range.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

index 70e1d5c..275d949 100644 (file)
@@ -1,3 +1,12 @@
+2016-06-01  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: iOS: VoiceOver can't access attachments in mail messages
+        https://bugs.webkit.org/show_bug.cgi?id=158198
+
+        Reviewed by Joanmarie Diggs.
+
+        * accessibility/ios-simulator/attributed-string-for-range.html: Added.
+
 2016-06-01  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r201488.
diff --git a/LayoutTests/accessibility/ios-simulator/attributed-string-for-range-expected.txt b/LayoutTests/accessibility/ios-simulator/attributed-string-for-range-expected.txt
new file mode 100644 (file)
index 0000000..fe77fa2
--- /dev/null
@@ -0,0 +1,27 @@
+hello     world
+This test ensures that attributed string for range works
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Attributed string: hello  {
+    UIAccessibilityTokenFontFamily = "Times New Roman";
+    UIAccessibilityTokenFontName = "Times New Roman";
+    UIAccessibilityTokenFontSize = 16;
+}{
+    UIAccessibilityTokenAttachment = "WebAccessibilityObjectWrapper: cake";
+}  {
+    UIAccessibilityTokenFontFamily = "Times New Roman";
+    UIAccessibilityTokenFontName = "Times New Roman";
+    UIAccessibilityTokenFontSize = 16;
+}{
+    UIAccessibilityTokenAttachment = "WebAccessibilityObjectWrapper: title, subtitle, action";
+} {
+    UIAccessibilityTokenFontFamily = "Times New Roman";
+    UIAccessibilityTokenFontName = "Times New Roman";
+    UIAccessibilityTokenFontSize = 16;
+}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/attributed-string-for-range.html b/LayoutTests/accessibility/ios-simulator/attributed-string-for-range.html
new file mode 100644 (file)
index 0000000..98cbe35
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script>
+var successfullyParsed = false;
+</script>
+<script>
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<div id="content">
+hello 
+
+<img src="resources/cake.png" alt="cake"> 
+<attachment id="attachment" title="title" subtitle="subtitle" action="action" progress="0.5"></attachment>
+
+world
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This test ensures that attributed string for range works");
+
+    if (window.accessibilityController) {
+
+        var obj = accessibilityController.accessibleElementById("content");
+        var text = obj.attributedStringForRange(0, 10);
+        debug("Attributed string: " + text);
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
index 73390c5..7e39f3a 100644 (file)
@@ -1,3 +1,19 @@
+2016-06-01  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: iOS: VoiceOver can't access attachments in mail messages
+        https://bugs.webkit.org/show_bug.cgi?id=158198
+
+        Reviewed by Joanmarie Diggs.
+
+        Replaced elements, like attachemnts, were not being exposed in the attributed string returned to VoiceOver.
+        Make sure they are exposed with the attachment character, pointing to the actual element.
+
+        Test: accessibility/ios-simulator/attributed-string-for-range.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (AccessibilityUnignoredAncestor):
+        (-[WebAccessibilityObjectWrapper _stringForRange:attributed:]):
+
 2016-06-01  Jer Noble  <jer.noble@apple.com>
 
         setVideoFullscreenGravity() has no effect on the fullscreen video layer
index c6ecd4b..9367040 100644 (file)
 
 #import <CoreText/CoreText.h>
 
+enum {
+    NSAttachmentCharacter = 0xfffc    /* To denote attachments. */
+};
+
 @interface NSObject (AccessibilityPrivate)
 - (void)_accessibilityUnregister;
 - (NSString *)accessibilityLabel;
@@ -106,6 +110,7 @@ static NSString * const UIAccessibilityTokenBold = @"UIAccessibilityTokenBold";
 static NSString * const UIAccessibilityTokenItalic = @"UIAccessibilityTokenItalic";
 static NSString * const UIAccessibilityTokenUnderline = @"UIAccessibilityTokenUnderline";
 static NSString * const UIAccessibilityTokenLanguage = @"UIAccessibilityTokenLanguage";
+static NSString * const UIAccessibilityTokenAttachment = @"UIAccessibilityTokenAttachment";
 
 static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityObjectWrapper *wrapper)
 {
@@ -2285,10 +2290,14 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     Class returnClass = attributed ? [NSMutableAttributedString class] : [NSMutableString class];
     id returnValue = [[(NSString *)[returnClass alloc] init] autorelease];
     
+    const unichar attachmentChar = NSAttachmentCharacter;
     NSInteger count = [array count];
     for (NSInteger k = 0; k < count; ++k) {
         id object = [array objectAtIndex:k];
 
+        if (attributed && [object isKindOfClass:[WebAccessibilityObjectWrapper class]])
+            object = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithCharacters:&attachmentChar length:1] attributes:@{ UIAccessibilityTokenAttachment : object }] autorelease];
+        
         if (![object isKindOfClass:returnClass])
             continue;
         
@@ -2855,13 +2864,15 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     return m_object->clickPoint();
 }
 
-#ifndef NDEBUG
 - (NSString *)description
 {
+#ifndef NDEBUG
     CGRect frame = [self accessibilityFrame];
     return [NSString stringWithFormat:@"Role: (%d) - Text: %@: Value: %@ -- Frame: %f %f %f %f", m_object ? m_object->roleValue() : 0, [self accessibilityLabel], [self accessibilityValue], frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
-}
+#else
+    return [NSString stringWithFormat:@"%@: %@", [self class], [self accessibilityLabel]];
 #endif
+}
 
 @end
 
index 2ba0c85..b1ef1ae 100644 (file)
@@ -1,3 +1,18 @@
+2016-06-01  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: iOS: VoiceOver can't access attachments in mail messages
+        https://bugs.webkit.org/show_bug.cgi?id=158198
+
+        Reviewed by Joanmarie Diggs.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::stringForRange):
+        (AccessibilityUIElement::attributedStringForRange):
+        (AccessibilityUIElement::attributedStringRangeIsMisspelled):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::attributedStringForRange):
+        (WTR::AccessibilityUIElement::attributedStringRangeIsMisspelled):
+
 2016-06-01  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Mark GTK+ test /webkit2/WebKitWebInspectorServer/test-open-debugging-session as slow.
index 091526a..5d3b053 100644 (file)
@@ -73,6 +73,7 @@ AccessibilityUIElement::~AccessibilityUIElement()
 - (NSArray *)accessibilityHeaderElements;
 - (NSString *)accessibilityPlaceholderValue;
 - (NSString *)stringForRange:(NSRange)range;
+- (NSAttributedString *)attributedStringForRange:(NSRange)range;
 - (NSArray *)elementsForRange:(NSRange)range;
 - (NSString *)selectionRangeString;
 - (CGPoint)accessibilityClickPoint;
@@ -365,9 +366,15 @@ JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned l
     return [stringForRange createJSStringRef];
 }
 
-JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
+JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    NSRange range = NSMakeRange(location, length);
+    NSAttributedString* string = [m_element attributedStringForRange:range];
+    if (![string isKindOfClass:[NSAttributedString class]])
+        return 0;
+    
+    NSString* stringWithAttrs = [string description];
+    return [stringWithAttrs createJSStringRef];
 }
 
 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned)
index d0e2384..2903c37 100644 (file)
@@ -50,6 +50,7 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (NSArray *)accessibilityHeaderElements;
 - (NSString *)accessibilityPlaceholderValue;
 - (NSString *)stringForRange:(NSRange)range;
+- (NSAttributedString *)attributedStringForRange:(NSRange)range;
 - (NSArray *)elementsForRange:(NSRange)range;
 - (NSString *)selectionRangeString;
 - (CGPoint)accessibilityClickPoint;
@@ -623,7 +624,11 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned locatio
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
 {
-    return JSStringCreateWithCharacters(0, 0);
+    NSAttributedString *stringForRange = [m_element attributedStringForRange:NSMakeRange(location, length)];
+    if (!stringForRange)
+        return nullptr;
+    
+    return [[stringForRange description] createJSStringRef];
 }
 
 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length)