Bug 492530 - allow aria-labelledby to work in anonymous content, r=marcoz, davidb

--HG--
rename : accessible/tests/mochitest/nsIAccessible_name.css => accessible/tests/mochitest/name.css
rename : accessible/tests/mochitest/nsIAccessible_name.js => accessible/tests/mochitest/name.js
rename : accessible/tests/mochitest/nsIAccessible_name.xbl => accessible/tests/mochitest/name.xbl
rename : accessible/tests/mochitest/test_nsIAccessible_name.html => accessible/tests/mochitest/test_name.html
rename : accessible/tests/mochitest/test_nsIAccessible_name.xul => accessible/tests/mochitest/test_name.xul
rename : accessible/tests/mochitest/test_nsIAccessible_name_button.html => accessible/tests/mochitest/test_name_button.html
rename : accessible/tests/mochitest/test_nsIAccessible_name_link.html => accessible/tests/mochitest/test_name_link.html
This commit is contained in:
Alexander Surkov 2009-05-13 13:13:12 +08:00
Родитель 7203ebd6c9
Коммит e33f660697
10 изменённых файлов: 67 добавлений и 23 удалений

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

@ -749,18 +749,22 @@ nsCoreUtils::GetElementsByIDRefsAttr(nsIContent *aContent, nsIAtom *aAttr,
nsIArray **aRefElements) nsIArray **aRefElements)
{ {
*aRefElements = nsnull; *aRefElements = nsnull;
nsAutoString ids; nsAutoString ids;
if (!aContent->GetAttr(kNameSpaceID_None, aAttr, ids)) if (!aContent->GetAttr(kNameSpaceID_None, aAttr, ids))
return; return;
ids.CompressWhitespace(PR_TRUE, PR_TRUE); ids.CompressWhitespace(PR_TRUE, PR_TRUE);
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(aContent->GetOwnerDoc()); nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(aContent->GetOwnerDoc());
NS_ASSERTION(document, "The given node is not in document!"); NS_ASSERTION(document, "The given node is not in document!");
if (!document) if (!document)
return; return;
nsCOMPtr<nsIDOMDocumentXBL> xblDocument;
if (aContent->IsInAnonymousSubtree())
xblDocument = do_QueryInterface(document);
nsCOMPtr<nsIMutableArray> refElms = do_CreateInstance(NS_ARRAY_CONTRACTID); nsCOMPtr<nsIMutableArray> refElms = do_CreateInstance(NS_ARRAY_CONTRACTID);
while (!ids.IsEmpty()) { while (!ids.IsEmpty()) {
@ -777,8 +781,20 @@ nsCoreUtils::GetElementsByIDRefsAttr(nsIContent *aContent, nsIAtom *aAttr,
ids.Cut(0, idLength + 1); ids.Cut(0, idLength + 1);
} }
// If content is anonymous subtree then use "anonid" attribute to get
// elements, otherwise search elements in DOM by ID attribute.
nsCOMPtr<nsIDOMElement> refElement; nsCOMPtr<nsIDOMElement> refElement;
document->GetElementById(id, getter_AddRefs(refElement)); if (xblDocument) {
nsCOMPtr<nsIDOMElement> elm =
do_QueryInterface(aContent->GetBindingParent());
xblDocument->GetAnonymousElementByAttribute(elm,
NS_LITERAL_STRING("anonid"),
id,
getter_AddRefs(refElement));
} else {
document->GetElementById(id, getter_AddRefs(refElement));
}
if (!refElement) if (!refElement)
continue; continue;

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

@ -56,10 +56,10 @@ _TEST_FILES =\
events.js \ events.js \
grid.js \ grid.js \
layout.js \ layout.js \
name.css \
name.js \
name.xbl \
namerules.xml \ namerules.xml \
nsIAccessible_name.css \
nsIAccessible_name.js \
nsIAccessible_name.xbl \
nsIAccessible_selects.js \ nsIAccessible_selects.js \
nsIAccessible_states.js \ nsIAccessible_states.js \
nsIAccessibleEditableText.js \ nsIAccessibleEditableText.js \
@ -88,14 +88,14 @@ _TEST_FILES =\
test_events_tree.xul \ test_events_tree.xul \
test_groupattrs.xul \ test_groupattrs.xul \
test_groupattrs.html \ test_groupattrs.html \
test_name.html \
test_name.xul \
test_name_button.html \
test_name_link.html \
test_name_markup.html \ test_name_markup.html \
$(warning test_table_indexes.html temporarily disabled) \ $(warning test_table_indexes.html temporarily disabled) \
test_nsIAccessible_applicationAccessible.html \ test_nsIAccessible_applicationAccessible.html \
$(warning test_nsIAccessible_comboboxes.xul temporarily disabled) \ $(warning test_nsIAccessible_comboboxes.xul temporarily disabled) \
test_nsIAccessible_name.html \
test_nsIAccessible_name_button.html \
test_nsIAccessible_name_link.html \
test_nsIAccessible_name.xul \
test_nsIAccessible_selects.html \ test_nsIAccessible_selects.html \
test_nsIAccessible_focus.html \ test_nsIAccessible_focus.html \
test_nsIAccessibleDocument.html \ test_nsIAccessibleDocument.html \

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

@ -1,11 +1,11 @@
box.first { box.first {
-moz-binding: url('chrome://mochikit/content/a11y/accessible/nsIAccessible_name.xbl#first'); -moz-binding: url('chrome://mochikit/content/a11y/accessible/name.xbl#first');
} }
.second { .second {
-moz-binding: url('chrome://mochikit/content/a11y/accessible/nsIAccessible_name.xbl#second'); -moz-binding: url('chrome://mochikit/content/a11y/accessible/name.xbl#second');
} }
.third { .third {
-moz-binding: url('chrome://mochikit/content/a11y/accessible/nsIAccessible_name.xbl#third'); -moz-binding: url('chrome://mochikit/content/a11y/accessible/name.xbl#third');
} }

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

@ -6,10 +6,11 @@ function testName(aAccOrElmOrID, aName, aMsg)
if (!acc) if (!acc)
return; return;
var txtID = prettyName(aAccOrElmOrID);
try { try {
is(acc.name, aName, msg + "Wrong name of the accessible for " + aAccOrElmOrID); is(acc.name, aName, msg + "Wrong name of the accessible for " + txtID);
} catch (e) { } catch (e) {
ok(false, msg + "Can't get name of the accessible for " + aAccOrElmOrID); ok(false, msg + "Can't get name of the accessible for " + txtID);
} }
return acc; return acc;
} }

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

@ -21,4 +21,12 @@
</content> </content>
</binding> </binding>
<binding id="third">
<content>
<xul:description anonid="label" value="It's a " />
<xul:description anonid="label2" value="cool button" />
<xul:button anonid="button" aria-labelledby="label label2"
value="button" />
</content>
</binding>
</bindings> </bindings>

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

@ -2,16 +2,18 @@
<head> <head>
<title>nsIAccessible::name calculation</title> <title>nsIAccessible::name calculation</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> <link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script> src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script> src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script> src="chrome://mochikit/content/a11y/accessible/name.js"></script>
<script type="application/javascript"> <script type="application/javascript">
function doTest() function doTest()

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

@ -2,7 +2,7 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?> <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?> type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.css" <?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/name.css"
type="text/css"?> type="text/css"?>
@ -19,7 +19,8 @@
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script> src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script> src="chrome://mochikit/content/a11y/accessible/name.js"></script>
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
function doTest() function doTest()
@ -48,6 +49,10 @@
testName("historyDays", "Remember 3 days"); testName("historyDays", "Remember 3 days");
testName("rememberAfter", null); // XUL labels doesn't allow name from subtree testName("rememberAfter", null); // XUL labels doesn't allow name from subtree
// Anonymous content (see name.xbl#third)
var anonBtn = getAccessible("labelledby_box_anon").lastChild;
testName(anonBtn, "It's a cool button");
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Name from subtree (single relation labelled_by). // Name from subtree (single relation labelled_by).
@ -171,6 +176,8 @@
]]> ]]>
</script> </script>
<hbox flex="1" style="overflow: auto;">
<body xmlns="http://www.w3.org/1999/xhtml"> <body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank" <a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279" href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279"
@ -184,6 +191,8 @@
</pre> </pre>
</body> </body>
<vbox flex="1">
<!-- aria-label, simple label --> <!-- aria-label, simple label -->
<button id="btn_simple_aria_label" aria-label="I am a button"/> <button id="btn_simple_aria_label" aria-label="I am a button"/>
<!-- aria-label plus aria-labelledby --> <!-- aria-label plus aria-labelledby -->
@ -201,6 +210,9 @@
<button id="btn_labelledby_texts" <button id="btn_labelledby_texts"
aria-labelledby="labelledby_text1 labelledby_text2"/> aria-labelledby="labelledby_text1 labelledby_text2"/>
<!-- aria-labelledby, multiple relations -->
<box class="third" id="labelledby_box_anon" role="group" />
<!-- trick aria-labelledby --> <!-- trick aria-labelledby -->
<checkbox id="rememberHistoryDays" <checkbox id="rememberHistoryDays"
label="Remember " label="Remember "
@ -314,5 +326,7 @@
</hbox> </hbox>
</vbox> </vbox>
</vbox>
</hbox>
</window> </window>

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

@ -8,10 +8,11 @@
src="chrome://mochikit/content/MochiKit/packed.js"></script> src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script> src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script> src="chrome://mochikit/content/a11y/accessible/name.js"></script>
<script type="application/javascript"> <script type="application/javascript">
function doTest() function doTest()

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

@ -10,10 +10,11 @@
src="chrome://mochikit/content/MochiKit/packed.js"></script> src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script> src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script> src="chrome://mochikit/content/a11y/accessible/name.js"></script>
<script type="application/javascript"> <script type="application/javascript">
function doTest() function doTest()

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

@ -8,12 +8,13 @@
src="chrome://mochikit/content/MochiKit/packed.js"></script> src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script> src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script> src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_name.js"></script> src="chrome://mochikit/content/a11y/accessible/name.js"></script>
<script type="application/javascript"> <script type="application/javascript">
// gA11yEventDumpID = "eventdump"; // gA11yEventDumpID = "eventdump";