mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 502164 - expose NODE_CHILD_OF relation for ARIA treegrids on rows, r=davidb
This commit is contained in:
parent
0fc0510b23
commit
7661d79018
@ -408,14 +408,30 @@ nsAccUtils::GetARIATreeItemParent(nsIAccessible *aStartTreeItem,
|
||||
nsIAccessible **aTreeItemParentResult)
|
||||
{
|
||||
*aTreeItemParentResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessible> parentAccessible;
|
||||
aStartTreeItem->GetParent(getter_AddRefs(parentAccessible));
|
||||
if (!parentAccessible)
|
||||
return;
|
||||
|
||||
PRUint32 startTreeItemRole = nsAccUtils::Role(aStartTreeItem);
|
||||
|
||||
// Calculate tree grid row parent only if the row inside of ARIA treegrid.
|
||||
if (startTreeItemRole == nsIAccessibleRole::ROLE_ROW) {
|
||||
PRUint32 role = nsAccUtils::Role(parentAccessible);
|
||||
if (role != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
return;
|
||||
}
|
||||
|
||||
// This is a tree or treegrid that uses aria-level to define levels, so find
|
||||
// the first previous sibling accessible where level is defined to be less
|
||||
// than the current level.
|
||||
nsAutoString levelStr;
|
||||
PRInt32 level = 0;
|
||||
if (nsAccUtils::HasDefinedARIAToken(aStartContent, nsAccessibilityAtoms::aria_level) &&
|
||||
aStartContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_level, levelStr)) {
|
||||
// This is a tree that uses aria-level to define levels, so find the first previous
|
||||
// sibling accessible where level is defined to be less than the current level
|
||||
|
||||
PRInt32 success;
|
||||
level = levelStr.ToInteger(&success);
|
||||
PRInt32 level = levelStr.ToInteger(&success);
|
||||
if (level > 1 && NS_SUCCEEDED(success)) {
|
||||
nsCOMPtr<nsIAccessible> currentAccessible = aStartTreeItem, prevAccessible;
|
||||
while (PR_TRUE) {
|
||||
@ -426,8 +442,9 @@ nsAccUtils::GetARIATreeItemParent(nsIAccessible *aStartTreeItem,
|
||||
break; // Reached top of tree, no higher level found
|
||||
}
|
||||
PRUint32 role = nsAccUtils::Role(currentAccessible);
|
||||
if (role != nsIAccessibleRole::ROLE_OUTLINEITEM)
|
||||
if (role != startTreeItemRole)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> treeItemNode;
|
||||
accessNode->GetDOMNode(getter_AddRefs(treeItemNode));
|
||||
nsCOMPtr<nsIContent> treeItemContent = do_QueryInterface(treeItemNode);
|
||||
@ -445,19 +462,25 @@ nsAccUtils::GetARIATreeItemParent(nsIAccessible *aStartTreeItem,
|
||||
}
|
||||
}
|
||||
|
||||
// Possibly a tree arranged by using role="group" to organize levels
|
||||
// In this case the parent of the tree item will be a group and the
|
||||
// previous sibling of that should be the tree item parent.
|
||||
// Or, if the parent is something other than a tree we will return that.
|
||||
nsCOMPtr<nsIAccessible> parentAccessible;
|
||||
aStartTreeItem->GetParent(getter_AddRefs(parentAccessible));
|
||||
if (!parentAccessible)
|
||||
return;
|
||||
// In the case of ARIA treegrid, return its parent since ARIA group isn't
|
||||
// used to organize levels in ARIA treegrids.
|
||||
|
||||
if (startTreeItemRole == nsIAccessibleRole::ROLE_ROW) {
|
||||
NS_ADDREF(*aTreeItemParentResult = parentAccessible);
|
||||
return; // The container for the tree grid rows
|
||||
}
|
||||
|
||||
// In the case of ARIA tree, a tree can be arranged by using role="group" to
|
||||
// organize levels. In this case the parent of the tree item will be a group
|
||||
// and the previous sibling of that should be the tree item parent. Or, if
|
||||
// the parent is something other than a tree we will return that.
|
||||
|
||||
PRUint32 role = nsAccUtils::Role(parentAccessible);
|
||||
if (role != nsIAccessibleRole::ROLE_GROUPING) {
|
||||
NS_ADDREF(*aTreeItemParentResult = parentAccessible);
|
||||
return; // The container for the tree items
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> prevAccessible;
|
||||
parentAccessible->GetPreviousSibling(getter_AddRefs(prevAccessible));
|
||||
if (!prevAccessible)
|
||||
|
@ -2492,13 +2492,16 @@ nsAccessible::GetRelationByType(PRUint32 aRelationType,
|
||||
if (rv != NS_OK_NO_RELATION_TARGET)
|
||||
return NS_OK; // XXX bug 381599, avoid performance problems
|
||||
|
||||
// This is an ARIA tree or treegrid that doesn't use owns, so we need to
|
||||
// get the parent the hard way.
|
||||
if (mRoleMapEntry &&
|
||||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_OUTLINEITEM) {
|
||||
// This is an ARIA tree that doesn't use owns, so we need to get
|
||||
// the parent the hard way.
|
||||
(mRoleMapEntry->role == nsIAccessibleRole::ROLE_OUTLINEITEM ||
|
||||
mRoleMapEntry->role == nsIAccessibleRole::ROLE_ROW)) {
|
||||
|
||||
nsCOMPtr<nsIAccessible> accTarget;
|
||||
nsAccUtils::GetARIATreeItemParent(this, content,
|
||||
getter_AddRefs(accTarget));
|
||||
|
||||
return nsRelUtils::AddTarget(aRelationType, aRelation, accTarget);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,12 @@
|
||||
testRelation("treeitem3", RELATION_NODE_CHILD_OF, "tree");
|
||||
testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree");
|
||||
testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4");
|
||||
testRelation("treeitem6", RELATION_NODE_CHILD_OF, "treeitem5");
|
||||
|
||||
// 'node child of' relation for row role of treegrid
|
||||
testRelation("treegridrow1", RELATION_NODE_CHILD_OF, "treegrid");
|
||||
testRelation("treegridrow2", RELATION_NODE_CHILD_OF, "treegrid");
|
||||
testRelation("treegridrow3", RELATION_NODE_CHILD_OF, "treegridrow2");
|
||||
|
||||
// 'node child of' relation for the document having window, returns
|
||||
// direct accessible parent (fixed in bug 419770).
|
||||
@ -147,6 +153,21 @@
|
||||
<div role="treeitem" id="treeitem3">Blue</div>
|
||||
<div role="treeitem" id="treeitem4" aria-level="1">Green</div>
|
||||
<div role="treeitem" id="treeitem5" aria-level="2">Light green</div>
|
||||
<div role="group">
|
||||
<div role="treeitem" id="treeitem6">Super light green</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div role="treegrid" id="treegrid">
|
||||
<div role="row" id="treegridrow1">
|
||||
<span role="gridcell">cell1</span><span role="gridcell">cell2</span>
|
||||
</div>
|
||||
<div role="row" id="treegridrow2" aria-level="1">
|
||||
<span role="gridcell">cell3</span><span role="gridcell">cell4</span>
|
||||
</div>
|
||||
<div role="row" id="treegridrow3" aria-level="2">
|
||||
<span role="gridcell">cell5</span><span role="gridcell">cell6</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<iframe id="iframe"></iframe>
|
||||
|
Loading…
Reference in New Issue
Block a user