Skip to content

Commit

Permalink
2011-03-29 Mario Sanchez Prada <msanchez@igalia.com>
Browse files Browse the repository at this point in the history
        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.

Canonical link: https://commits.webkit.org/72097@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
mariospr committed Mar 29, 2011
1 parent dd2dd20 commit 1dffe62
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 21 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
@@ -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
Expand Down
@@ -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

67 changes: 67 additions & 0 deletions LayoutTests/platform/gtk/accessibility/aria-roles-unignored.html
@@ -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>
27 changes: 27 additions & 0 deletions Source/WebCore/ChangeLog
@@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/accessibility/AccessibilityObject.h
Expand Up @@ -171,6 +171,10 @@ enum AccessibilityRole {
ListItemRole,
MenuListPopupRole,
MenuListOptionRole,
ParagraphRole,
LabelRole,
DivRole,
FormRole,

// ARIA Grouping roles
LandmarkApplicationRole,
Expand Down
14 changes: 13 additions & 1 deletion Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Expand Up @@ -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.
Expand Down
31 changes: 12 additions & 19 deletions Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
Expand Up @@ -476,38 +476,31 @@ 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;
}
}

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)
Expand Down
Expand Up @@ -1287,7 +1287,11 @@ - (NSValue*)position
{ TabPanelRole, NSAccessibilityGroupRole },
{ TreeRole, NSAccessibilityOutlineRole },
{ TreeItemRole, NSAccessibilityRowRole },
{ ListItemRole, NSAccessibilityGroupRole }
{ ListItemRole, NSAccessibilityGroupRole },
{ ParagraphRole, NSAccessibilityGroupRole },
{ LabelRole, NSAccessibilityGroupRole },
{ DivRole, NSAccessibilityGroupRole },
{ FormRole, NSAccessibilityGroupRole }
};
AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;

Expand Down

0 comments on commit 1dffe62

Please sign in to comment.