From kde-commits Fri Jan 18 23:41:57 2008 From: Maks Orlovich Date: Fri, 18 Jan 2008 23:41:57 +0000 To: kde-commits Subject: branches/KDE/4.0/kdelibs/khtml Message-Id: <1200699717.692276.24270.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120069972914949 SVN commit 763247 by orlovich: - It helps to call the right method in the bindings - Fix bug in getPreviousNode, and my complete botching of getParentNode. Now acid3 test 6 passes (test 5 still needs work) M +1 -1 ecma/kjs_traversal.cpp M +12 -7 xml/dom2_traversalimpl.cpp --- branches/KDE/4.0/kdelibs/khtml/ecma/kjs_traversal.cpp #763246:763247 @@ -273,7 +273,7 @@ case DOMTreeWalker::NextSibling: return getDOMNode(exec,treeWalker.nextSibling()); case DOMTreeWalker::PreviousNode: - return getDOMNode(exec,treeWalker.previousSibling()); + return getDOMNode(exec,treeWalker.previousNode()); case DOMTreeWalker::NextNode: return getDOMNode(exec,treeWalker.nextNode()); } --- branches/KDE/4.0/kdelibs/khtml/xml/dom2_traversalimpl.cpp #763246:763247 @@ -445,7 +445,7 @@ NodePtr n = getPreviousSibling(m_currentNode); if (n) { - // Find the last kid in the tree's preorder traversal, if any, + // Find the last kid in the subtree's preorder traversal, if any, // by following the lastChild links. NodePtr desc = getLastChild(n); while (desc) { @@ -455,7 +455,7 @@ return n; } - return getParentNode(n); + return getParentNode(m_currentNode); } TreeWalkerImpl::NodePtr TreeWalkerImpl::getNextNode() @@ -508,15 +508,20 @@ TreeWalkerImpl::NodePtr TreeWalkerImpl::getParentNode(TreeWalkerImpl::NodePtr n) { - NodePtr cursor = n; + // Already on top of root's subtree tree... + if (n == m_rootNode) + return 0; // Walk up, to find the first visible node != n, until we run out of // document or into the root (which we don't have to be inside of!) - while (cursor && cursor != m_rootNode) { - if (cursor != n && isAccepted(cursor) == NodeFilter::FILTER_ACCEPT) + NodePtr cursor = n->parentNode(); + while (cursor) { + if (isAccepted(cursor) == NodeFilter::FILTER_ACCEPT) return cursor; - else - cursor = cursor->parentNode(); + + if (cursor == m_rootNode) // We just checked root -- no where else to go up. + return 0; + cursor = cursor->parentNode(); } return 0;