Title: [203538] trunk
Revision
203538
Author
n_w...@apple.com
Date
2016-07-21 16:47:53 -0700 (Thu, 21 Jul 2016)

Log Message

AX: aria-label not being used correctly in accessible name calculation of heading
https://bugs.webkit.org/show_bug.cgi?id=160009

Reviewed by Chris Fleizach.

Source/WebCore:

Actually we are exposing the correct information for heading objects. On macOS, 
VoiceOver should handle the logic that picks the right information to speak.
On iOS, VoiceOver is speaking the static text child instead of the heading object.
So we should set the accessibilityLabel of the static text based on the parent's 
alternate label.

Test: accessibility/ios-simulator/heading-with-aria-label.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _accessibilityTraitsFromAncestors]):

LayoutTests:

* accessibility/ios-simulator/heading-with-aria-label-expected.txt: Added.
* accessibility/ios-simulator/heading-with-aria-label.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203537 => 203538)


--- trunk/LayoutTests/ChangeLog	2016-07-21 23:41:44 UTC (rev 203537)
+++ trunk/LayoutTests/ChangeLog	2016-07-21 23:47:53 UTC (rev 203538)
@@ -1,3 +1,13 @@
+2016-07-21  Nan Wang  <n_w...@apple.com>
+
+        AX: aria-label not being used correctly in accessible name calculation of heading
+        https://bugs.webkit.org/show_bug.cgi?id=160009
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/heading-with-aria-label-expected.txt: Added.
+        * accessibility/ios-simulator/heading-with-aria-label.html: Added.
+
 2016-07-21  Ryan Haddad  <ryanhad...@apple.com>
 
         Move expected.txt file for editing/deleting/delete-emoji.html from mac-elcapitan to mac-yosemite

Added: trunk/LayoutTests/accessibility/ios-simulator/heading-with-aria-label-expected.txt (0 => 203538)


--- trunk/LayoutTests/accessibility/ios-simulator/heading-with-aria-label-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/heading-with-aria-label-expected.txt	2016-07-21 23:47:53 UTC (rev 203538)
@@ -0,0 +1,13 @@
+visible text visible text
+This tests that if heading 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".
+
+
+PASS heading1Text.traits == heading2Text.traits is true
+PASS heading1Text.description is 'AXLabel: test label'
+PASS heading2Text.description is 'AXLabel: visible text'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/ios-simulator/heading-with-aria-label.html (0 => 203538)


--- trunk/LayoutTests/accessibility/ios-simulator/heading-with-aria-label.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/heading-with-aria-label.html	2016-07-21 23:47:53 UTC (rev 203538)
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script>
+var successfullyParsed = false;
+</script>
+</head>
+<body id="body">
+
+<span id="heading1" role="heading" aria-label="test label">visible text</span>
+<span id="heading2" role="heading">visible text</span>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that if heading has aria-label, it will override the visible text as necessary.");
+
+    if (window.accessibilityController) {
+
+        var heading1Text = accessibilityController.accessibleElementById("heading1").childAtIndex(0);
+        var heading2Text = accessibilityController.accessibleElementById("heading2").childAtIndex(0);
+        
+        // Get the trait so that the label will be set.
+        shouldBeTrue("heading1Text.traits == heading2Text.traits");
+        
+        shouldBe("heading1Text.description", "'AXLabel: test label'");
+        shouldBe("heading2Text.description", "'AXLabel: visible text'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (203537 => 203538)


--- trunk/Source/WebCore/ChangeLog	2016-07-21 23:41:44 UTC (rev 203537)
+++ trunk/Source/WebCore/ChangeLog	2016-07-21 23:47:53 UTC (rev 203538)
@@ -1,3 +1,21 @@
+2016-07-21  Nan Wang  <n_w...@apple.com>
+
+        AX: aria-label not being used correctly in accessible name calculation of heading
+        https://bugs.webkit.org/show_bug.cgi?id=160009
+
+        Reviewed by Chris Fleizach.
+
+        Actually we are exposing the correct information for heading objects. On macOS, 
+        VoiceOver should handle the logic that picks the right information to speak.
+        On iOS, VoiceOver is speaking the static text child instead of the heading object.
+        So we should set the accessibilityLabel of the static text based on the parent's 
+        alternate label.
+
+        Test: accessibility/ios-simulator/heading-with-aria-label.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilityTraitsFromAncestors]):
+
 2016-07-21  Saam Barati  <sbar...@apple.com>
 
         op_add/ValueAdd should be an IC in all JIT tiers

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (203537 => 203538)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2016-07-21 23:41:44 UTC (rev 203537)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2016-07-21 23:47:53 UTC (rev 203538)
@@ -598,8 +598,15 @@
                 // to the heading level. If it was a static text element, we need to store
                 // the value as the label, because the heading level needs to the value.
                 AccessibilityObjectWrapper* wrapper = parent->wrapper();
-                if (role == StaticTextRole) 
-                    [self setAccessibilityLabel:m_object->stringValue()];                
+                if (role == StaticTextRole) {
+                    // We should only set the text value as the label when there's no
+                    // alternate text on the heading parent.
+                    NSString *headingLabel = [wrapper accessibilityLabel];
+                    if (![headingLabel length])
+                        [self setAccessibilityLabel:m_object->stringValue()];
+                    else
+                        [self setAccessibilityLabel:headingLabel];
+                }
                 [self setAccessibilityValue:[wrapper accessibilityValue]];
                 break;
             }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to