Title: [144766] trunk
Revision
144766
Author
[email protected]
Date
2013-03-05 09:24:30 -0800 (Tue, 05 Mar 2013)

Log Message

AX: aria-label does not override text content on iOS
https://bugs.webkit.org/show_bug.cgi?id=111222

Reviewed by David Kilzer.

Source/WebCore: 

Make iOS use the same text alternative computation that Mac is using. The main difference
is that description and title need to be concatenated, because iOS doesn't have two attributes
to return those values.

Test: platform/iphone-simulator/accessibility/aria-label-with-internal-text.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper stringValueShouldBeUsedInLabel]):
(-[WebAccessibilityObjectWrapper accessibilityLabel]):
(-[WebAccessibilityObjectWrapper accessibilityHint]):
* accessibility/mac/WebAccessibilityObjectWrapperBase.h:

LayoutTests: 

* platform/iphone-simulator/accessibility/aria-label-with-internal-text-expected.txt: Added.
* platform/iphone-simulator/accessibility/aria-label-with-internal-text.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144765 => 144766)


--- trunk/LayoutTests/ChangeLog	2013-03-05 17:08:18 UTC (rev 144765)
+++ trunk/LayoutTests/ChangeLog	2013-03-05 17:24:30 UTC (rev 144766)
@@ -1,3 +1,13 @@
+2013-03-05  Chris Fleizach  <[email protected]>
+
+        AX: aria-label does not override text content on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=111222
+
+        Reviewed by David Kilzer.
+
+        * platform/iphone-simulator/accessibility/aria-label-with-internal-text-expected.txt: Added.
+        * platform/iphone-simulator/accessibility/aria-label-with-internal-text.html: Added.
+
 2013-03-05  Julien Chaffraix  <[email protected]>
 
         [CSS Grid Layout] Add parsing for grid-{end|after}

Added: trunk/LayoutTests/platform/iphone-simulator/accessibility/aria-label-with-internal-text-expected.txt (0 => 144766)


--- trunk/LayoutTests/platform/iphone-simulator/accessibility/aria-label-with-internal-text-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/iphone-simulator/accessibility/aria-label-with-internal-text-expected.txt	2013-03-05 17:24:30 UTC (rev 144766)
@@ -0,0 +1,21 @@
+1
+1
+text1
+link1
+This tests that if an element has aria-label, it will override the visible text as necessary.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Button 1 should expose alternative text only.
+PASS button1.iphoneLabel is 'AXLabel: PLAY'
+Button 2 should expose internal text only.
+PASS button2.iphoneLabel is 'AXLabel: 1'
+Text 1 should rely on the stringValue() in the label field.
+PASS text1.iphoneLabel is 'AXLabel: text1'
+Link1 should combine the title field and the aria-label field.
+PASS link1.iphoneLabel is 'AXLabel: link1, link1-title'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/iphone-simulator/accessibility/aria-label-with-internal-text.html (0 => 144766)


