Bug 758072 - Fix backward sibling traversal in nsIAccessiblePivot. r=surkov

This commit is contained in:
Eitan Isaacson 2012-05-24 11:46:04 -07:00
parent 37d528b6db
commit cfaaeb46a5
4 changed files with 32 additions and 27 deletions

View File

@ -343,10 +343,10 @@ nsAccessiblePivot::MovePivotInternal(nsAccessible* aPosition)
nsAccessible*
nsAccessiblePivot::SearchBackward(nsAccessible* aAccessible,
nsIAccessibleTraversalRule* aRule,
bool searchCurrent,
nsresult* rv)
bool aSearchCurrent,
nsresult* aResult)
{
*rv = NS_OK;
*aResult = NS_OK;
// Initial position could be unset, in that case return null.
if (!aAccessible)
@ -357,9 +357,9 @@ nsAccessiblePivot::SearchBackward(nsAccessible* aAccessible,
PRUint16 filtered = nsIAccessibleTraversalRule::FILTER_IGNORE;
if (searchCurrent) {
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
if (aSearchCurrent) {
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
if (filtered & nsIAccessibleTraversalRule::FILTER_MATCH)
return accessible;
}
@ -371,16 +371,17 @@ nsAccessiblePivot::SearchBackward(nsAccessible* aAccessible,
if (!(accessible = parent->GetChildAt(--idxInParent)))
continue;
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
nsAccessible* lastChild;
while (!(filtered & nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE) &&
(lastChild = accessible->LastChild())) {
parent = accessible;
accessible = lastChild;
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
idxInParent = accessible->IndexInParent();
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
}
if (filtered & nsIAccessibleTraversalRule::FILTER_MATCH)
@ -390,8 +391,8 @@ nsAccessiblePivot::SearchBackward(nsAccessible* aAccessible,
if (!(accessible = parent))
break;
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
if (filtered & nsIAccessibleTraversalRule::FILTER_MATCH)
return accessible;
@ -403,10 +404,10 @@ nsAccessiblePivot::SearchBackward(nsAccessible* aAccessible,
nsAccessible*
nsAccessiblePivot::SearchForward(nsAccessible* aAccessible,
nsIAccessibleTraversalRule* aRule,
bool searchCurrent,
nsresult* rv)
bool aSearchCurrent,
nsresult* aResult)
{
*rv = NS_OK;
*aResult = NS_OK;
// Initial position could be not set, in that case begin search from root.
nsAccessible *accessible = (!aAccessible) ? mRoot.get() : aAccessible;
@ -414,9 +415,9 @@ nsAccessiblePivot::SearchForward(nsAccessible* aAccessible,
RuleCache cache(aRule);
PRUint16 filtered = nsIAccessibleTraversalRule::FILTER_IGNORE;
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
if (searchCurrent && (filtered & nsIAccessibleTraversalRule::FILTER_MATCH))
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
if (aSearchCurrent && (filtered & nsIAccessibleTraversalRule::FILTER_MATCH))
return accessible;
while (true) {
@ -424,8 +425,8 @@ nsAccessiblePivot::SearchForward(nsAccessible* aAccessible,
while (!(filtered & nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE) &&
(firstChild = accessible->FirstChild())) {
accessible = firstChild;
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
if (filtered & nsIAccessibleTraversalRule::FILTER_MATCH)
return accessible;
@ -447,8 +448,8 @@ nsAccessiblePivot::SearchForward(nsAccessible* aAccessible,
break;
accessible = sibling;
*rv = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*rv, nsnull);
*aResult = cache.ApplyFilter(accessible, &filtered);
NS_ENSURE_SUCCESS(*aResult, nsnull);
if (filtered & nsIAccessibleTraversalRule::FILTER_MATCH)
return accessible;

View File

@ -60,16 +60,16 @@ private:
*/
nsAccessible* SearchForward(nsAccessible* aAccessible,
nsIAccessibleTraversalRule* aRule,
bool searchCurrent,
nsresult* rv);
bool aSearchCurrent,
nsresult* aResult);
/*
* Reverse search in preorder for the first accessible to match the rule.
*/
nsAccessible* SearchBackward(nsAccessible* aAccessible,
nsIAccessibleTraversalRule* aRule,
bool searchCurrent,
nsresult* rv);
bool aSearchCurrent,
nsresult* aResult);
/*
* Update the pivot, and notify observers.

View File

@ -23,5 +23,9 @@
<a href="http://mozilla.org" title="Link 2 title">Link 2</a>
<a href="http://mozilla.org" title="Link 3 title">Link 3</a>
</p>
<ul>
<li>Hello<span> </span></li>
<li>World</li>
</ul>
</body>
</html>

View File

@ -61,7 +61,7 @@
'semper', ' nulla. ', 'Second Section Title',
'Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.',
'An ', 'embedded', ' document.', 'Hide me', 'Link 1', 'Link 2',
'Link 3']);
'Link 3', 'Hello', 'World']);
// Just a random smoke test to see if our setTextRange works.
gQueue.push(