Index: Source/core/dom/ContainerNode.cpp |
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp |
index 832ccfe22fc22fa0a0252d7787e48ffea9f97dc3..3f8352caf484ba4a2bb78a953217ae763edbfda4 100644 |
--- a/Source/core/dom/ContainerNode.cpp |
+++ b/Source/core/dom/ContainerNode.cpp |
@@ -23,7 +23,6 @@ |
#include "config.h" |
#include "core/dom/ContainerNode.h" |
-#include "bindings/v8/ExceptionMessages.h" |
#include "bindings/v8/ExceptionState.h" |
#include "core/dom/ChildListMutationScope.h" |
#include "core/dom/ContainerNodeAlgorithms.h" |
@@ -56,10 +55,6 @@ ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot = 0; |
unsigned NoEventDispatchAssertion::s_count = 0; |
#endif |
-static const char appendChildMethodName[] = "appendChild"; |
-static const char insertBeforeMethodName[] = "insertBefore"; |
-static const char replaceChildMethodName[] = "replaceChild"; |
- |
static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionState& exceptionState) |
{ |
if (!node.isDocumentFragment()) { |
@@ -116,11 +111,11 @@ bool ContainerNode::containsConsideringHostElements(const Node& newChild) const |
return newChild.contains(this); |
} |
-bool ContainerNode::checkAcceptChild(const Node* newChild, const Node* oldChild, const char* method, ExceptionState& exceptionState) const |
+bool ContainerNode::checkAcceptChild(const Node* newChild, const Node* oldChild, ExceptionState& exceptionState) const |
{ |
// Not mentioned in spec: throw NotFoundError if newChild is null |
if (!newChild) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(method, "Node", "The new child element is null.")); |
+ exceptionState.throwDOMException(NotFoundError, "The new child element is null."); |
return false; |
} |
@@ -128,7 +123,7 @@ bool ContainerNode::checkAcceptChild(const Node* newChild, const Node* oldChild, |
if ((newChild->isElementNode() || newChild->isTextNode()) && isElementNode()) { |
ASSERT(isChildTypeAllowed(*newChild)); |
if (containsConsideringHostElements(*newChild)) { |
- exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent.")); |
+ exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent."); |
return false; |
} |
return true; |
@@ -137,34 +132,34 @@ bool ContainerNode::checkAcceptChild(const Node* newChild, const Node* oldChild, |
// This should never happen, but also protect release builds from tree corruption. |
ASSERT(!newChild->isPseudoElement()); |
if (newChild->isPseudoElement()) { |
- exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element is a pseudo-element.")); |
+ exceptionState.throwDOMException(HierarchyRequestError, "The new child element is a pseudo-element."); |
return false; |
} |
if (containsConsideringHostElements(*newChild)) { |
- exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent.")); |
+ exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent."); |
return false; |
} |
if (oldChild && isDocumentNode()) { |
if (!toDocument(this)->canReplaceChild(*newChild, *oldChild)) { |
// FIXME: Adjust 'Document::canReplaceChild' to return some additional detail (or an error message). |
- exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "ContainerNode")); |
+ exceptionState.throwDOMException(HierarchyRequestError, "Failed to replace child."); |
return false; |
} |
} else if (!isChildTypeAllowed(*newChild)) { |
- exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "Nodes of type '" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + nodeName() + "'.")); |
+ exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + nodeName() + "'."); |
return false; |
} |
return true; |
} |
-bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, const char* method, ExceptionState& exceptionState) const |
+bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, ExceptionState& exceptionState) const |
{ |
ASSERT(isChildTypeAllowed(newChild)); |
if (newChild.contains(this)) { |
- exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent.")); |
+ exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent."); |
return false; |
} |
return true; |
@@ -185,13 +180,13 @@ void ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce |
} |
// Make sure adding the new child is OK. |
- if (!checkAcceptChild(newChild.get(), 0, insertBeforeMethodName, exceptionState)) |
+ if (!checkAcceptChild(newChild.get(), 0, exceptionState)) |
return; |
ASSERT(newChild); |
// NotFoundError: Raised if refChild is not a child of this node |
if (refChild->parentNode() != this) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(insertBeforeMethodName, "Node", "The node before which the new node is to be inserted is not a child of this node.")); |
+ exceptionState.throwDOMException(NotFoundError, "The node before which the new node is to be inserted is not a child of this node."); |
return; |
} |
@@ -208,7 +203,7 @@ void ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce |
return; |
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events. |
- if (!checkAcceptChildGuaranteedNodeTypes(*newChild, insertBeforeMethodName, exceptionState)) |
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) |
return; |
InspectorInstrumentation::willInsertDOMNode(this); |
@@ -298,17 +293,17 @@ void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce |
return; |
if (!oldChild) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(replaceChildMethodName, "Node", "The node to be replaced is null.")); |
+ exceptionState.throwDOMException(NotFoundError, "The node to be replaced is null."); |
return; |
} |
// Make sure replacing the old child with the new is ok |
- if (!checkAcceptChild(newChild.get(), oldChild, replaceChildMethodName, exceptionState)) |
+ if (!checkAcceptChild(newChild.get(), oldChild, exceptionState)) |
return; |
// NotFoundError: Raised if oldChild is not a child of this node. |
if (oldChild->parentNode() != this) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(replaceChildMethodName, "Node", "The node to be replaced is not a child of this node.")); |
+ exceptionState.throwDOMException(NotFoundError, "The node to be replaced is not a child of this node."); |
return; |
} |
@@ -326,7 +321,7 @@ void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce |
return; |
// Does this one more time because removeChild() fires a MutationEvent. |
- if (!checkAcceptChild(newChild.get(), oldChild, replaceChildMethodName, exceptionState)) |
+ if (!checkAcceptChild(newChild.get(), oldChild, exceptionState)) |
return; |
NodeVector targets; |
@@ -335,7 +330,7 @@ void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce |
return; |
// Does this yet another check because collectChildrenAndRemoveFromOldParent() fires a MutationEvent. |
- if (!checkAcceptChild(newChild.get(), oldChild, replaceChildMethodName, exceptionState)) |
+ if (!checkAcceptChild(newChild.get(), oldChild, exceptionState)) |
return; |
InspectorInstrumentation::willInsertDOMNode(this); |
@@ -413,7 +408,7 @@ void ContainerNode::removeChild(Node* oldChild, ExceptionState& exceptionState) |
// NotFoundError: Raised if oldChild is not a child of this node. |
if (!oldChild || oldChild->parentNode() != this) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute("removeChild", "Node", "The node to be removed is not a child of this node.")); |
+ exceptionState.throwDOMException(NotFoundError, "The node to be removed is not a child of this node."); |
return; |
} |
@@ -427,7 +422,7 @@ void ContainerNode::removeChild(Node* oldChild, ExceptionState& exceptionState) |
// Events fired when blurring currently focused node might have moved this |
// child into a different parent. |
if (child->parentNode() != this) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute("removeChild", "Node", "The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?")); |
+ exceptionState.throwDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?"); |
return; |
} |
@@ -435,7 +430,7 @@ void ContainerNode::removeChild(Node* oldChild, ExceptionState& exceptionState) |
// Mutation events might have moved this child into a different parent. |
if (child->parentNode() != this) { |
- exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute("removeChild", "Node", "The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutation?")); |
+ exceptionState.throwDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutation?"); |
return; |
} |
@@ -558,7 +553,7 @@ void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& excep |
ASSERT(refCount() || parentOrShadowHostNode()); |
// Make sure adding the new child is ok |
- if (!checkAcceptChild(newChild.get(), 0, appendChildMethodName, exceptionState)) |
+ if (!checkAcceptChild(newChild.get(), 0, exceptionState)) |
return; |
ASSERT(newChild); |
@@ -574,7 +569,7 @@ void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& excep |
return; |
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events. |
- if (!checkAcceptChildGuaranteedNodeTypes(*newChild, appendChildMethodName, exceptionState)) |
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) |
return; |
InspectorInstrumentation::willInsertDOMNode(this); |