Source/WebCore: AX: When img@alt is undefined, WebKit should use @title as accessibil...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2013 16:42:45 +0000 (16:42 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2013 16:42:45 +0000 (16:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114535

Reviewed by Tim Horton.

Don't hide images from Accessibility that have the title attribute on them.

Test: accessibility/empty-image-with-title.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):

LayoutTests: When img@alt is undefined, WebKit should use @title as accessibility label if available
https://bugs.webkit.org/show_bug.cgi?id=114535

Reviewed by Tim Horton.

* accessibility/empty-image-with-title-expected.txt: Added.
* accessibility/empty-image-with-title.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/empty-image-with-title-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/empty-image-with-title.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp

index 7c9e9bd..c988c98 100644 (file)
@@ -1,3 +1,13 @@
+2013-04-17  Chris Fleizach  <cfleizach@apple.com>
+
+        When img@alt is undefined, WebKit should use @title as accessibility label if available
+        https://bugs.webkit.org/show_bug.cgi?id=114535
+
+        Reviewed by Tim Horton.
+
+        * accessibility/empty-image-with-title-expected.txt: Added.
+        * accessibility/empty-image-with-title.html: Added.
+
 2013-04-17  Arpita Bahuguna  <a.bah@samsung.com>
 
         getAttribute does not behave correctly for mixed-case attributes on HTML elements
diff --git a/LayoutTests/accessibility/empty-image-with-title-expected.txt b/LayoutTests/accessibility/empty-image-with-title-expected.txt
new file mode 100644 (file)
index 0000000..518f40f
--- /dev/null
@@ -0,0 +1,12 @@
+
+This tests that if a missing image has a title attribute, it still appears in the AX hierarchy.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS image1.role is 'AXRole: AXImage'
+PASS image1.description is 'AXDescription: baz'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/empty-image-with-title.html b/LayoutTests/accessibility/empty-image-with-title.html
new file mode 100644 (file)
index 0000000..7607c66
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<img id="image1" src="foo.gif" title="baz" width="100" height="100">
+
+<div id="console"></div>
+
+<script>
+
+    description("This tests that if a missing image has a title attribute, it still appears in the AX hierarchy.");
+
+    if (window.accessibilityController) {
+
+          var image1 = accessibilityController.accessibleElementById("image1");
+          shouldBe("image1.role", "'AXRole: AXImage'");
+          shouldBe("image1.description", "'AXDescription: baz'");
+    }
+
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 4f141a9..db9546d 100644 (file)
@@ -1,3 +1,17 @@
+2013-04-17  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: When img@alt is undefined, WebKit should use @title as accessibility label if available
+        https://bugs.webkit.org/show_bug.cgi?id=114535
+
+        Reviewed by Tim Horton.
+
+        Don't hide images from Accessibility that have the title attribute on them.
+
+        Test: accessibility/empty-image-with-title.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
+
 2013-04-17  Arpita Bahuguna  <a.bah@samsung.com>
 
         getAttribute does not behave correctly for mixed-case attributes on HTML elements
index 97a0974..1f88b5e 100644 (file)
@@ -1247,6 +1247,9 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
             // informal standard is to ignore images with zero-length alt strings
             if (!alt.isNull())
                 return true;
+            // If an image has a title attribute on it, accessibility should be lenient and allow it to appear in the hierarchy (according to WAI-ARIA).
+            if (!getAttribute(titleAttr).isEmpty())
+                return false;
         }
         
         if (isNativeImage()) {