From a53d1722d2942684b93adbd4a41fb1ef17fc3d23 Mon Sep 17 00:00:00 2001 From: mjs Date: Fri, 19 Nov 2004 00:49:09 +0000 Subject: [PATCH] Reviewed by Chris. - fix recursive item traversal, use traverseNextNode() instead of the buggy hand-rolled traversal. * khtml/xml/dom_nodeimpl.cpp: (NodeListImpl::recursiveItem): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8042 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog-2005-08-23 | 10 ++++++++++ WebCore/khtml/xml/dom_nodeimpl.cpp | 13 ++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23 index 99e54b94fe9d..26527195b9bd 100644 --- a/WebCore/ChangeLog-2005-08-23 +++ b/WebCore/ChangeLog-2005-08-23 @@ -1,3 +1,13 @@ +2004-11-18 Maciej Stachowiak + + Reviewed by Chris. + + - fix recursive item traversal, use traverseNextNode() instead of + the buggy hand-rolled traversal. + + * khtml/xml/dom_nodeimpl.cpp: + (NodeListImpl::recursiveItem): + 2004-11-17 Darin Adler Reviewed by Ken. diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp index 17416bbbdbf1..0d5976352dab 100644 --- a/WebCore/khtml/xml/dom_nodeimpl.cpp +++ b/WebCore/khtml/xml/dom_nodeimpl.cpp @@ -2331,10 +2331,9 @@ NodeImpl *NodeListImpl::recursiveItem ( unsigned long offset, NodeImpl *start) c } } - NodeImpl *end = rootNode->nextSibling(); NodeImpl *n = start; - while (n != 0 && n != end) { + while (n) { if ( n->nodeType() == Node::ELEMENT_NODE ) { if (nodeMatches(n)) { if (!remainingOffset) { @@ -2347,15 +2346,7 @@ NodeImpl *NodeListImpl::recursiveItem ( unsigned long offset, NodeImpl *start) c } } - if (n->firstChild()) { - n = n->firstChild(); - } else if (n->nextSibling()) { - n = n->nextSibling(); - } else if (n->parentNode()) { - n = n->parentNode()->nextSibling(); - } else { - n = 0; - } + n = n->traverseNextNode(rootNode); } return 0; // no matching node in this subtree -- 2.36.0