Bug 627718 - Map used for grouping is not accessible under certain circumstances, r=marcoz

This commit is contained in:
Alexander Surkov 2011-10-05 15:24:44 +09:00
parent e98266ca22
commit fa5868ceaa
3 changed files with 93 additions and 9 deletions

View File

@ -70,6 +70,7 @@
#include "nsImageFrame.h"
#include "nsILink.h"
#include "nsIObserverService.h"
#include "nsLayoutUtils.h"
#include "nsNPAPIPluginInstance.h"
#include "nsISupportsUtils.h"
#include "nsObjectFrame.h"
@ -1012,15 +1013,14 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
if (isHTML && content->Tag() == nsGkAtoms::map) {
// Create hyper text accessible for HTML map if it is used to group links
// (see http://www.w3.org/TR/WCAG10-HTML-TECHS/#group-bypass). If the HTML
// map doesn't have 'name' attribute (or has empty name attribute) then we
// suppose it is used for links grouping. Otherwise we think it is used in
// conjuction with HTML image element and in this case we don't create any
// accessible for it and don't walk into it. The accessibles for HTML area
// (nsHTMLAreaAccessible) the map contains are attached as children of the
// appropriate accessible for HTML image (nsHTMLImageAccessible).
nsAutoString name;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
if (!name.IsEmpty()) {
// map rect is empty then it is used for links grouping. Otherwise it should
// be used in conjunction with HTML image element and in this case we don't
// create any accessible for it and don't walk into it. The accessibles for
// HTML area (nsHTMLAreaAccessible) the map contains are attached as
// children of the appropriate accessible for HTML image
// (nsHTMLImageAccessible).
if (nsLayoutUtils::GetAllInFlowRectsUnion(weakFrame,
weakFrame->GetParent()).IsEmpty()) {
if (aIsSubtreeHidden)
*aIsSubtreeHidden = true;

View File

@ -65,6 +65,7 @@ _TEST_FILES =\
test_img.html \
test_invalidationlist.html \
test_list.html \
test_map.html \
test_media.html \
test_select.html \
test_tabbox.xul \

View File

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html>
<head>
<title>HTML map accessible tree tests</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript">
function doTest()
{
// map used as imagemap, not accessible
var accTree =
{ SECTION: [ ] };
testAccessibleTree("imagemapcontainer", accTree);
// map group
accTree =
{ PARAGRAPH: [
{ PARAGRAPH: [
{ TEXT_LEAF: [ ] },
{ LINK: [
{ TEXT_LEAF: [ ] }
] },
{ TEXT_LEAF: [ ] },
{ LINK: [
{ TEXT_LEAF: [ ] }
] },
{ TEXT_LEAF: [ ] }
] }
] };
testAccessibleTree("mapgroup", accTree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Map used for grouping is not accessible under certain circumstances"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=627718">
Mozilla Bug 627718
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="imagemapcontainer">
<map name="atoz_map">
<area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#b"
coords="17,0,30,14" alt="b" shape="rect">
<area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#a"
coords="0,0,13,14" alt="a" shape="rect">
</map>
</div>
<img id="imgmap" width="447" height="15"
usemap="#atoz_map"
src="../letters.gif">
<map id="mapgroup" title="Navigation Bar" name="mapgroup">
<p>
[<a href="#how">Bypass navigation bar</a>]
[<a href="home.html">Home</a>]
</p>
</map>
</body>
</html>