NS_IMETHODIMP nsXULTreeAccessible::GetFocusedChild(nsIAccessible **aFocusedChild) { NS_ENSURE_ARG_POINTER(aFocusedChild); *aFocusedChild = nsnull; if (IsDefunct()) return NS_ERROR_FAILURE; if (gLastFocusedNode != mContent) return NS_OK; nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect = do_QueryInterface(mContent); if (multiSelect) { PRInt32 row = -1; multiSelect->GetCurrentIndex(&row); if (row >= 0) NS_IF_ADDREF(*aFocusedChild = GetTreeItemAccessible(row)); } return NS_OK; }
NS_IMETHODIMP nsXULTreeGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex, nsIAccessible **aCell) { NS_ENSURE_ARG_POINTER(aCell); *aCell = nsnull; if (IsDefunct()) return NS_ERROR_FAILURE; nsAccessible *rowAccessible = GetTreeItemAccessible(aRowIndex); if (!rowAccessible) return NS_ERROR_INVALID_ARG; nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetSensibleColumnAt(mTree, aColumnIndex); if (!column) return NS_ERROR_INVALID_ARG; nsRefPtr<nsXULTreeItemAccessibleBase> rowAcc = do_QueryObject(rowAccessible); NS_IF_ADDREF(*aCell = rowAcc->GetCellAccessible(column)); return NS_OK; }
nsAccessible* nsXULTreeAccessible::GetSelectedItem(PRUint32 aIndex) { nsCOMPtr<nsITreeSelection> selection; mTreeView->GetSelection(getter_AddRefs(selection)); if (!selection) return nsnull; PRUint32 selCount = 0; PRInt32 rangeCount = 0; selection->GetRangeCount(&rangeCount); for (PRInt32 rangeIdx = 0; rangeIdx < rangeCount; rangeIdx++) { PRInt32 firstIdx = 0, lastIdx = -1; selection->GetRangeAt(rangeIdx, &firstIdx, &lastIdx); for (PRInt32 rowIdx = firstIdx; rowIdx <= lastIdx; rowIdx++) { if (selCount == aIndex) return GetTreeItemAccessible(rowIdx); selCount++; } } return nsnull; }