+2012-04-11 Stephen Chenney <schenney@chromium.org>
+
+ Shadow tree TreeScope data is not removed by ContainerNode::removeAllChildren
+ https://bugs.webkit.org/show_bug.cgi?id=83484
+
+ Reviewed by Hajime Morita.
+
+ The ContainerNode::removeAllChildren method does fast and dirty node removal.
+ As compared to ContainerNode::removeChildren, it does not include the
+ method to adopt the removed child node into the root document's TreeScope.
+ Rather, it leaves the existing TreeScope in place. However, the existing
+ TreeScope may be removed, causing a crash when something prevents the child
+ node from being deleted immediately. The fix is to modify the code in
+ ContainerNodeAlgorithms to do the TreeScope adoption.
+
+ Could not reproduce crash in layout test.
+
+ * dom/ContainerNodeAlgorithms.h:
+ (Private):
+ (WebCore::Private::NodeRemovalDispatcher::dispatch):
+ (WebCore::Private::addChildNodesToDeletionQueue):
+
2012-04-11 Yury Semikhatsky <yurys@chromium.org>
Web Inspector: showing summary view is very slow on a snapshot with thousands of constructors
// Helper methods for removeAllChildrenInContainer, hidden from WebCore namespace
namespace Private {
- template<class GenericNode, bool dispatchRemovalNotification>
+ template<class GenericNode, class GenericNodeContainer, bool dispatchRemovalNotification>
struct NodeRemovalDispatcher {
- static void dispatch(GenericNode*)
+ static void dispatch(GenericNode*, GenericNodeContainer*)
{
// no-op, by default
}
};
- template<class GenericNode>
- struct NodeRemovalDispatcher<GenericNode, true> {
- static void dispatch(GenericNode* node)
+ template<class GenericNode, class GenericNodeContainer>
+ struct NodeRemovalDispatcher<GenericNode, GenericNodeContainer, true> {
+ static void dispatch(GenericNode* node, GenericNodeContainer* container)
{
+ // Clean up any TreeScope to a removed tree.
+ if (Document* containerDocument = container->ownerDocument())
+ containerDocument->adoptIfNeeded(node);
if (node->inDocument())
node->removedFromDocument();
}
tail = n;
} else {
RefPtr<GenericNode> protect(n); // removedFromDocument may remove remove all references to this node.
- NodeRemovalDispatcher<GenericNode, ShouldDispatchRemovalNotification<GenericNode>::value>::dispatch(n);
+ NodeRemovalDispatcher<GenericNode, GenericNodeContainer, ShouldDispatchRemovalNotification<GenericNode>::value>::dispatch(n, container);
}
}