Commit 78c63e4e authored by esprehn@chromium.org's avatar esprehn@chromium.org

Merge appendChildToContainer into ContainerNode

We don't need the templates in ContainerNodeAlgorithms now,
lets start merging them into ContainerNode.

Review URL: https://codereview.chromium.org/329703002

git-svn-id: svn://svn.chromium.org/blink/trunk@175968 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5e792fff
......@@ -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);
}
......
......@@ -168,9 +168,6 @@ public:
protected:
ContainerNode(TreeScope*, ConstructionType = CreateContainer);
template<class GenericNode, class GenericNodeContainer>
friend void appendChildToContainer(GenericNode& child, GenericNodeContainer&);
template<class GenericNode, class GenericNodeContainer>
friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer&);
......@@ -184,6 +181,7 @@ protected:
private:
void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild);
void insertBeforeCommon(Node& nextChild, Node& oldChild);
void appendChildCommon(Node& child);
void updateTreeAfterInsertion(Node& child);
void willRemoveChildren();
void willRemoveChild(Node& child);
......
......@@ -66,22 +66,6 @@ inline void removeDetachedChildrenInContainer(GenericNodeContainer& container)
}
#endif
template<class GenericNode, class GenericNodeContainer>
inline void appendChildToContainer(GenericNode& child, GenericNodeContainer& container)
{
child.setParentOrShadowHostNode(&container);
GenericNode* lastChild = container.lastChild();
if (lastChild) {
child.setPreviousSibling(lastChild);
lastChild->setNextSibling(&child);
} else {
container.setFirstChild(&child);
}
container.setLastChild(&child);
}
// Helper methods for removeDetachedChildrenInContainer, hidden from WebCore namespace
namespace Private {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment