AX: Support abbreviations in iOS
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Aug 2016 18:01:41 +0000 (18:01 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Aug 2016 18:01:41 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160907

Reviewed by Joanmarie Diggs.

Source/WebCore:

Expose the expandedTextValue attribute for iOS, so that VoiceOver can speak abbreviations correctly.

Test: accessibility/ios-simulator/abbreviation.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper textMarkersForRange:]):
(-[WebAccessibilityObjectWrapper accessibilityExpandedTextValue]):
(-[WebAccessibilityObjectWrapper accessibilityIdentifier]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetSpelling):
(AXAttributeStringSetExpandedTextValue):
(AXAttributedStringAppendText):
(AXAttributeStringSetexpandedTextValue): Deleted.

Tools:

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::stringAttributeValue):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::stringAttributeValue):

LayoutTests:

* accessibility/ios-simulator/abbreviation-expected.txt: Added.
* accessibility/ios-simulator/abbreviation.html: Added.

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

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

index 90ae654..7977aee 100644 (file)
@@ -1,3 +1,13 @@
+2016-08-17  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support abbreviations in iOS
+        https://bugs.webkit.org/show_bug.cgi?id=160907
+
+        Reviewed by Joanmarie Diggs.
+
+        * accessibility/ios-simulator/abbreviation-expected.txt: Added.
+        * accessibility/ios-simulator/abbreviation.html: Added.
+
 2016-08-16  Simon Fraser  <simon.fraser@apple.com>
 
         [iOS WK2] Don't throw touchMove events on the floor
diff --git a/LayoutTests/accessibility/ios-simulator/abbreviation-expected.txt b/LayoutTests/accessibility/ios-simulator/abbreviation-expected.txt
new file mode 100644 (file)
index 0000000..9da5255
--- /dev/null
@@ -0,0 +1,12 @@
+IRS
+This tests that expanded text values can be retrieved.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.description is 'AXLabel: IRS'
+PASS text.stringAttributeValue('AXExpandedTextValue') is 'Internal Revenue Service'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/abbreviation.html b/LayoutTests/accessibility/ios-simulator/abbreviation.html
new file mode 100644 (file)
index 0000000..9bb2f9e
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+var successfullyParsed = false;
+</script>
+</head>
+<body id="body">
+
+<abbr id="content" title='Internal Revenue Service'>IRS</abbr>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that expanded text values can be retrieved.");
+
+    if (window.accessibilityController) {
+
+        var text = accessibilityController.accessibleElementById("content").childAtIndex(0);
+        
+        shouldBe("text.description", "'AXLabel: IRS'");
+        shouldBe("text.stringAttributeValue('AXExpandedTextValue')", "'Internal Revenue Service'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
index 55c55b7..d70714c 100644 (file)
@@ -1,3 +1,24 @@
+2016-08-17  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support abbreviations in iOS
+        https://bugs.webkit.org/show_bug.cgi?id=160907
+
+        Reviewed by Joanmarie Diggs.
+
+        Expose the expandedTextValue attribute for iOS, so that VoiceOver can speak abbreviations correctly.
+
+        Test: accessibility/ios-simulator/abbreviation.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper textMarkersForRange:]):
+        (-[WebAccessibilityObjectWrapper accessibilityExpandedTextValue]):
+        (-[WebAccessibilityObjectWrapper accessibilityIdentifier]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetSpelling):
+        (AXAttributeStringSetExpandedTextValue):
+        (AXAttributedStringAppendText):
+        (AXAttributeStringSetexpandedTextValue): Deleted.
+
 2016-08-17  Antti Koivisto  <antti@apple.com>
 
         Remove StyleCachedImageSet
index 3290059..6ec83c3 100644 (file)
@@ -2592,6 +2592,13 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     return [NSArray arrayWithObjects:start, end, nil];
 }
 
+- (NSString *)accessibilityExpandedTextValue
+{
+    if (![self _prepareAccessibilityCall])
+        return nil;
+    return m_object->expandedTextValue();
+}
+
 - (NSString *)accessibilityIdentifier
 {
     if (![self _prepareAccessibilityCall])
index 9d1e27c..e22b7ab 100644 (file)
@@ -1194,7 +1194,7 @@ static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString,
     }
 }
 
-static void AXAttributeStringSetexpandedTextValue(NSMutableAttributedString *attrString, RenderObject* renderer, NSRange range)
+static void AXAttributeStringSetExpandedTextValue(NSMutableAttributedString *attrString, RenderObject* renderer, NSRange range)
 {
     if (!renderer || !AXAttributedStringRangeIsValid(attrString, range))
         return;
@@ -1283,7 +1283,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     AXAttributeStringSetStyle(attrString, renderer, attrStringRange);
     AXAttributeStringSetHeadingLevel(attrString, renderer, attrStringRange);
     AXAttributeStringSetBlockquoteLevel(attrString, renderer, attrStringRange);
-    AXAttributeStringSetexpandedTextValue(attrString, renderer, attrStringRange);
+    AXAttributeStringSetExpandedTextValue(attrString, renderer, attrStringRange);
     AXAttributeStringSetElement(attrString, NSAccessibilityLinkTextAttribute, AccessibilityObject::anchorElementForNode(node), attrStringRange);
     
     // do spelling last because it tends to break up the range
index bb555ef..a258160 100644 (file)
@@ -1,3 +1,15 @@
+2016-08-17  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support abbreviations in iOS
+        https://bugs.webkit.org/show_bug.cgi?id=160907
+
+        Reviewed by Joanmarie Diggs.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::stringAttributeValue):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::stringAttributeValue):
+
 2016-08-17  Gyuyoung Kim  <gyuyoung.kim@navercorp.com>
 
         [EFL] Bump efl version from 1.17 to 1.18
index 12c3a0c..625550b 100644 (file)
@@ -96,6 +96,7 @@ AccessibilityUIElement::~AccessibilityUIElement()
 - (UIAccessibilityTraits)_axContainedByFieldsetTrait;
 - (id)_accessibilityFieldsetAncestor;
 - (BOOL)_accessibilityHasTouchEventListener;
+- (NSString *)accessibilityExpandedTextValue;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -647,6 +648,9 @@ JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
     
     if (JSStringIsEqualToUTF8CString(attribute, "AXARIACurrent"))
         return [[m_element accessibilityARIACurrentStatus] createJSStringRef];
+
+    if (JSStringIsEqualToUTF8CString(attribute, "AXExpandedTextValue"))
+        return [[m_element accessibilityExpandedTextValue] createJSStringRef];
     
     return JSStringCreateWithCharacters(0, 0);
 }
index 6d17d0e..ded101b 100644 (file)
@@ -73,6 +73,7 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (UIAccessibilityTraits)_axContainedByFieldsetTrait;
 - (id)_accessibilityFieldsetAncestor;
 - (BOOL)_accessibilityHasTouchEventListener;
+- (NSString *)accessibilityExpandedTextValue;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -339,7 +340,10 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRe
     
     if (JSStringIsEqualToUTF8CString(attribute, "AXARIACurrent"))
         return [[m_element accessibilityARIACurrentStatus] createJSStringRef];
-    
+
+    if (JSStringIsEqualToUTF8CString(attribute, "AXExpandedTextValue"))
+        return [[m_element accessibilityExpandedTextValue] createJSStringRef];
+
     return JSStringCreateWithCharacters(0, 0);
 }