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) ...@@ -271,6 +271,20 @@ void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
newChild.setNextSibling(&nextChild); 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) void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node& nextChild)
{ {
ASSERT(newChild); ASSERT(newChild);
...@@ -374,7 +388,7 @@ void ContainerNode::replaceChild(PassRefPtrWillBeRawPtr<Node> newChild, Node* ol ...@@ -374,7 +388,7 @@ void ContainerNode::replaceChild(PassRefPtrWillBeRawPtr<Node> newChild, Node* ol
if (next) if (next)
insertBeforeCommon(*next, child); insertBeforeCommon(*next, child);
else else
appendChildToContainer(child, *this); appendChildCommon(child);
} }
updateTreeAfterInsertion(child); updateTreeAfterInsertion(child);
...@@ -622,7 +636,7 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception ...@@ -622,7 +636,7 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception
ScriptForbiddenScope forbidScript; ScriptForbiddenScope forbidScript;
treeScope().adoptIfNeeded(child); treeScope().adoptIfNeeded(child);
appendChildToContainer(child, *this); appendChildCommon(child);
} }
updateTreeAfterInsertion(child); updateTreeAfterInsertion(child);
...@@ -648,8 +662,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) ...@@ -648,8 +662,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
ScriptForbiddenScope forbidScript; ScriptForbiddenScope forbidScript;
treeScope().adoptIfNeeded(*newChild); treeScope().adoptIfNeeded(*newChild);
// FIXME: This method should take a PassRefPtr. appendChildCommon(*newChild);
appendChildToContainer(*newChild, *this);
newChild->updateAncestorConnectedSubframeCountForInsertion(); newChild->updateAncestorConnectedSubframeCountForInsertion();
ChildListMutationScope(*this).childAdded(*newChild); ChildListMutationScope(*this).childAdded(*newChild);
} }
......
...@@ -168,9 +168,6 @@ public: ...@@ -168,9 +168,6 @@ public:
protected: protected:
ContainerNode(TreeScope*, ConstructionType = CreateContainer); ContainerNode(TreeScope*, ConstructionType = CreateContainer);
template<class GenericNode, class GenericNodeContainer>
friend void appendChildToContainer(GenericNode& child, GenericNodeContainer&);
template<class GenericNode, class GenericNodeContainer> template<class GenericNode, class GenericNodeContainer>
friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer&); friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer&);
...@@ -184,6 +181,7 @@ protected: ...@@ -184,6 +181,7 @@ protected:
private: private:
void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild); void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild);
void insertBeforeCommon(Node& nextChild, Node& oldChild); void insertBeforeCommon(Node& nextChild, Node& oldChild);
void appendChildCommon(Node& child);
void updateTreeAfterInsertion(Node& child); void updateTreeAfterInsertion(Node& child);
void willRemoveChildren(); void willRemoveChildren();
void willRemoveChild(Node& child); void willRemoveChild(Node& child);
......
...@@ -66,22 +66,6 @@ inline void removeDetachedChildrenInContainer(GenericNodeContainer& container) ...@@ -66,22 +66,6 @@ inline void removeDetachedChildrenInContainer(GenericNodeContainer& container)
} }
#endif #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 // Helper methods for removeDetachedChildrenInContainer, hidden from WebCore namespace
namespace Private { 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