зеркало из https://github.com/mozilla/pjs.git
Bug 346906. GetLinkIndex() is off by 1. r=neo.liu
This commit is contained in:
Родитель
1902f15696
Коммит
99f4ac25ce
|
@ -49,6 +49,11 @@ interface nsIAccessibleHyperText : nsISupports
|
||||||
|
|
||||||
nsIAccessibleHyperLink getLink (in long index);
|
nsIAccessibleHyperLink getLink (in long index);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the link index at this character index.
|
||||||
|
* Return value of -1 indicates no link at that index.
|
||||||
|
*/
|
||||||
long getLinkIndex (in long charIndex);
|
long getLinkIndex (in long charIndex);
|
||||||
|
|
||||||
long getSelectedLinkIndex ();
|
long getSelectedLinkIndex ();
|
||||||
};
|
};
|
||||||
|
|
|
@ -846,15 +846,17 @@ NS_IMETHODIMP nsHyperTextAccessible::GetLink(PRInt32 aIndex, nsIAccessibleHyperL
|
||||||
|
|
||||||
NS_IMETHODIMP nsHyperTextAccessible::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *aLinkIndex)
|
NS_IMETHODIMP nsHyperTextAccessible::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *aLinkIndex)
|
||||||
{
|
{
|
||||||
*aLinkIndex = -1;
|
*aLinkIndex = -1; // API says this magic value means 'not found'
|
||||||
|
|
||||||
PRInt32 characterCount = 0;
|
PRInt32 characterCount = 0;
|
||||||
|
PRInt32 linkIndex = 0;
|
||||||
if (!mDOMNode) {
|
if (!mDOMNode) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessible> accessible;
|
nsCOMPtr<nsIAccessible> accessible;
|
||||||
|
|
||||||
while (NextChild(accessible)) {
|
while (NextChild(accessible) && characterCount < aCharIndex) {
|
||||||
PRUint32 role = Role(accessible);
|
PRUint32 role = Role(accessible);
|
||||||
if (role == ROLE_TEXT_LEAF) {
|
if (role == ROLE_TEXT_LEAF) {
|
||||||
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(accessible));
|
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(accessible));
|
||||||
|
@ -864,19 +866,16 @@ NS_IMETHODIMP nsHyperTextAccessible::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (characterCount == aCharIndex) {
|
if (characterCount ++ == aCharIndex) {
|
||||||
return NS_OK;
|
*aLinkIndex = linkIndex;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (characterCount > aCharIndex) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
++ characterCount;
|
|
||||||
if (role != ROLE_WHITESPACE) {
|
if (role != ROLE_WHITESPACE) {
|
||||||
++ *aLinkIndex;
|
++ linkIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_ERROR_FAILURE;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsHyperTextAccessible::GetSelectedLinkIndex(PRInt32 *aSelectedLinkIndex)
|
NS_IMETHODIMP nsHyperTextAccessible::GetSelectedLinkIndex(PRInt32 *aSelectedLinkIndex)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче