2011-03-29 Mario Sanchez Prada <msanchez@igalia.com>
authormario@webkit.org <mario@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 18:43:44 +0000 (18:43 +0000)
committermario@webkit.org <mario@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 18:43:44 +0000 (18:43 +0000)
        Reviewed by Chris Fleizach.

        AX: GTK: ARIA role is not respected on <p> <label> <div> and <form>
        https://bugs.webkit.org/show_bug.cgi?id=47636

        Added new layout test to check that roles are correct in GTK.

        * platform/gtk/accessibility/aria-roles-unignored-expected.txt: Added.
        * platform/gtk/accessibility/aria-roles-unignored.html: Added.
2011-03-29  Mario Sanchez Prada  <msanchez@igalia.com>

        Reviewed by Chris Fleizach.

        AX: GTK: ARIA role is not respected on <p> <label> <div> and <form>
        https://bugs.webkit.org/show_bug.cgi?id=47636

        Define new roles in WebCore and map them to ATK accordingly.

        Test: platform/gtk/accessibility/aria-roles-unignored.html

        * accessibility/AccessibilityObject.h: Added new roles to
        represent paragraphs, labels, forms and div sections.
        * accessibility/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
        Return ParagraphRole, LabelRole, FormRole and DivRole when needed.
        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
        (atkRole): Map new WebCore roles to ATK Roles.
        (webkit_accessible_get_role): Remove code to define roles for
        paragraphs, labels, forms and divs based on node's tag name.

        Update mappings for the Mac platform.

        * accessibility/mac/AccessibilityObjectWrapper.mm:
        (createAccessibilityRoleMap): Add explicit mappings from the new
        roles introduced to NSAccessibilityGroupRole.

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/accessibility/aria-roles-unignored-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/aria-roles-unignored.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm

index cda03d0716724ac3ad185c55a4942f2ea9cb1ce9..3c0d6afc6b9dfc44072139e83dd15fe35682167c 100644 (file)
@@ -1,3 +1,15 @@
+2011-03-29  Mario Sanchez Prada  <msanchez@igalia.com>
+
+        Reviewed by Chris Fleizach.
+
+        AX: GTK: ARIA role is not respected on <p> <label> <div> and <form>
+        https://bugs.webkit.org/show_bug.cgi?id=47636
+
+        Added new layout test to check that roles are correct in GTK.
+
+        * platform/gtk/accessibility/aria-roles-unignored-expected.txt: Added.
+        * platform/gtk/accessibility/aria-roles-unignored.html: Added.
+
 2011-03-29  Jessie Berlin  <jberlin@apple.com>
 
         [Snow Leopard WebKit2 Release Tests] fast/images/move-image-to-new-document.html timing out
diff --git a/LayoutTests/platform/gtk/accessibility/aria-roles-unignored-expected.txt b/LayoutTests/platform/gtk/accessibility/aria-roles-unignored-expected.txt
new file mode 100644 (file)
index 0000000..3255164
--- /dev/null
@@ -0,0 +1,26 @@
+Simple paragraph
+
+A paragraph pretending to be a table
+
+A label Who said label? It's a heading!
+A form with a button Click me!
+Just a button Click me!
+Just some text inside a div
+This div is contains a textbox (an entry)
+This tests that ARIA roles are not ignored for 'p','label', 'form' and 'div' elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS element.role is 'AXRole: paragraph'
+PASS element.role is 'AXRole: table'
+PASS element.role is 'AXRole: label'
+PASS element.role is 'AXRole: heading'
+PASS element.role is 'AXRole: form'
+PASS element.role is 'AXRole: push button'
+PASS element.role is 'AXRole: panel'
+PASS element.role is 'AXRole: entry'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/aria-roles-unignored.html b/LayoutTests/platform/gtk/accessibility/aria-roles-unignored.html
new file mode 100644 (file)
index 0000000..043734f
--- /dev/null
@@ -0,0 +1,67 @@
+<!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">
+
+<p>Simple paragraph</p>
+<p role="grid">A paragraph pretending to be a table</p>
+
+<label>A label</label>
+<label role="heading">Who said label? It's a heading!</label>
+
+<form>A form with a button <button name="button" value="Button">Click me!</button></form>
+<form role="button">Just a button <button name="button" value="Button">Click me!</button></form>
+
+<div>Just some text inside a div</form>
+<div role="textbox">This div is contains a textbox (an entry)</div>
+
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("This tests that ARIA roles are not ignored for 'p','label', 'form' and 'div' elements");
+
+if (window.layoutController) {
+    layoutTestController.dumpAsText();
+}
+
+if (window.accessibilityController) {
+    document.getElementById("body").focus();
+    var webArea = accessibilityController.focusedElement;
+
+    // Paragraphs
+    var element = webArea.childAtIndex(0);
+    shouldBe("element.role", "'AXRole: paragraph'");
+    element = webArea.childAtIndex(1);
+    shouldBe("element.role", "'AXRole: table'");
+
+    // Labels are exposed as inside a panel
+    var labelsPanel = webArea.childAtIndex(2);
+    element = labelsPanel.childAtIndex(0);
+    shouldBe("element.role", "'AXRole: label'");
+    element = labelsPanel.childAtIndex(1);
+    shouldBe("element.role", "'AXRole: heading'");
+
+    // Forms
+    element = webArea.childAtIndex(3);
+    shouldBe("element.role", "'AXRole: form'");
+    element = webArea.childAtIndex(4);
+    shouldBe("element.role", "'AXRole: push button'");
+
+    // Divs
+    element = webArea.childAtIndex(5);
+    shouldBe("element.role", "'AXRole: panel'");
+    element = webArea.childAtIndex(6);
+    shouldBe("element.role", "'AXRole: entry'");
+}
+
+successfullyParsed = true;
+</script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 1cac597dd4b12e1ea03fe13563125432e2e23106..830ef0b03ed1c4dcd9ee450f66303a6d2c224e87 100644 (file)
@@ -1,3 +1,30 @@
+2011-03-29  Mario Sanchez Prada  <msanchez@igalia.com>
+
+        Reviewed by Chris Fleizach.
+
+        AX: GTK: ARIA role is not respected on <p> <label> <div> and <form>
+        https://bugs.webkit.org/show_bug.cgi?id=47636
+
+        Define new roles in WebCore and map them to ATK accordingly.
+
+        Test: platform/gtk/accessibility/aria-roles-unignored.html
+
+        * accessibility/AccessibilityObject.h: Added new roles to
+        represent paragraphs, labels, forms and div sections.
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        Return ParagraphRole, LabelRole, FormRole and DivRole when needed.
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (atkRole): Map new WebCore roles to ATK Roles.
+        (webkit_accessible_get_role): Remove code to define roles for
+        paragraphs, labels, forms and divs based on node's tag name.
+
+        Update mappings for the Mac platform.
+
+        * accessibility/mac/AccessibilityObjectWrapper.mm:
+        (createAccessibilityRoleMap): Add explicit mappings from the new
+        roles introduced to NSAccessibilityGroupRole.
+
 2011-03-29  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed build fix. Remove ASSERT hitting consitently on GTK.
