Title: [160311] trunk
Revision
160311
Author
[email protected]
Date
2013-12-09 06:17:27 -0800 (Mon, 09 Dec 2013)

Log Message

AX: WebKit ignores @alt on IMG elements with role="text"
https://bugs.webkit.org/show_bug.cgi?id=125363

Reviewed by Mario Sanchez Prada.

Source/WebCore:

If an <img> element has a different role, the alt attribute should still be used in the
name calculation if present.

Test: accessibility/alt-tag-on-image-with-nonimage-role.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::usesAltTagForTextComputation):
(WebCore::AccessibilityNodeObject::alternativeText):
(WebCore::AccessibilityNodeObject::accessibilityDescription):
(WebCore::AccessibilityNodeObject::text):
* accessibility/AccessibilityNodeObject.h:

LayoutTests:

* accessibility/alt-tag-on-image-with-nonimage-role-expected.txt: Added.
* accessibility/alt-tag-on-image-with-nonimage-role.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160310 => 160311)


--- trunk/LayoutTests/ChangeLog	2013-12-09 14:10:18 UTC (rev 160310)
+++ trunk/LayoutTests/ChangeLog	2013-12-09 14:17:27 UTC (rev 160311)
@@ -1,3 +1,13 @@
+2013-12-09  Chris Fleizach  <[email protected]>
+
+        AX: WebKit ignores @alt on IMG elements with role="text"
+        https://bugs.webkit.org/show_bug.cgi?id=125363
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/alt-tag-on-image-with-nonimage-role-expected.txt: Added.
+        * accessibility/alt-tag-on-image-with-nonimage-role.html: Added.
+
 2013-12-09  Michal Poteralski  <[email protected]>
 
         DataCloneError exception is not thrown when postMessage's second parameter

Added: trunk/LayoutTests/accessibility/alt-tag-on-image-with-nonimage-role-expected.txt (0 => 160311)


--- trunk/LayoutTests/accessibility/alt-tag-on-image-with-nonimage-role-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/alt-tag-on-image-with-nonimage-role-expected.txt	2013-12-09 14:17:27 UTC (rev 160311)
@@ -0,0 +1,13 @@
+   
+This tests that setting a role on an img still allows the alt attribute to be used for the description..
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.stringValue is 'AXValue: TEST1'
+PASS group.description is 'AXDescription: TEST2'
+PASS button.description is 'AXDescription: TEST3'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/alt-tag-on-image-with-nonimage-role.html (0 => 160311)


--- trunk/LayoutTests/accessibility/alt-tag-on-image-with-nonimage-role.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/alt-tag-on-image-with-nonimage-role.html	2013-12-09 14:17:27 UTC (rev 160311)
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<img alt="TEST1" src="" role="text" id="text">
+
+<img alt="TEST2" src="" role="group" id="group">
+
+<img alt="TEST3" src="" role="button" id="button">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that setting a role on an img still allows the alt attribute to be used for the description..");
+
+    if (window.accessibilityController) {
+
+        var text = accessibilityController.accessibleElementById("text");
+        shouldBe("text.stringValue", "'AXValue: TEST1'");
+
+        var group = accessibilityController.accessibleElementById("group");
+        shouldBe("group.description", "'AXDescription: TEST2'");
+
+        var button = accessibilityController.accessibleElementById("button");
+        shouldBe("button.description", "'AXDescription: TEST3'");
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (160310 => 160311)


--- trunk/Source/WebCore/ChangeLog	2013-12-09 14:10:18 UTC (rev 160310)
+++ trunk/Source/WebCore/ChangeLog	2013-12-09 14:17:27 UTC (rev 160311)
@@ -1,3 +1,22 @@
+2013-12-09  Chris Fleizach  <[email protected]>
+
+        AX: WebKit ignores @alt on IMG elements with role="text"
+        https://bugs.webkit.org/show_bug.cgi?id=125363
+
+        Reviewed by Mario Sanchez Prada.
+
+        If an <img> element has a different role, the alt attribute should still be used in the 
+        name calculation if present.
+
+        Test: accessibility/alt-tag-on-image-with-nonimage-role.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::usesAltTagForTextComputation):
+        (WebCore::AccessibilityNodeObject::alternativeText):
+        (WebCore::AccessibilityNodeObject::accessibilityDescription):
+        (WebCore::AccessibilityNodeObject::text):
+        * accessibility/AccessibilityNodeObject.h:
+
 2013-12-08  Martin Robinson  <[email protected]>
 
         [WK2][Soup] Use didReceiveBuffer instead of didReceiveData

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (160310 => 160311)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-12-09 14:10:18 UTC (rev 160310)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-12-09 14:17:27 UTC (rev 160311)
@@ -1211,6 +1211,11 @@
     return 0;
 }
 
+bool AccessibilityNodeObject::usesAltTagForTextComputation() const
+{
+    return isImage() || isInputImage() || isNativeImage() || isCanvas() || (node() && node()->hasTagName(imgTag));
+}
+    
 void AccessibilityNodeObject::titleElementText(Vector<AccessibilityText>& textOrder) const
 {
     Node* node = this->node();
@@ -1250,7 +1255,7 @@
     if (!ariaLabel.isEmpty())
         textOrder.append(AccessibilityText(ariaLabel, AlternativeText));
     
-    if (isImage() || isInputImage() || isNativeImage() || isCanvas()) {
+    if (usesAltTagForTextComputation()) {
         if (renderer() && renderer()->isRenderImage()) {
             String renderAltText = toRenderImage(renderer())->altText();
 
@@ -1479,7 +1484,7 @@
     if (!ariaDescription.isEmpty())
         return ariaDescription;
 
-    if (isImage() || isInputImage() || isNativeImage() || isCanvas()) {
+    if (usesAltTagForTextComputation()) {
         // Images should use alt as long as the attribute is present, even if empty.                    
         // Otherwise, it should fallback to other methods, like the title attribute.                    
         const AtomicString& alt = getAttribute(altAttr);
@@ -1739,8 +1744,12 @@
 String AccessibilityNodeObject::text() const
 {
     // If this is a user defined static text, use the accessible name computation.                                      
-    if (ariaRoleAttribute() == StaticTextRole)
-        return ariaAccessibilityDescription();
+    if (ariaRoleAttribute() == StaticTextRole) {
+        Vector<AccessibilityText> textOrder;
+        alternativeText(textOrder);
+        if (textOrder.size() > 0 && textOrder[0].text.length())
+            return textOrder[0].text;
+    }
 
     if (!isTextControl())
         return String();

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h (160310 => 160311)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-12-09 14:10:18 UTC (rev 160310)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-12-09 14:17:27 UTC (rev 160311)
@@ -201,6 +201,7 @@
     String alternativeTextForWebArea() const;
     void ariaLabeledByText(Vector<AccessibilityText>&) const;
     virtual bool computeAccessibilityIsIgnored() const OVERRIDE;
+    bool usesAltTagForTextComputation() const;
 };
 
 ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityNodeObject, isAccessibilityNodeObject())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to