Chromium Code Reviews| 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) |