Bug 16758 - ASSERT when using TreeWalker methods for a current node outside of the root (Acid3)
Summary: ASSERT when using TreeWalker methods for a current node outside of the root (...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-05 16:48 PST by Sam Weinig
Modified: 2008-01-08 23:11 PST (History)
0 users

See Also:


Attachments
patch (8.61 KB, patch)
2008-01-05 16:50 PST, Sam Weinig
darin: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2008-01-05 16:48:05 PST
Running the Acid3 test in debug builds reveals an assertion failure:

ASSERTION FAILED: !stayWithin || !n->nextSibling() || n->nextSibling()->isDescendantOf(stayWithin)
(/Users/weinig/Code/webkit/OpenSource/WebCore/dom/Node.cpp:490 WebCore::Node* WebCore::Node::traverseNextNode(const WebCore::Node*) const)

This stems from the TreeWalker class being able to set the currentNode to an arbitrary node but not checking that is within it's root node when using the traverseNextNode/traversePreviousNode functions.
Comment 1 Sam Weinig 2008-01-05 16:50:58 PST
Created attachment 18291 [details]
patch
Comment 2 Eric Seidel (no email) 2008-01-05 17:07:42 PST
Comment on attachment 18291 [details]
patch

Looks great!
Comment 3 Sam Weinig 2008-01-05 18:38:00 PST
Landed in r29203.
Comment 4 Darin Adler 2008-01-08 22:21:29 PST
Comment on attachment 18291 [details]
patch

This is wrong.

If you read the TreeWalker documentation, you'll see that it has well defined behavior when used on nodes outside the original subtree. The code correctly implemented most of those rules before -- this patch broke it!

I have a patch that fixes it. The test case expects behavior that is incorrect, so I need to change it around.
Comment 5 Darin Adler 2008-01-08 22:32:10 PST
Here is the relevant quote from the specification:

"All the TreeWalker's navigation methods operate in terms of the context of the currentNode at the time they are invoked, no matter what has happened to, or around, that node since the last time the TreeWalker was accessed. This remains true even if the currentNode is moved out of its original subtree."

And:

"If we instead insert the currentNode into the <subtree/> element, like so: [...] we have moved the currentNode out from under the TreeWalker's root node. This does not invalidate the TreeWalker; it may still be used to navigate relative to the currentNode."

The real fix here would be to remove the assertions, and I have done this in my new patch.
Comment 6 Darin Adler 2008-01-08 22:52:55 PST
The patch in bug 3492 addresses this.
Comment 7 Sam Weinig 2008-01-08 23:11:52 PST
I realized after landing that this was not correct (but only now thought that the right corse of action would have been to roll it out).  A fix I made is in bug 16759, but is probably not necessary with Darin's patch.