Index: Source/core/dom/ContainerNode.cpp |
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp |
index fed648dbb0002f7a4a4f906e439df3f33500c162..837a135f602df0890efc15cd5b3961e536ee53b3 100644 |
--- a/Source/core/dom/ContainerNode.cpp |
+++ b/Source/core/dom/ContainerNode.cpp |
@@ -271,6 +271,20 @@ void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) |
newChild.setNextSibling(&nextChild); |
} |
+void ContainerNode::appendChildCommon(Node& child) |
+{ |
+ child.setParentOrShadowHostNode(this); |
+ |
+ if (m_lastChild) { |
+ child.setPreviousSibling(m_lastChild); |
+ m_lastChild->setNextSibling(&child); |
+ } else { |
+ setFirstChild(&child); |
+ } |
+ |
+ setLastChild(&child); |
+} |
+ |
void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node& nextChild) |
{ |
ASSERT(newChild); |
@@ -374,7 +388,7 @@ void ContainerNode::replaceChild(PassRefPtrWillBeRawPtr<Node> newChild, Node* ol |
if (next) |
insertBeforeCommon(*next, child); |
else |
- appendChildToContainer(child, *this); |
+ appendChildCommon(child); |
} |
updateTreeAfterInsertion(child); |
@@ -622,7 +636,7 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception |
ScriptForbiddenScope forbidScript; |
treeScope().adoptIfNeeded(child); |
- appendChildToContainer(child, *this); |
+ appendChildCommon(child); |
} |
updateTreeAfterInsertion(child); |
@@ -648,8 +662,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) |
ScriptForbiddenScope forbidScript; |
treeScope().adoptIfNeeded(*newChild); |
- // FIXME: This method should take a PassRefPtr. |
- appendChildToContainer(*newChild, *this); |
+ appendChildCommon(*newChild); |
newChild->updateAncestorConnectedSubframeCountForInsertion(); |
ChildListMutationScope(*this).childAdded(*newChild); |
} |