Bug 1176123 - Add NODE_CHILD_OF/NODE_PARENT_OF relations to mroot. r=surkov

This commit is contained in:
Frédéric Wang 2015-06-24 15:40:00 +02:00
parent 37ed20bae0
commit 08ede9947e
3 changed files with 52 additions and 2 deletions

View File

@ -1755,6 +1755,42 @@ HyperTextAccessible::RemoveChild(Accessible* aAccessible)
return Accessible::RemoveChild(aAccessible);
}
Relation
HyperTextAccessible::RelationByType(RelationType aType)
{
Relation rel = Accessible::RelationByType(aType);
switch (aType) {
case RelationType::NODE_CHILD_OF:
if (mContent->IsMathMLElement()) {
Accessible* parent = Parent();
if (parent) {
nsIContent* parentContent = parent->GetContent();
if (parentContent->IsMathMLElement(nsGkAtoms::mroot_)) {
// Add a relation pointing to the parent <mroot>.
rel.AppendTarget(parent);
}
}
}
break;
case RelationType::NODE_PARENT_OF:
if (mContent->IsMathMLElement(nsGkAtoms::mroot_)) {
Accessible* base = GetChildAt(0);
Accessible* index = GetChildAt(1);
if (base && index) {
// Append the <mroot> children in the order index, base.
rel.AppendTarget(index);
rel.AppendTarget(base);
}
}
break;
default:
break;
}
return rel;
}
void
HyperTextAccessible::CacheChildren()
{

View File

@ -62,6 +62,7 @@ public:
virtual void InvalidateChildren() override;
virtual bool RemoveChild(Accessible* aAccessible) override;
virtual Relation RelationByType(RelationType aType) override;
// HyperTextAccessible (static helper method)

View File

@ -125,6 +125,19 @@
obj = {
role: ROLE_MATHML_ROOT,
relations: {
RELATION_NODE_PARENT_OF: ["mroot_index", "mroot_base"]
},
children: [
{
role: ROLE_MATHML_IDENTIFIER,
relations: { RELATION_NODE_CHILD_OF: "mroot" }
},
{
role: ROLE_MATHML_NUMBER,
relations: { RELATION_NODE_CHILD_OF: "mroot" }
}
]
};
testElm("mroot", obj);
@ -386,8 +399,8 @@
<mn>2</mn>
</mfrac>
<mroot id="mroot">
<mi>x</mi>
<mn>5</mn>
<mi id="mroot_base">x</mi>
<mn id="mroot_index">5</mn>
</mroot>
<mspace width="1em"/>
<mfenced id="mfenced" close="[" open="]" separators=".">