Bug 473732 - Provide actions to set ARIA sort and expanded, r=surkov, r=MarcoZ

This commit is contained in:
David Bolter 2009-04-09 18:16:10 +02:00
Родитель 9ce70ae8c3
Коммит 8e5f0c1901
8 изменённых файлов: 105 добавлений и 6 удалений

Просмотреть файл

@ -123,7 +123,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
"columnheader",
nsIAccessibleRole::ROLE_COLUMNHEADER,
eNoValue,
eNoAction,
eSortAction,
eNoLiveAttr,
kNoReqStates,
{&nsAccessibilityAtoms::aria_selected, kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},
@ -417,7 +417,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
"rowheader",
nsIAccessibleRole::ROLE_ROWHEADER,
eNoValue,
eNoAction,
eSortAction,
eNoLiveAttr,
kNoReqStates,
{&nsAccessibilityAtoms::aria_selected, kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE},

Просмотреть файл

@ -57,9 +57,11 @@ enum EActionRule
eActivateAction,
eClickAction,
eCheckUncheckAction,
eExpandAction,
eJumpAction,
eOpenCloseAction,
eSelectAction,
eSortAction,
eSwitchAction
};

Просмотреть файл

@ -321,6 +321,8 @@ nsAccUtils::SetLiveContainerAttributes(nsIPersistentProperties *aAttributes,
PRBool
nsAccUtils::HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom)
{
NS_ASSERTION(aContent, "aContent is null in call to HasDefinedARIAToken!");
if (!aContent->HasAttr(kNameSpaceID_None, aAtom) ||
aContent->AttrValueIs(kNameSpaceID_None, aAtom,
nsAccessibilityAtoms::_empty, eCaseMatters) ||

Просмотреть файл

@ -2335,6 +2335,17 @@ nsAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
case eSwitchAction:
aName.AssignLiteral("switch");
return NS_OK;
case eSortAction:
aName.AssignLiteral("sort");
return NS_OK;
case eExpandAction:
if (states & nsIAccessibleStates::STATE_COLLAPSED)
aName.AssignLiteral("expand");
else
aName.AssignLiteral("collapse");
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
@ -3229,8 +3240,9 @@ nsAccessible::GetActionRule(PRUint32 aStates)
if (aStates & nsIAccessibleStates::STATE_UNAVAILABLE)
return eNoAction;
nsIContent* content = nsCoreUtils::GetRoleContent(mDOMNode);
// Check if it's simple xlink.
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (nsCoreUtils::IsXLink(content))
return eJumpAction;
@ -3240,11 +3252,17 @@ nsAccessible::GetActionRule(PRUint32 aStates)
if (isOnclick)
return eClickAction;
// Get an action based on ARIA role.
if (mRoleMapEntry)
if (mRoleMapEntry &&
mRoleMapEntry->actionRule != eNoAction)
return mRoleMapEntry->actionRule;
// Get an action based on ARIA attribute.
if (nsAccUtils::HasDefinedARIAToken(content,
nsAccessibilityAtoms::aria_expanded))
return eExpandAction;
return eNoAction;
}

Просмотреть файл

@ -65,6 +65,7 @@ _TEST_FILES =\
role.js \
test_accessnode_invalidation.html \
test_actions_aria.html \
test_actions_doc.html \
$(warning test_actions_inputs.html temporarily disabled) \
test_actions.xul \
test_aria_activedescendant.html \

Просмотреть файл

@ -99,6 +99,21 @@
ID: "treeitem",
actionName: "activate",
events: CLICK_EVENTS
},
{
ID: "sortable",
actionName: "sort",
events: CLICK_EVENTS
},
{
ID: "expandable",
actionName: "expand",
events: CLICK_EVENTS
},
{
ID: "collapseable",
actionName: "collapse",
events: CLICK_EVENTS
}
];
testActions(actionsArray);
@ -160,5 +175,14 @@
<div role="tree">
<div id="treeitem" role="treeitem">Treeitem</div>
</div>
<div role="grid">
<div id="sortable" role="columnheader" aria-sort="ascending">
Columnheader
</div>
</div>
<div id="expandable" aria-expanded="false">collapsed</div>
<div id="collapseable" aria-expanded="true">expanded</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,53 @@
<html>
<head>
<title>nsIAccessible actions testing for document</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_actions.js"></script>
<script type="application/javascript">
function doTest()
{
var docAcc = getAccessible(document, [nsIAccessibleDocument]);
if (!docAcc) {
SimpleTest.finish();
return;
}
is(docAcc.numActions, 1, "Wrong number of actions for document!");
is(docAcc.getActionName(0), "click", "Wrong action name for document!");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body role="button">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=473732"
title="Related to work on bug 473732">
Mozilla Bug 473732
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
</html>

Просмотреть файл

@ -19,7 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441737
<script type="application/javascript">
function doTest()
{
// Get accessible for body tag.
var docAcc = getAccessible(document, [nsIAccessibleDocument]);
if (docAcc) {
// nsIAccessible