mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 348037. GetIndexInParent impl for ATK counting too many children. r=ginn.chen
This commit is contained in:
parent
06d750b78a
commit
0985d3c59c
@ -902,12 +902,41 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
|
||||
gint
|
||||
getIndexInParentCB(AtkObject *aAtkObj)
|
||||
{
|
||||
// We don't use nsIAccessible::GetIndexInParent() because
|
||||
// for ATK we don't want to include text leaf nodes as children
|
||||
NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), -1);
|
||||
nsAccessibleWrap *accWrap =
|
||||
NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
|
||||
|
||||
PRInt32 currentIndex = -1;
|
||||
accWrap->GetIndexInParent(¤tIndex);
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
accWrap->GetParent(getter_AddRefs(parent));
|
||||
if (!parent) {
|
||||
return -1; // No parent
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> sibling;
|
||||
parent->GetFirstChild(getter_AddRefs(sibling));
|
||||
if (!sibling) {
|
||||
return -1; // Error, parent has no children
|
||||
}
|
||||
|
||||
PRInt32 currentIndex = 0;
|
||||
|
||||
while (sibling != NS_STATIC_CAST(nsIAccessible*, accWrap)) {
|
||||
NS_ASSERTION(sibling, "Never ran into the same child that we started from");
|
||||
|
||||
if (!sibling) {
|
||||
return -1;
|
||||
}
|
||||
if (nsAccessible::IsEmbeddedObject(sibling)) {
|
||||
++ currentIndex;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> tempAccessible;
|
||||
sibling->GetNextSibling(getter_AddRefs(tempAccessible));
|
||||
sibling.swap(tempAccessible);
|
||||
}
|
||||
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user