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

Unified Diff: Source/core/dom/ContainerNode.cpp

Issue 375293002: Node.insertBefore and Node.appendChild do not use custom binding anymore (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Take review comment into consideration 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/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 71aaabaefc7a916f48eb9d6fcbe36fbf272feeab..93a9ab6d91fc2668c2fab9b46bbf6772dd41312e 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -177,7 +177,7 @@ bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, Ex
return true;
}
-void ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* refChild, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<Node> ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* refChild, ExceptionState& exceptionState)
{
#if !ENABLE(OILPAN)
// Check that this node is not "floating".
@@ -189,36 +189,36 @@ void ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* re
// insertBefore(node, 0) is equivalent to appendChild(node)
if (!refChild) {
- appendChild(newChild, exceptionState);
- return;
+ return appendChild(newChild, exceptionState);
}
// Make sure adding the new child is OK.
if (!checkAcceptChild(newChild.get(), 0, exceptionState))
- return;
+ return nullptr;
haraken 2014/07/11 02:18:23 Shall we add ASSERT(exceptionState.hadException())
kangil_ 2014/07/11 02:39:42 Done.
ASSERT(newChild);
// NotFoundError: Raised if refChild is not a child of this node
if (refChild->parentNode() != this) {
exceptionState.throwDOMException(NotFoundError, "The node before which the new node is to be inserted is not a child of this node.");
- return;
+ return nullptr;
}
- if (refChild->previousSibling() == newChild || refChild == newChild) // nothing to do
- return;
+ // nothing to do
+ if (refChild->previousSibling() == newChild || refChild == newChild)
+ return newChild;
RefPtrWillBeRawPtr<Node> next = refChild;
NodeVector targets;
collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState);
if (exceptionState.hadException())
- return;
+ return nullptr;
if (targets.isEmpty())
- return;
+ return newChild;
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState))
- return;
+ return nullptr;
haraken 2014/07/11 02:18:23 Add ASSERT(exceptionState.hadException()).
kangil_ 2014/07/11 02:39:42 Done.
InspectorInstrumentation::willInsertDOMNode(this);
@@ -244,6 +244,8 @@ void ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* re
}
dispatchSubtreeModifiedEvent();
+
+ return newChild;
}
void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
@@ -592,7 +594,7 @@ void ContainerNode::removeChildren()
dispatchSubtreeModifiedEvent();
}
-void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<Node> ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, ExceptionState& exceptionState)
{
RefPtrWillBeRawPtr<ContainerNode> protect(this);
@@ -604,23 +606,23 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception
// Make sure adding the new child is ok
if (!checkAcceptChild(newChild.get(), 0, exceptionState))
- return;
+ return nullptr;
haraken 2014/07/11 02:18:23 Add ASSERT(exceptionState.hadException()).
kangil_ 2014/07/11 02:39:42 Done.
ASSERT(newChild);
if (newChild == m_lastChild) // nothing to do
- return;
+ return newChild;
NodeVector targets;
collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState);
if (exceptionState.hadException())
- return;
+ return nullptr;
if (targets.isEmpty())
- return;
+ return newChild;
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState))
- return;
+ return nullptr;
haraken 2014/07/11 02:18:23 Add ASSERT(exceptionState.hadException()).
kangil_ 2014/07/11 02:39:42 Done.
InspectorInstrumentation::willInsertDOMNode(this);
@@ -648,6 +650,7 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception
}
dispatchSubtreeModifiedEvent();
+ return newChild;
}
void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)

Powered by Google App Engine
This is Rietveld 408576698