Bug 296405. Fix nsIAccessible::GetLastChild(). Patch thanks to Peter Parente (parente@cs.unc.edu). r=aaronlev, sr=neil, a=bsmedberg

This commit is contained in:
aaronleventhal%moonset.net 2005-06-27 15:52:12 +00:00
Родитель d6990cbc87
Коммит ce289541bf
2 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -164,7 +164,7 @@ interface nsIAccessible : nsISupports
nsIAccessible getChildAtPoint(in long x, in long y);
/**
* Nth accessible child using zero-based index
* Nth accessible child using zero-based index or last child if index less than zero
*/
nsIAccessible getChildAt(in long aChildIndex);

Просмотреть файл

@ -484,14 +484,17 @@ NS_IMETHODIMP nsAccessible::GetLastChild(nsIAccessible * *aLastChild)
NS_IMETHODIMP nsAccessible::GetChildAt(PRInt32 aChildNum, nsIAccessible **aChild)
{
// aChildNum is a zero-based index
// If aChildNum is out of range, last child is returned
PRInt32 numChildren;
GetChildCount(&numChildren);
if (aChildNum >= numChildren || !mWeakShell) {
// If no children or aChildNum is larger than numChildren, return null
if (aChildNum >= numChildren || numChildren == 0 || !mWeakShell) {
*aChild = nsnull;
return NS_ERROR_FAILURE;
// If aChildNum is less than zero, set aChild to last index
} else if (aChildNum < 0) {
aChildNum = numChildren - 1;
}
nsCOMPtr<nsIAccessible> current(mFirstChild), nextSibling;