Index: Source/core/editing/RemoveNodePreservingChildrenCommand.cpp |
diff --git a/Source/core/editing/RemoveNodePreservingChildrenCommand.cpp b/Source/core/editing/RemoveNodePreservingChildrenCommand.cpp |
index 11ef29aa7a0fc09f50a3e551099080ba23b1514a..9dc580a331fd604c7165bdefea3cc64af30a696d 100644 |
--- a/Source/core/editing/RemoveNodePreservingChildrenCommand.cpp |
+++ b/Source/core/editing/RemoveNodePreservingChildrenCommand.cpp |
@@ -41,15 +41,16 @@ RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(PassRef |
void RemoveNodePreservingChildrenCommand::doApply() |
{ |
- WillBeHeapVector<RefPtrWillBeMember<Node> > children; |
- for (Node* child = m_node->firstChild(); child; child = child->nextSibling()) |
- children.append(child); |
- |
- size_t size = children.size(); |
- for (size_t i = 0; i < size; ++i) { |
- RefPtrWillBeRawPtr<Node> child = children[i].release(); |
- removeNode(child, m_shouldAssumeContentIsAlwaysEditable); |
- insertNodeBefore(child.release(), m_node, m_shouldAssumeContentIsAlwaysEditable); |
+ if (m_node->isContainerNode()) { |
+ NodeVector children; |
+ getChildNodes(toContainerNode(*m_node), children); |
+ |
+ size_t size = children.size(); |
+ for (size_t i = 0; i < size; ++i) { |
+ RefPtrWillBeRawPtr<Node> child = children[i].release(); |
+ removeNode(child, m_shouldAssumeContentIsAlwaysEditable); |
+ insertNodeBefore(child.release(), m_node, m_shouldAssumeContentIsAlwaysEditable); |
+ } |
} |
removeNode(m_node, m_shouldAssumeContentIsAlwaysEditable); |
} |