Bug 682790 - ignore implicit label association when it's associated explicitly, r=marcoz

This commit is contained in:
Alexander Surkov 2011-09-30 13:38:20 +09:00
parent 8f6aeecfc2
commit c116e6b189
3 changed files with 43 additions and 9 deletions

View File

@ -180,13 +180,16 @@ HTMLLabelIterator::Next()
nsAccessible* walkUp = mAcc->Parent();
while (walkUp && !walkUp->IsDoc()) {
nsIContent* walkUpElm = walkUp->GetContent();
if (walkUpElm->Tag() == nsGkAtoms::label) {
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
return walkUp;
}
if (walkUpElm->IsHTML()) {
if (walkUpElm->Tag() == nsGkAtoms::label &&
!walkUpElm->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
return walkUp;
}
if (walkUpElm->Tag() == nsGkAtoms::form)
break;
if (walkUpElm->Tag() == nsGkAtoms::form)
break;
}
walkUp = walkUp->Parent();
}

View File

@ -170,11 +170,13 @@
testName("combo4", "Subscribe to ATOM feed.");
testName("comboinmiddle2", "Play the Haliluya sound when new mail arrives");
testName("combo5", "Play the Haliluya sound when new mail arrives");
testName("combo5", null); // label isn't used as a name for control
testName("checkbox", "Play the Haliluya sound when new mail arrives");
testName("comboinmiddle3", "Play the Haliluya sound when new mail arrives");
testName("combo6", "Play the Haliluya sound when new mail arrives");
testName("comboinend", "This day was sunny");
testName("combo6", "This day was");
testName("combo7", "This day was");
testName("textboxinend", "This day was sunny");
testName("textbox2", "This day was");
@ -213,6 +215,11 @@
title="Use placeholder as name if name is otherwise empty">
Mozilla Bug 604391
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=669312"
title="Accessible name is duplicated when input has a label associated uisng for/id and is wrapped around the input">
Mozilla Bug 669312
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -437,10 +444,18 @@
</label>
<input id="checkbox" type="checkbox" />
<label id="comboinmiddle3" for="combo6">Play the
<select id="combo6">
<option>Haliluya</option>
<option>Hurra</option>
</select>
sound when new mail arrives
</label>
<!-- at the end (without and with whitespaces) -->
<label id="comboinend">
This day was
<select id="combo6" name="occupation">
<select id="combo7" name="occupation">
<option>sunny</option>
<option>rainy</option>
</select></label>

View File

@ -41,6 +41,10 @@
testRelation("control1_11", RELATION_LABELLED_BY, "label1_11");
testRelation("control1_12", RELATION_LABELLED_BY, "label1_12");
testRelation("label1_13", RELATION_LABEL_FOR, null);
testRelation("control1_13", RELATION_LABELLED_BY, null);
testRelation("control1_14", RELATION_LABELLED_BY, "label1_14");
// aria-labelledby
testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
testRelation("checkbox2", RELATION_LABELLED_BY, "label2");
@ -157,6 +161,11 @@
title="make HTML <output> accessible">
Mozilla Bug 558036
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=682790"
title="Ignore implicit label association when it's associated explicitly">
Mozilla Bug 682790
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=687393"
title="HTML select options gets relation from containing label">
@ -204,6 +213,13 @@
<progress id="control1_12"></progress>
</label>
<label id="label1_13" for="">Label
<input id="control1_13">
</label>
<label id="label1_14" for="control1_14">Label
<input id="control1_14">
</label>
<span id="label2">label</span>
<span role="checkbox" id="checkbox2" aria-labelledby="label2"></span>