Title: [200290] trunk
Revision
200290
Author
n_w...@apple.com
Date
2016-04-30 11:06:47 -0700 (Sat, 30 Apr 2016)

Log Message

AX: @aria-label attribute should work on <label> element
https://bugs.webkit.org/show_bug.cgi?id=157219

Reviewed by Chris Fleizach.

Source/WebCore:

When there's aria-label on a <label> element, we shouldn't expose it
as the titleUIElement. Instead, we return its aria-label as a title.

Test: accessibility/mac/aria-label-on-label-element.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::titleElementText):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::exposesTitleUIElement):

LayoutTests:

* accessibility/mac/aria-label-on-label-element-expected.txt: Added.
* accessibility/mac/aria-label-on-label-element.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200289 => 200290)


--- trunk/LayoutTests/ChangeLog	2016-04-30 05:40:57 UTC (rev 200289)
+++ trunk/LayoutTests/ChangeLog	2016-04-30 18:06:47 UTC (rev 200290)
@@ -1,3 +1,13 @@
+2016-04-30  Nan Wang  <n_w...@apple.com>
+
+        AX: @aria-label attribute should work on <label> element
+        https://bugs.webkit.org/show_bug.cgi?id=157219
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/aria-label-on-label-element-expected.txt: Added.
+        * accessibility/mac/aria-label-on-label-element.html: Added.
+
 2016-04-29  Ryosuke Niwa  <rn...@webkit.org>
 
         Rename getAssignedNodes to assignedNodes and support flattened option

Added: trunk/LayoutTests/accessibility/mac/aria-label-on-label-element-expected.txt (0 => 200290)


--- trunk/LayoutTests/accessibility/mac/aria-label-on-label-element-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/aria-label-on-label-element-expected.txt	2016-04-30 18:06:47 UTC (rev 200290)
@@ -0,0 +1,13 @@
+Some text  Some other text 
+This tests that the aria-label attribute works on element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS !titleUIElement1 is true
+PASS input1.title is 'AXTitle: aria label'
+PASS titleUIElement2.isEqual(accessibilityController.accessibleElementById('label2')) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/aria-label-on-label-element.html (0 => 200290)


--- trunk/LayoutTests/accessibility/mac/aria-label-on-label-element.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/aria-label-on-label-element.html	2016-04-30 18:06:47 UTC (rev 200290)
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<label for="" aria-label="aria label">Some text</label>
+<input id="input" type="text" size=20>
+
+<label id="label2" for="" other text</label>
+<input id="input2" type="text" size=20>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the aria-label attribute works on <label> element.");
+
+    if (window.accessibilityController) {
+    
+        // aria-label on the <label> element return a title for the input, instead of a title ui element.
+        var input1 = accessibilityController.accessibleElementById("input");
+        var titleUIElement1 = input1.titleUIElement();
+        shouldBeTrue("!titleUIElement1");
+        shouldBe("input1.title", "'AXTitle: aria label'");
+        
+        // Normal case.
+        var input2 = accessibilityController.accessibleElementById("input2");
+        var titleUIElement2 = input2.titleUIElement();
+        shouldBeTrue("titleUIElement2.isEqual(accessibilityController.accessibleElementById('label2'))");
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (200289 => 200290)


--- trunk/Source/WebCore/ChangeLog	2016-04-30 05:40:57 UTC (rev 200289)
+++ trunk/Source/WebCore/ChangeLog	2016-04-30 18:06:47 UTC (rev 200290)
@@ -1,3 +1,20 @@
+2016-04-30  Nan Wang  <n_w...@apple.com>
+
+        AX: @aria-label attribute should work on <label> element
+        https://bugs.webkit.org/show_bug.cgi?id=157219
+
+        Reviewed by Chris Fleizach.
+
+        When there's aria-label on a <label> element, we shouldn't expose it
+        as the titleUIElement. Instead, we return its aria-label as a title.
+
+        Test: accessibility/mac/aria-label-on-label-element.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::titleElementText):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::exposesTitleUIElement):
+
 2016-04-29  Chris Dumez  <cdu...@apple.com>
 
         [Web IDL] Specify default parameter values for callback parameters

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (200289 => 200290)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2016-04-30 05:40:57 UTC (rev 200289)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2016-04-30 18:06:47 UTC (rev 200290)
@@ -1265,6 +1265,11 @@
         if (HTMLLabelElement* label = labelForElement(downcast<Element>(node))) {
             AccessibilityObject* labelObject = axObjectCache()->getOrCreate(label);
             String innerText = label->innerText();
+            
+            const AtomicString& ariaLabel = labelObject->getAttribute(aria_labelAttr);
+            if (!ariaLabel.isEmpty())
+                innerText = ariaLabel;
+            
             // Only use the <label> text if there's no ARIA override.
             if (!innerText.isEmpty() && !ariaAccessibilityDescription())
                 textOrder.append(AccessibilityText(innerText, LabelByElementText, labelObject));

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (200289 => 200290)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2016-04-30 05:40:57 UTC (rev 200289)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2016-04-30 18:06:47 UTC (rev 200290)
@@ -1071,6 +1071,15 @@
     if (hasTextAlternative())
         return false;
     
+    // When <label> element has aria-label on it, we shouldn't expose it as the titleUIElement,
+    // otherwise its inner text will be announced by a screenreader.
+    if (is<HTMLInputElement>(*this->node()) || AccessibilityObject::isARIAInput(ariaRoleAttribute())) {
+        if (HTMLLabelElement* label = labelForElement(downcast<Element>(node()))) {
+            if (!label->fastGetAttribute(aria_labelAttr).isEmpty())
+                return false;
+        }
+    }
+    
     return true;
 }
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to