index 4687cae72c1085409fcefeeaf7f4b1a89593c06b..2d27e39d86cc6a5db0514c8ec7a5fefabdebf738 100644 (file)
@@ -171,6 +171,10 @@ enum AccessibilityRole {
     ListItemRole,
     MenuListPopupRole,
     MenuListOptionRole,
+    ParagraphRole,
+    LabelRole,
+    DivRole,
+    FormRole,
 
     // ARIA Grouping roles
     LandmarkApplicationRole,
index 6d203a9e58be48fd72658b46387011023d62cb29..1d0fe5cd8c143528e11cd2e557cacff249a53af7 100644 (file)
@@ -3089,7 +3089,19 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
         return SplitterRole;
 #endif
 
-    if (m_renderer->isBlockFlow() || (node && node->hasTagName(labelTag)))
+    if (node && node->hasTagName(pTag))
+        return ParagraphRole;
+
+    if (node && node->hasTagName(labelTag))
+        return LabelRole;
+
+    if (node && node->hasTagName(divTag))
+        return DivRole;
+
+    if (node && node->hasTagName(formTag))
+        return FormRole;
+
+    if (m_renderer->isBlockFlow())
         return GroupRole;
     
     // If the element does not have role, but it has ARIA attributes, accessibility should fallback to exposing it as a group.
index e6c27e7eda908bf646fdd709cc78b5852debe8ec..7dff2e3526b7e7a972611555de336e926764ccc4 100644 (file)
@@ -476,6 +476,14 @@ static AtkRole atkRole(AccessibilityRole role)
     case ListItemRole:
     case ListBoxOptionRole:
         return ATK_ROLE_LIST_ITEM;
+    case ParagraphRole:
+        return ATK_ROLE_PARAGRAPH;
+    case LabelRole:
+        return ATK_ROLE_LABEL;
+    case DivRole:
+        return ATK_ROLE_SECTION;
+    case FormRole:
+        return ATK_ROLE_FORM;
     default:
         return ATK_ROLE_UNKNOWN;
     }
@@ -483,31 +491,16 @@ static AtkRole atkRole(AccessibilityRole role)
 
 static AtkRole webkit_accessible_get_role(AtkObject* object)
 {
-    AccessibilityObject* axObject = core(object);
+    AccessibilityObject* coreObject = core(object);
 
-    if (!axObject)
+    if (!coreObject)
         return ATK_ROLE_UNKNOWN;
 
-    // WebCore does not know about paragraph role, label role, or section role
-    if (axObject->isAccessibilityRenderObject()) {
-        Node* node = static_cast<AccessibilityRenderObject*>(axObject)->renderer()->node();
-        if (node) {
-            if (node->hasTagName(HTMLNames::pTag))
-                return ATK_ROLE_PARAGRAPH;
-            if (node->hasTagName(HTMLNames::labelTag))
-                return ATK_ROLE_LABEL;
-            if (node->hasTagName(HTMLNames::divTag))
-                return ATK_ROLE_SECTION;
-            if (node->hasTagName(HTMLNames::formTag))
-                return ATK_ROLE_FORM;
-        }
-    }
-
     // Note: Why doesn't WebCore have a password field for this
-    if (axObject->isPasswordField())
+    if (coreObject->isPasswordField())
         return ATK_ROLE_PASSWORD_TEXT;
 
-    return atkRole(axObject->roleValue());
+    return atkRole(coreObject->roleValue());
 }
 
 static bool selectionBelongsToObject(AccessibilityObject* coreObject, VisibleSelection& selection)
index a4c8d8a11f8c0c300b025ba6c97afa4094a33bb2..c0dd7955965b4529c37c41bb583a257dd630558e 100644 (file)
@@ -1287,7 +1287,11 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { TabPanelRole, NSAccessibilityGroupRole },
         { TreeRole, NSAccessibilityOutlineRole },
         { TreeItemRole, NSAccessibilityRowRole },
-        { ListItemRole, NSAccessibilityGroupRole }
+        { ListItemRole, NSAccessibilityGroupRole },
+        { ParagraphRole, NSAccessibilityGroupRole },
+        { LabelRole, NSAccessibilityGroupRole },
+        { DivRole, NSAccessibilityGroupRole },
+        { FormRole, NSAccessibilityGroupRole }
     };
     AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;