Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Unified Diff: Source/core/editing/RemoveNodePreservingChildrenCommand.cpp

Issue 435733002: Have getChildNodes() take a ContainerNode in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698