Bug 687414 - Add label_for relation for implicit labels. r=tbsaunde

This commit is contained in:
Eitan Isaacson 2013-09-19 14:51:58 -07:00
parent 879c9272a9
commit d0c91e45d7
4 changed files with 26 additions and 6 deletions

View File

@ -2020,10 +2020,8 @@ Accessible::RelationByType(uint32_t aType)
case nsIAccessibleRelation::RELATION_LABEL_FOR: {
Relation rel(new RelatedAccIterator(Document(), mContent,
nsGkAtoms::aria_labelledby));
if (mContent->Tag() == nsGkAtoms::label)
rel.AppendIter(new IDRefsIterator(mDoc, mContent, mContent->IsHTML() ?
nsGkAtoms::_for :
nsGkAtoms::control));
if (mContent->Tag() == nsGkAtoms::label && mContent->IsXUL())
rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::control));
return rel;
}

View File

@ -14,6 +14,8 @@
#include "Role.h"
#include "States.h"
#include "mozilla/dom/HTMLLabelElement.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
@ -62,6 +64,18 @@ HTMLLabelAccessible::NativeName(nsString& aName)
return aName.IsEmpty() ? eNameOK : eNameFromSubtree;
}
Relation
HTMLLabelAccessible::RelationByType(uint32_t aType)
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType == nsIAccessibleRelation::RELATION_LABEL_FOR) {
nsRefPtr<dom::HTMLLabelElement> label = dom::HTMLLabelElement::FromContent(mContent);
rel.AppendTarget(mDoc, label->GetControl());
}
return rel;
}
role
HTMLLabelAccessible::NativeRole()
{

View File

@ -61,6 +61,7 @@ public:
// Accessible
virtual a11y::role NativeRole();
virtual Relation RelationByType(uint32_t aType) MOZ_OVERRIDE;
protected:
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;

View File

@ -28,17 +28,24 @@
[ "label1_2", "label1_3" ]);
// ancestor html:label (implicit association)
todo(false, "no label_for relation on implicitly associated label, bug 687414");
//testRelation("label1_4", RELATION_LABEL_FOR, "control1_4");
testRelation("label1_4", RELATION_LABEL_FOR, "control1_4");
testRelation("control1_4", RELATION_LABELLED_BY, "label1_4");
testRelation("control1_4_option1", RELATION_LABELLED_BY, null);
testRelation("label1_5", RELATION_LABEL_FOR, "control1_5");
testRelation("control1_5", RELATION_LABELLED_BY, "label1_5");
testRelation("label1_6", RELATION_LABEL_FOR, "control1_6");
testRelation("control1_6", RELATION_LABELLED_BY, "label1_6");
testRelation("label1_7", RELATION_LABEL_FOR, "control1_7");
testRelation("control1_7", RELATION_LABELLED_BY, "label1_7");
testRelation("label1_8", RELATION_LABEL_FOR, "control1_8");
testRelation("control1_8", RELATION_LABELLED_BY, "label1_8");
testRelation("label1_9", RELATION_LABEL_FOR, "control1_9");
testRelation("control1_9", RELATION_LABELLED_BY, "label1_9");
testRelation("label1_10", RELATION_LABEL_FOR, "control1_10");
testRelation("control1_10", RELATION_LABELLED_BY, "label1_10");
testRelation("label1_11", RELATION_LABEL_FOR, "control1_11");
testRelation("control1_11", RELATION_LABELLED_BY, "label1_11");
testRelation("label1_12", RELATION_LABEL_FOR, "control1_12");
testRelation("control1_12", RELATION_LABELLED_BY, "label1_12");
testRelation("label1_13", RELATION_LABEL_FOR, null);