--- trunk/LayoutTests/platform/iphone-simulator/accessibility/aria-label-with-internal-text.html	                        (rev 0)
+++ trunk/LayoutTests/platform/iphone-simulator/accessibility/aria-label-with-internal-text.html	2013-03-05 17:24:30 UTC (rev 144766)
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script>
+var successfullyParsed = false;
+</script>
+</head>
+<body id="body">
+
+<div id="button1" role="button" aria-label="PLAY"><span>1</span></div>
+<div id="button2" role="button"><span>1</span></div>
+<div id="text1" role="text"><span>text1</span></div>
+<div id="link1" title="link1-title" role="link"><span>link1</span></div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that if an element has aria-label, it will override the visible text as necessary.");
+
+    if (window.accessibilityController) {
+
+        var button1 = accessibilityController.accessibleElementById("button1");
+        debug("Button 1 should expose alternative text only.");
+        shouldBe("button1.iphoneLabel", "'AXLabel: PLAY'");
+
+        var button2 = accessibilityController.accessibleElementById("button2");
+        debug("Button 2 should expose internal text only.");
+        shouldBe("button2.iphoneLabel", "'AXLabel: 1'");
+
+        var text1 = accessibilityController.accessibleElementById("text1");
+        debug("Text 1 should rely on the stringValue() in the label field.");
+        shouldBe("text1.iphoneLabel", "'AXLabel: text1'");
+
+        var link1 = accessibilityController.accessibleElementById("link1");
+        debug("Link1 should combine the title field and the aria-label field.");
+        shouldBe("link1.iphoneLabel", "'AXLabel: link1, link1-title'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src=""
+
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (144765 => 144766)


--- trunk/Source/WebCore/ChangeLog	2013-03-05 17:08:18 UTC (rev 144765)
+++ trunk/Source/WebCore/ChangeLog	2013-03-05 17:24:30 UTC (rev 144766)
@@ -1,3 +1,22 @@
+2013-03-05  Chris Fleizach  <[email protected]>
+
+        AX: aria-label does not override text content on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=111222
+
+        Reviewed by David Kilzer.
+
+        Make iOS use the same text alternative computation that Mac is using. The main difference
+        is that description and title need to be concatenated, because iOS doesn't have two attributes
+        to return those values.
+
+        Test: platform/iphone-simulator/accessibility/aria-label-with-internal-text.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper stringValueShouldBeUsedInLabel]):
+        (-[WebAccessibilityObjectWrapper accessibilityLabel]):
+        (-[WebAccessibilityObjectWrapper accessibilityHint]):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.h:
+
 2013-03-05  David Kilzer  <[email protected]>
 
         BUILD FIX (r144698): Only enable SPEECH_SYNTHESIS for Mac

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (144765 => 144766)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2013-03-05 17:08:18 UTC (rev 144765)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2013-03-05 17:24:30 UTC (rev 144766)
@@ -658,7 +658,7 @@
         return NO;
     if (m_object->roleValue() == PopUpButtonRole)
         return NO;
-    
+
     return YES;
 }
 
@@ -672,15 +672,23 @@
     if (label)
         return label;
 
-    NSString* title = m_object->title();
-    if (![title length])
-        title = m_object->accessibilityDescription();
-
-    // Everything except a text control needs to return their string value in the axLabel (per iPhone AX API).
-    if (![title length] && [self stringValueShouldBeUsedInLabel])
-        title = m_object->stringValue();
+    // iOS doesn't distinguish between a title and description field,
+    // so concatentation will yield the best result.
+    NSString *axTitle = [self accessibilityTitle];
+    NSString *axDescription = [self accessibilityDescription];
+    NSUInteger axTitleLength = [axTitle length];
+    NSUInteger axDescriptionLength = [axDescription length];
     
-    return title;
+    if (axTitleLength && axDescriptionLength)
+        return [axTitle stringByAppendingFormat:@", %@", axDescription];
+    else if (axTitleLength)
+        return axTitle;
+    else if (axDescriptionLength)
+        return axDescription;
+    else if ([self stringValueShouldBeUsedInLabel])
+        return m_object->stringValue();
+    
+    return nil;
 }
 
 - (AccessibilityTableCell*)tableCellParent
@@ -894,7 +902,7 @@
     if (![self _prepareAccessibilityCall])
         return nil;
 
-    return m_object->helpText();
+    return [self accessibilityHelpText];
 }
 
 - (NSURL *)accessibilityURL

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h (144765 => 144766)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h	2013-03-05 17:08:18 UTC (rev 144765)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h	2013-03-05 17:24:30 UTC (rev 144766)
@@ -43,6 +43,10 @@
 - (WebCore::AccessibilityObject*)accessibilityObject;
 - (BOOL)updateObjectBackingStore;
 
+- (NSString *)accessibilityTitle;
+- (NSString *)accessibilityDescription;
+- (NSString *)accessibilityHelpText;
+
 - (id)attachmentView;
 // Used to inform an element when a notification is posted for it. Used by DRT.
 - (void)accessibilityPostedNotification:(NSString *)notificationName;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to