Accessible* XULTreeColumAccessible::GetSiblingAtOffset(int32_t aOffset, nsresult* aError) const { if (aOffset < 0) return XULColumAccessible::GetSiblingAtOffset(aOffset, aError); if (aError) *aError = NS_OK; // fail peacefully nsCOMPtr<nsITreeBoxObject> tree = nsCoreUtils::GetTreeBoxObject(mContent); if (tree) { nsCOMPtr<nsITreeView> treeView; tree->GetView(getter_AddRefs(treeView)); if (treeView) { int32_t rowCount = 0; treeView->GetRowCount(&rowCount); if (rowCount > 0 && aOffset <= rowCount) { XULTreeAccessible* treeAcc = Parent()->AsXULTree(); if (treeAcc) return treeAcc->GetTreeItemAccessible(aOffset - 1); } } } return nullptr; }
Relation XULTreeItemAccessibleBase::RelationByType(RelationType aType) { switch (aType) { case RelationType::NODE_CHILD_OF: { int32_t parentIndex = -1; if (!NS_SUCCEEDED(mTreeView->GetParentIndex(mRow, &parentIndex))) return Relation(); if (parentIndex == -1) return Relation(mParent); XULTreeAccessible* treeAcc = mParent->AsXULTree(); return Relation(treeAcc->GetTreeItemAccessible(parentIndex)); } case RelationType::NODE_PARENT_OF: { bool isTrue = false; if (NS_FAILED(mTreeView->IsContainerEmpty(mRow, &isTrue)) || isTrue) return Relation(); if (NS_FAILED(mTreeView->IsContainerOpen(mRow, &isTrue)) || !isTrue) return Relation(); XULTreeAccessible* tree = mParent->AsXULTree(); return Relation(new XULTreeItemIterator(tree, mTreeView, mRow)); } default: return Relation(); } }
Relation XULTreeItemAccessibleBase::RelationByType(uint32_t aType) { if (!mTreeView) return Relation(); if (aType != nsIAccessibleRelation::RELATION_NODE_CHILD_OF) return Relation(); int32_t parentIndex = -1; if (!NS_SUCCEEDED(mTreeView->GetParentIndex(mRow, &parentIndex))) return Relation(); if (parentIndex == -1) return Relation(mParent); XULTreeAccessible* treeAcc = mParent->AsXULTree(); return Relation(treeAcc->GetTreeItemAccessible(parentIndex)); }