Bug 1429940 - Part 1 - Use the first "label" element instead of the one inside "caption" to describe the "groupbox" element. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D11793

--HG--
extra : rebase_source : eec887ae45eb1a2b1356cef2f6cbbf24a5427f39
This commit is contained in:
Paolo Amadini 2018-11-15 12:05:09 +00:00
Родитель 9004df8f9b
Коммит 4d52da3cb2
5 изменённых файлов: 18 добавлений и 29 удалений

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

@ -174,7 +174,7 @@
testName("li_labelledby", "Show an Alert The moment the event starts");
//////////////////////////////////////////////////////////////////////////
// groupbox labeling from caption sub tree
// groupbox labeling from first label
testName("groupbox", "Some caption");
SimpleTest.finish();
@ -348,7 +348,7 @@
<!-- Name from caption sub tree -->
<groupbox id="groupbox">
<caption><label>Some caption</label></caption>
<label>Some caption</label>
<checkbox label="some checkbox label" />
</groupbox>
</vbox>

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

@ -103,8 +103,7 @@
// 'default button' relation
testRelation("textbox", RELATION_DEFAULT_BUTTON, "submit");
// 'labelled by'/'label for' relation for xul:goupbox and xul:label of
// xul:caption
// 'labelled by'/'label for' relation for xul:groupbox and xul:label
var groupboxAcc = getAccessible("groupbox");
var labelAcc = groupboxAcc.firstChild;
testRelation(labelAcc, RELATION_LABEL_FOR, groupboxAcc);
@ -211,7 +210,7 @@
<button id="submit" default="true" label="Default"/>
<groupbox id="groupbox">
<caption><label id="groupboxlabel" value="caption"/></caption>
<label value="caption"/>
</groupbox>
<tabbox>

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

@ -54,7 +54,7 @@
<vbox flex="1">
<groupbox id="groupbox">
<caption><label value="Some caption"/></caption>
<label value="Some caption"/>
<checkbox label="some checkbox label" />
</groupbox>
</vbox>

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

@ -89,12 +89,13 @@ Relation
XULLabelAccessible::RelationByType(RelationType aType) const
{
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
// The label for xul:groupbox is generated from the first xul:label
if (aType == RelationType::LABEL_FOR) {
// Caption is the label for groupbox
nsIContent* parent = mContent->GetFlattenedTreeParent();
if (parent && parent->IsXULElement(nsGkAtoms::caption)) {
Accessible* parent = Parent();
if (parent && parent->Role() == roles::GROUPING)
if (parent && parent->Role() == roles::GROUPING &&
parent->GetContent()->IsXULElement(nsGkAtoms::groupbox) &&
parent->GetChildAt(0) == this) {
rel.AppendTarget(parent);
}
}

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

@ -286,26 +286,15 @@ Relation
XULGroupboxAccessible::RelationByType(RelationType aType) const
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType != RelationType::LABELLED_BY)
return rel;
// The label for xul:groupbox is generated from xul:label that is
// inside the anonymous content of the xul:caption.
// The xul:label has an accessible object but the xul:caption does not
uint32_t childCount = ChildCount();
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
Accessible* childAcc = GetChildAt(childIdx);
if (childAcc->Role() == roles::LABEL) {
// Ensure that it's our label
Relation reverseRel = childAcc->RelationByType(RelationType::LABEL_FOR);
Accessible* testGroupbox = nullptr;
while ((testGroupbox = reverseRel.Next()))
if (testGroupbox == this) {
// The <label> points back to this groupbox
// The label for xul:groupbox is generated from the first xul:label
if (aType == RelationType::LABELLED_BY && ChildCount() > 0) {
Accessible* childAcc = GetChildAt(0);
if (childAcc->Role() == roles::LABEL &&
childAcc->GetContent()->IsXULElement(nsGkAtoms::label)) {
rel.AppendTarget(childAcc);
}
}
}
return rel;
}