2009-12-07 Joanmarie Diggs <joanmarie.diggs@gmail.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 14:27:44 +0000 (14:27 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 14:27:44 +0000 (14:27 +0000)
        Reviewed by Xan Lopez.

        https://bugs.webkit.org/show_bug.cgi?id=25524
        [Gtk] Expose the title attribute to assistive technologies

        * platform/gtk/accessibility/title-and-alt.html: Added.
        * platform/gtk/accessibility/title-and-alt-expected.txt: Added.
2009-12-07  Joanmarie Diggs  <joanmarie.diggs@gmail.com>

        Reviewed by Xan Lopez.

        https://bugs.webkit.org/show_bug.cgi?id=25524
        [Gtk] Expose the title attribute to assistive technologies

        Expose 'alt' attribute from images as accessible name.
        Expose the 'title' core HTML attribute as accessible description.
        This is a modified version of the original fix submitted by Mario Sanchez Prada,
        adjusted so that it doesn't impact other platforms.

        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
        (webkit_accessible_get_name):
        (webkit_accessible_get_description):

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/accessibility/title-and-alt-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/title-and-alt.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp

index 57d8413e9edb2a33e151a9a56a5a6c5bbe31cbea..5459b4254729b262ca5c92595a88f424be923276 100644 (file)
@@ -1,3 +1,13 @@
+2009-12-07  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
+
+        Reviewed by Xan Lopez.
+
+        https://bugs.webkit.org/show_bug.cgi?id=25524
+        [Gtk] Expose the title attribute to assistive technologies
+
+        * platform/gtk/accessibility/title-and-alt.html: Added.
+        * platform/gtk/accessibility/title-and-alt-expected.txt: Added.
+
 2009-12-07  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
 2009-12-07  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/platform/gtk/accessibility/title-and-alt-expected.txt b/LayoutTests/platform/gtk/accessibility/title-and-alt-expected.txt
new file mode 100644 (file)
index 0000000..2c54ac1
--- /dev/null
@@ -0,0 +1,19 @@
+
+Functional label:
+This tests the exposure of alt and title information.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS image.title is 'Image alt attr'
+PASS image.description is 'Image title attr'
+PASS link.title is ''
+PASS link.description is 'Link title attr'
+PASS entry.title is ''
+PASS entry.description is 'Entry title attr'
+PASS button.title is 'Submit'
+PASS button.description is 'Submit button title attr'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/title-and-alt.html b/LayoutTests/platform/gtk/accessibility/title-and-alt.html
new file mode 100644 (file)
index 0000000..aa91e7a
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<img src="image.jpg" alt="Image alt attr" title="Image title attr">
+<form>
+<a href="" title="Link title attr">Functional label</a>:<input title="Entry title attr" type="text" /><input value="Clear" type="reset" /><input value="Submit" title="Submit button title attr" type="submit" />
+</form>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the exposure of alt and title information.");
+    if (window.accessibilityController) {
+        layoutTestController.dumpAsText();
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+
+        var image = webArea.childAtIndex(0);
+        shouldBe("image.title", "'Image alt attr'");
+        shouldBe("image.description", "'Image title attr'");
+
+        var link = webArea.childAtIndex(1);
+        shouldBe("link.title", "''");
+        shouldBe("link.description", "'Link title attr'");
+
+        var entry = webArea.childAtIndex(2);
+        shouldBe("entry.title", "''");
+        shouldBe("entry.description", "'Entry title attr'");
+
+        var button = webArea.childAtIndex(4);
+        shouldBe("button.title", "'Submit'");
+        shouldBe("button.description", "'Submit button title attr'");
+        }
+    successfullyParsed = true;
+</script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 8f380a8dc4960caa08e176a4be1b982450d8a09a..3446641080ccd2c1fe77b9ba0aff0f6558f1aa0e 100644 (file)
@@ -1,3 +1,19 @@
+2009-12-07  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
+
+        Reviewed by Xan Lopez.
+
+        https://bugs.webkit.org/show_bug.cgi?id=25524
+        [Gtk] Expose the title attribute to assistive technologies
+
+        Expose 'alt' attribute from images as accessible name.
+        Expose the 'title' core HTML attribute as accessible description.
+        This is a modified version of the original fix submitted by Mario Sanchez Prada,
+        adjusted so that it doesn't impact other platforms.
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (webkit_accessible_get_name):
+        (webkit_accessible_get_description):
+
 2009-12-07  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         Reviewed by Simon Hausmann.
 2009-12-07  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         Reviewed by Simon Hausmann.
index 308007c5d4a587dee3b7c2fc7f883fc891c12372..466ccfdc512becf48018b084fda6ed7cd0362fc3 100644 (file)
@@ -159,29 +159,51 @@ static const gchar* nameFromChildren(AccessibilityObject* object)
 static const gchar* webkit_accessible_get_name(AtkObject* object)
 {
     AccessibilityObject* coreObject = core(object);
 static const gchar* webkit_accessible_get_name(AtkObject* object)
 {
     AccessibilityObject* coreObject = core(object);
+    if (!coreObject->isAccessibilityRenderObject())
+        return returnString(coreObject->stringValue());
+
+    AccessibilityRenderObject* renderObject = static_cast<AccessibilityRenderObject*>(coreObject);
     if (coreObject->isControl()) {
     if (coreObject->isControl()) {
-        AccessibilityRenderObject* renderObject = static_cast<AccessibilityRenderObject*>(coreObject);
         AccessibilityObject* label = renderObject->correspondingLabelForControlElement();
         if (label)
             return returnString(nameFromChildren(label));
     }
         AccessibilityObject* label = renderObject->correspondingLabelForControlElement();
         if (label)
             return returnString(nameFromChildren(label));
     }
+
+    if (renderObject->isImage() || renderObject->isInputImage()) {
+        Node* node = renderObject->renderer()->node();
+        if (node && node->isHTMLElement()) {
+            // Get the attribute rather than altText String so as not to fall back on title.
+            String alt = static_cast<HTMLElement*>(node)->getAttribute(HTMLNames::altAttr);
+            if (!alt.isEmpty())
+                return returnString(alt);
+        }
+    }
+
     return returnString(coreObject->stringValue());
 }
 
 static const gchar* webkit_accessible_get_description(AtkObject* object)
 {
     AccessibilityObject* coreObject = core(object);
     return returnString(coreObject->stringValue());
 }
 
 static const gchar* webkit_accessible_get_description(AtkObject* object)
 {
     AccessibilityObject* coreObject = core(object);
+    Node* node = 0;
+    if (coreObject->isAccessibilityRenderObject())
+        node = static_cast<AccessibilityRenderObject*>(coreObject)->renderer()->node();
+    if (!node || !node->isHTMLElement() || coreObject->ariaRoleAttribute() != UnknownRole)
+        return returnString(coreObject->accessibilityDescription());
 
     // atk_table_get_summary returns an AtkObject. We have no summary object, so expose summary here.
 
     // atk_table_get_summary returns an AtkObject. We have no summary object, so expose summary here.
-    if (coreObject->roleValue() == TableRole && coreObject->ariaRoleAttribute() == UnknownRole) {
-        Node* node = static_cast<AccessibilityRenderObject*>(coreObject)->renderer()->node();
-        if (node && node->isHTMLElement()) {
-            String summary = static_cast<HTMLTableElement*>(node)->summary();
-            if (!summary.isEmpty())
-                return returnString(summary);
-        }
+    if (coreObject->roleValue() == TableRole) {
+        String summary = static_cast<HTMLTableElement*>(node)->summary();
+        if (!summary.isEmpty())
+            return returnString(summary);
     }
 
     }
 
+    // The title attribute should be reliably available as the object's descripton.
+    // We do not want to fall back on other attributes in its absence. See bug 25524.
+    String title = static_cast<HTMLElement*>(node)->title();
+    if (!title.isEmpty())
+        return returnString(title);
+
     return returnString(coreObject->accessibilityDescription());
 }
 
     return returnString(coreObject->accessibilityDescription());
 }