-
abucur@adobe.com authored
https://bugs.webkit.org/show_bug.cgi?id=113517 Reviewed by Darin Adler. The patch is based on the work made by Elliott Sprehn. He kindly agreed for me to finalize the last bits and pieces of the fix. Source/WebCore: Simplify ContainerNode::removeChildren by merging the loops and removing willRemoveChildren. This removes two traversals of the children, avoids refing and derefing all the children once, avoids allocating a second NodeVector of children, and means we detach() in the same order as normal removal. This does mean you can get into an infinite loop with DOMNodeRemoved listeners by continously adding nodes but this is true in all other browsers and the current behavior is bad because it means you don't get notified of nodes added during removal (which other browsers do notify of). This patch removes the containerNode.html test that originally tested for this infinite loop and adds a new one that tests that all nodes get notified. This makes PerformanceTests/Parser/innerHTML-setter.html 2-6% faster. There's also a new test verifying ranges remain consistent if modified inside an mutation event handler. Without the patch it's possible to create a range with boundaries outside of the DOM tree. Tests: fast/dom/Range/range-remove-children-event.html fast/events/mutation-during-innerHTML.html * dom/ContainerNode.cpp: (WebCore::ContainerNode::removeChildren): * dom/Document.cpp: * dom/Document.h: nodeChildrenWillBeRemoved is not needed any more. * dom/Range.cpp: * dom/Range.h: nodeChildrenWillBeRemoved is not needed any more. LayoutTests: Remove containerNode.html test since it was checking for an infinite loop when adding DOM nodes inside a DOMNodeRemoved mutation event handler, but we actually do want to allow an infinite loop here for correctness and compatability with other browsers. Also added mutation-during-innerHTML which checks that all nodes are notified of being removed even if they were added during the DOMNodeRemoved notification. There's a new test range-remove-children-event that verifies the ranges modified inside a mutation event handler remain consistent. * fast/dom/MutationObserver/added-out-of-order-expected.txt: * fast/dom/MutationObserver/added-out-of-order.html: * fast/dom/Range/range-remove-children-event-expected.txt: Added. * fast/dom/Range/range-remove-children-event.html: Added. * fast/dom/containerNode-expected.txt: Removed. * fast/dom/containerNode.html: Removed. * fast/events/mutation-during-innerHTML-expected.txt: Added. * fast/events/mutation-during-innerHTML.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147942 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24c25908