Bug 628938 - Treewalker not working properly in Mozilla Treewalker Demo; r=sicking,smaug a=jst

This commit is contained in:
Craig Topper 2011-02-23 15:58:55 -08:00
Родитель fa91b12674
Коммит c0f6d411d8
1 изменённых файлов: 19 добавлений и 27 удалений

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

@ -389,7 +389,6 @@ nsresult nsTreeWalker::FirstChildInternal(PRBool aReversed, nsIDOMNode **_retval
* @returns Errorcode
*/
nsresult nsTreeWalker::NextSiblingInternal(PRBool aReversed, nsIDOMNode **_retval)
{
nsresult rv;
PRInt16 filtered;
@ -402,46 +401,39 @@ nsresult nsTreeWalker::NextSiblingInternal(PRBool aReversed, nsIDOMNode **_retva
return NS_OK;
while (1) {
nsCOMPtr<nsINode> sibling = aReversed ? node->GetPreviousSibling()
: node->GetNextSibling();
nsINode* sibling = aReversed ? node->GetPreviousSibling()
: node->GetNextSibling();
while (sibling) {
rv = TestNode(sibling, &filtered);
node = sibling;
rv = TestNode(node, &filtered);
NS_ENSURE_SUCCESS(rv, rv);
switch (filtered) {
case nsIDOMNodeFilter::FILTER_ACCEPT:
// Node found
mCurrentNode = sibling;
return CallQueryInterface(sibling, _retval);
case nsIDOMNodeFilter::FILTER_SKIP: {
nsINode *firstChild = aReversed ? sibling->GetLastChild()
: sibling->GetFirstChild();
if (firstChild) {
sibling = firstChild;
continue;
}
}
break;
case nsIDOMNodeFilter::FILTER_REJECT:
// Keep searching
break;
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
// Node found
mCurrentNode.swap(node);
return CallQueryInterface(mCurrentNode, _retval);
}
// If rejected or no children, try a sibling
if (filtered == nsIDOMNodeFilter::FILTER_REJECT ||
!(sibling = aReversed ? node->GetLastChild()
: node->GetFirstChild())) {
sibling = aReversed ? node->GetPreviousSibling()
: node->GetNextSibling();
}
sibling = aReversed ? sibling->GetPreviousSibling()
: sibling->GetNextSibling();
}
node = node->GetNodeParent();
if (!node || node == mRoot)
break;
return NS_OK;
// Is parent transparent in filtered view?
rv = TestNode(node, &filtered);
NS_ENSURE_SUCCESS(rv, rv);
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT)
break;
return NS_OK;
}
return NS_OK;
}