void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent) { NodeVector children; getChildNodes(oldParent, children); if (oldParent->document()->hasMutationObserversOfType(MutationObserver::ChildList)) { ChildListMutationScope mutation(oldParent); for (unsigned i = 0; i < children.size(); ++i) mutation.willRemoveChild(children[i].get()); } // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each child, // probably inside removeDetachedChildrenInContainer. oldParent->removeDetachedChildren(); for (unsigned i = 0; i < children.size(); ++i) { if (children[i]->attached()) children[i]->detach(); // FIXME: We need a no mutation event version of adoptNode. RefPtr<Node> child = document()->adoptNode(children[i].release(), ASSERT_NO_EXCEPTION); parserAppendChild(child.get()); // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree). // Can we do better? treeScope()->adoptIfNeeded(child.get()); if (attached() && !child->attached()) child->attach(); } }
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent) { NodeVector children; getChildNodes(oldParent, children); oldParent->removeAllChildren(); for (unsigned i = 0; i < children.size(); ++i) { ExceptionCode ec = 0; if (children[i]->attached()) children[i]->detach(); // FIXME: We need a no mutation event version of adoptNode. RefPtr<Node> child = document()->adoptNode(children[i].release(), ec); ASSERT(!ec); parserAppendChild(child.get()); // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree). // Can we do better? treeScope()->adoptIfNeeded(child.get()); if (attached() && !child->attached()) child->attach(); } }