Bug 548291 - Support ARIA on area (map) elements; r=MarcoZ,surkov

This commit is contained in:
David Bolter 2010-04-13 13:55:39 -04:00
parent 856ecc5649
commit 757cef32a2
7 changed files with 181 additions and 0 deletions

View File

@ -152,6 +152,9 @@ nsHTMLImageMapAccessible::CacheChildren()
return;
}
// We must respect ARIA on area elements (for the canvas map technique)
areaAcc->SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(areaNode));
mChildren.AppendElement(areaAcc);
areaAcc->SetParent(this);
}
@ -250,6 +253,19 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
////////////////////////////////////////////////////////////////////////////////
// nsHTMLAreaAccessible: nsAccessible public
nsresult
nsHTMLAreaAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
{
// Bypass the link states specialization for non links.
if (mRoleMapEntry &&
mRoleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING &&
mRoleMapEntry->role != nsIAccessibleRole::ROLE_LINK) {
return nsAccessible::GetStateInternal(aState,aExtraState);
}
return nsHTMLLinkAccessible::GetStateInternal(aState, aExtraState);
}
nsresult
nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
PRBool aDeepestChild,

View File

@ -92,6 +92,7 @@ public:
// nsAccessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
PRBool aDeepestChild,
nsIAccessible **aChild);

View File

@ -48,6 +48,7 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
formimage.png \
letters.gif \
moz.png \
$(topsrcdir)/content/media/test/bug461281.ogg \

View File

@ -47,6 +47,7 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_aria.html \
test_aria_imgmap.html \
test_doc.html \
test_docarticle.html \
test_editablebody.html \

View File

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<title>Test usemap elements and ARIA</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/role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
<script type="application/javascript">
function doTest()
{
testStates("t1", 0, EXT_STATE_EDITABLE, STATE_LINKED);
testStates("t2", 0, EXT_STATE_EDITABLE, STATE_LINKED);
testStates("rb1", (STATE_CHECKABLE | STATE_CHECKED), 0, STATE_LINKED);
testStates("rb2", STATE_CHECKABLE, 0, STATE_CHECKED, STATE_LINKED);
testStates("cb1", (STATE_CHECKABLE | STATE_CHECKED), 0, STATE_LINKED);
testStates("cbox", (STATE_HASPOPUP | STATE_COLLAPSED),
EXT_STATE_EXPANDABLE, STATE_LINKED);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=548291"
title="ARIA states on image maps">
Mozilla Bug 548291
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<img id="imagemap" src="../formimage.png" width="219" height="229" border="0" usemap="#ariaMap">
<map id="ariaMap" name="ariaMap">
<area id="t1" role="textbox" shape="rect" tabindex="0" alt="" title="first name" coords="4,20,108,48" href="#" />
<area id="t2" role="textbox" shape="rect" alt="" title="last name" coords="111,21,215,50" href="#" />
<area id="rb1" role="radio" aria-checked="true" shape="circle" alt="" title="male" coords="60,75,11" href="#" />
<area id="rb2" role="radio" shape="circle" alt="" title="female" coords="73,94,11" href="#" />
<area id="cb1" role="checkbox" aria-checked="true" shape="rect" alt="" title="have bike" coords="95,123,118,145" href="#" />
<area id="cbox" role="combobox" shape="rect" alt="" title="bike model" coords="120,124,184,146" href="#" />
<area id="cb2" role="checkbox" shape="rect" alt="" title="have car" coords="90,145,114,164" href="#" />
<area id="cb3" role="checkbox" shape="rect" alt="" title="have airplane" coords="130,163,152,184" href="#" />
<area id="b1" role="button" shape="rect" alt="" title="submit" coords="4,198,67,224" href="#" />
</map>
</body>
</html>

View File

@ -47,6 +47,7 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_aria_globals.html \
test_aria_imgmap.html \
test_button.xul \
test_colorpicker.xul \
test_combobox.xul \

View File

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html>
<head>
<title>Test usemap elements and ARIA</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/role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
<script type="application/javascript">
function doTest()
{
var accTree = {
role: ROLE_IMAGE_MAP,
children: [
{
role: ROLE_ENTRY,
name: "first name"
},
{
role: ROLE_ENTRY,
name: "last name"
},
{
role: ROLE_RADIOBUTTON,
name: "male"
},
{
role: ROLE_RADIOBUTTON,
name: "female"
},
{
role: ROLE_CHECKBUTTON,
name: "have bike"
},
{
role: ROLE_COMBOBOX,
name: "bike model"
},
{
role: ROLE_CHECKBUTTON,
name: "have car"
},
{
role: ROLE_CHECKBUTTON,
name: "have airplane"
},
{
role: ROLE_PUSHBUTTON,
name: "submit"
}
]
};
// Test image map tree structure, roles, and names.
testAccessibleTree("imagemap", accTree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=548291"
title="Accessible tree of ARIA image maps">
Mozilla Bug 548291
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<img id="imagemap" src="../formimage.png" width="219" height="229" border="0" usemap="#ariaMap">
<map id="ariaMap" name="ariaMap">
<area id="t1" role="textbox" shape="rect" tabindex="0" alt="" title="first name" coords="4,20,108,48" href="#" />
<area id="t2" role="textbox" shape="rect" alt="" title="last name" coords="111,21,215,50" href="#" />
<area id="rb1" role="radio" aria-checked="true" shape="circle" alt="" title="male" coords="60,75,11" href="#" />
<area id="rb2" role="radio" shape="circle" alt="" title="female" coords="73,94,11" href="#" />
<area id="cb1" role="checkbox" aria-checked="true" shape="rect" alt="" title="have bike" coords="95,123,118,145" href="#" />
<area id="cbox" role="combobox" shape="rect" alt="" title="bike model" coords="120,124,184,146" href="#" />
<area id="cb2" role="checkbox" shape="rect" alt="" title="have car" coords="90,145,114,164" href="#" />
<area id="cb3" role="checkbox" shape="rect" alt="" title="have airplane" coords="130,163,152,184" href="#" />
<area id="b1" role="button" shape="rect" alt="" title="submit" coords="4,198,67,224" href="#" />
</map>
</body>
</html>