Bug 76146 - NodeIterator loses track of the reference node when the reference node is removed from the document (IETC ni_removeReferenceNode)
Summary: NodeIterator loses track of the reference node when the reference node is rem...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks: 76198
  Show dependency treegraph
 
Reported: 2012-01-11 21:33 PST by Adam Barth
Modified: 2012-01-12 15:18 PST (History)
4 users (show)

See Also:


Attachments
Patch (5.85 KB, patch)
2012-01-11 21:38 PST, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2012-01-11 21:33:26 PST
NodeIterator loses track of the reference node when the reference node is removed from the document (IETC ni_removeReferenceNode)
Comment 1 Adam Barth 2012-01-11 21:38:49 PST
Created attachment 122167 [details]
Patch
Comment 2 Ryosuke Niwa 2012-01-11 22:20:26 PST
Comment on attachment 122167 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=122167&action=review

> Source/WebCore/dom/NodeIterator.cpp:185
> +            while (node && node->isDescendantOf(removedNode))
> +                node = node->traverseNextNode(root());

This is every inefficient way to find the next node. If node is a descendant of the removed node, then the next node should be removedNode->traverseNextSibling(), no?
Comment 3 Adam Barth 2012-01-11 23:02:26 PST
@darin: I've been told that you're the expert on this code.  This function is pretty subtle.  If you have a few minutes to sanity-check this patch, that would be great.  Thanks!
Comment 4 Darin Adler 2012-01-12 11:11:36 PST
Comment on attachment 122167 [details]
Patch

I did fix quite a few bugs in this code a while back. The change in the code looks fine. I think to improve performance and correctness we’d want to add performance and correctness tests. This little-used barely-useful obscure corner of the DOM does not get a lot of attention or love.
Comment 5 Adam Barth 2012-01-12 12:17:27 PST
It looks like DOM4 has a reasonably simple specification of what to do when nodes are removed:

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-nodeiterator

I wonder if we can re-work our implementation to match the spec more closely.
Comment 6 Adam Barth 2012-01-12 14:05:20 PST
Comment on attachment 122167 [details]
Patch

I'm going to work on refactoring and adding more tests for NodeIterator in future bug.
Comment 7 WebKit Review Bot 2012-01-12 15:18:51 PST
Comment on attachment 122167 [details]
Patch

Clearing flags on attachment: 122167

Committed r104866: <http://trac.webkit.org/changeset/104866>
Comment 8 WebKit Review Bot 2012-01-12 15:18:56 PST
All reviewed patches have been landed.  Closing bug.