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

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: Replace assert with condition 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
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 71aaabaefc7a916f48eb9d6fcbe36fbf272feeab..8485a7e87181a6553a6606b429c563c83ef81ac9 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,42 @@ 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;
+ if (!checkAcceptChild(newChild.get(), 0, exceptionState)) {
+ if (exceptionState.hadException())
+ return nullptr;
+ return newChild;
+ }
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;
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) {
+ if (exceptionState.hadException())
+ return nullptr;
+ return newChild;
+ }
InspectorInstrumentation::willInsertDOMNode(this);
@@ -244,6 +250,8 @@ void ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* re
}
dispatchSubtreeModifiedEvent();
+
+ return newChild;
}
void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
@@ -592,7 +600,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);
@@ -603,24 +611,30 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception
#endif
// Make sure adding the new child is ok
- if (!checkAcceptChild(newChild.get(), 0, exceptionState))
- return;
+ if (!checkAcceptChild(newChild.get(), 0, exceptionState)) {
+ if (exceptionState.hadException())
+ return nullptr;
+ return newChild;
+ }
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;
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) {
+ if (exceptionState.hadException())
+ return nullptr;
+ return newChild;
+ }
InspectorInstrumentation::willInsertDOMNode(this);
@@ -648,6 +662,7 @@ void ContainerNode::appendChild(PassRefPtrWillBeRawPtr<Node> newChild, Exception
}
dispatchSubtreeModifiedEvent();
+ return newChild;
}
void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698