| Index: Source/core/dom/ContainerNode.cpp
|
| diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
|
| index bf1243cef510bff9d0593e5d887dec47e0e2b566..3ffda6f4eae05942354707693c7c51d4d7a23878 100644
|
| --- a/Source/core/dom/ContainerNode.cpp
|
| +++ b/Source/core/dom/ContainerNode.cpp
|
| @@ -63,12 +63,12 @@ static const char appendChildMethodName[] = "appendChild";
|
| static const char insertBeforeMethodName[] = "insertBefore";
|
| static const char replaceChildMethodName[] = "replaceChild";
|
|
|
| -static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionState& es)
|
| +static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionState& exceptionState)
|
| {
|
| if (!node.isDocumentFragment()) {
|
| nodes.append(&node);
|
| if (ContainerNode* oldParent = node.parentNode())
|
| - oldParent->removeChild(&node, es);
|
| + oldParent->removeChild(&node, exceptionState);
|
| return;
|
| }
|
| getChildNodes(node, nodes);
|
| @@ -125,11 +125,11 @@ static inline bool containsConsideringHostElements(const Node& newChild, const N
|
| : newChild.contains(&newParent);
|
| }
|
|
|
| -static inline bool checkAcceptChild(ContainerNode& newParent, Node* newChild, Node* oldChild, const char* method, ExceptionState& es)
|
| +static inline bool checkAcceptChild(ContainerNode& newParent, Node* newChild, Node* oldChild, const char* method, ExceptionState& exceptionState)
|
| {
|
| // Not mentioned in spec: throw NotFoundError if newChild is null
|
| if (!newChild) {
|
| - es.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(method, "Node", "The new child element is null."));
|
| + exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(method, "Node", "The new child element is null."));
|
| return false;
|
| }
|
|
|
| @@ -138,7 +138,7 @@ static inline bool checkAcceptChild(ContainerNode& newParent, Node* newChild, No
|
| ASSERT(!newParent.isDocumentTypeNode());
|
| ASSERT(isChildTypeAllowed(newParent, *newChild));
|
| if (containsConsideringHostElements(*newChild, newParent)) {
|
| - es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent."));
|
| + exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent."));
|
| return false;
|
| }
|
| return true;
|
| @@ -147,52 +147,52 @@ static inline bool checkAcceptChild(ContainerNode& newParent, Node* newChild, No
|
| // This should never happen, but also protect release builds from tree corruption.
|
| ASSERT(!newChild->isPseudoElement());
|
| if (newChild->isPseudoElement()) {
|
| - es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element is a pseudo-element."));
|
| + exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element is a pseudo-element."));
|
| return false;
|
| }
|
|
|
| if (containsConsideringHostElements(*newChild, newParent)) {
|
| - es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent."));
|
| + exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent."));
|
| return false;
|
| }
|
|
|
| if (oldChild && newParent.isDocumentNode()) {
|
| if (!toDocument(newParent).canReplaceChild(*newChild, *oldChild)) {
|
| // FIXME: Adjust 'Document::canReplaceChild' to return some additional detail (or an error message).
|
| - es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "ContainerNode"));
|
| + exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "ContainerNode"));
|
| return false;
|
| }
|
| } else if (!isChildTypeAllowed(newParent, *newChild)) {
|
| - es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "Nodes of type '" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + newParent.nodeName() + "'."));
|
| + exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "Nodes of type '" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + newParent.nodeName() + "'."));
|
| return false;
|
| }
|
|
|
| return true;
|
| }
|
|
|
| -static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode& newParent, Node& newChild, const char* method, ExceptionState& es)
|
| +static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode& newParent, Node& newChild, const char* method, ExceptionState& exceptionState)
|
| {
|
| ASSERT(!newParent.isDocumentTypeNode());
|
| ASSERT(isChildTypeAllowed(newParent, newChild));
|
| if (newChild.contains(&newParent)) {
|
| - es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent."));
|
| + exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToExecute(method, "Node", "The new child element contains the parent."));
|
| return false;
|
| }
|
|
|
| return true;
|
| }
|
|
|
| -static inline bool checkAddChild(ContainerNode& newParent, Node* newChild, const char* method, ExceptionState& es)
|
| +static inline bool checkAddChild(ContainerNode& newParent, Node* newChild, const char* method, ExceptionState& exceptionState)
|
| {
|
| - return checkAcceptChild(newParent, newChild, 0, method, es);
|
| + return checkAcceptChild(newParent, newChild, 0, method, exceptionState);
|
| }
|
|
|
| -static inline bool checkReplaceChild(ContainerNode& newParent, Node* newChild, Node& oldChild, const char* method, ExceptionState& es)
|
| +static inline bool checkReplaceChild(ContainerNode& newParent, Node* newChild, Node& oldChild, const char* method, ExceptionState& exceptionState)
|
| {
|
| - return checkAcceptChild(newParent, newChild, &oldChild, method, es);
|
| + return checkAcceptChild(newParent, newChild, &oldChild, method, exceptionState);
|
| }
|
|
|
| -void ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionState& es)
|
| +void ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionState& exceptionState)
|
| {
|
| // Check that this node is not "floating".
|
| // If it is, it can be deleted as a side effect of sending mutation events.
|
| @@ -202,18 +202,18 @@ void ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
|
|
|
| // insertBefore(node, 0) is equivalent to appendChild(node)
|
| if (!refChild) {
|
| - appendChild(newChild, es);
|
| + appendChild(newChild, exceptionState);
|
| return;
|
| }
|
|
|
| // Make sure adding the new child is OK.
|
| - if (!checkAddChild(*this, newChild.get(), insertBeforeMethodName, es))
|
| + if (!checkAddChild(*this, newChild.get(), insertBeforeMethodName, exceptionState))
|
| return;
|
| ASSERT(newChild);
|
|
|
| // NotFoundError: Raised if refChild is not a child of this node
|
| if (refChild->parentNode() != this) {
|
| - es.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, ExceptionMessages::failedToExecute(insertBeforeMethodName, "Node", "The node before which the new node is to be inserted is not a child of this node."));
|
| return;
|
| }
|
|
|
| @@ -223,14 +223,14 @@ void ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
|
| RefPtr<Node> next = refChild;
|
|
|
| NodeVector targets;
|
| - collectChildrenAndRemoveFromOldParent(*newChild, targets, es);
|
| - if (es.hadException())
|
| + collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState);
|
| + if (exceptionState.hadException())
|
| return;
|
| if (targets.isEmpty())
|
| return;
|
|
|
| // We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
|
| - if (!checkAcceptChildGuaranteedNodeTypes(*this, *newChild, insertBeforeMethodName, es))
|
| + if (!checkAcceptChildGuaranteedNodeTypes(*this, *newChild, insertBeforeMethodName, exceptionState))
|
| return;
|
|
|
| InspectorInstrumentation::willInsertDOMNode(this);
|
| @@ -308,7 +308,7 @@ void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node& nextChil
|
| ChildNodeInsertionNotifier(*this).notify(*newChild);
|
| }
|
|
|
| -void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionState& es)
|
| +void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionState& exceptionState)
|
| {
|
| // Check that this node is not "floating".
|
| // If it is, it can be deleted as a side effect of sending mutation events.
|
| @@ -320,17 +320,17 @@ void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
|
| return;
|
|
|
| if (!oldChild) {
|
| - es.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(replaceChildMethodName, "Node", "The node to be replaced is null."));
|
| + exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(replaceChildMethodName, "Node", "The node to be replaced is null."));
|
| return;
|
| }
|
|
|
| // Make sure replacing the old child with the new is ok
|
| - if (!checkReplaceChild(*this, newChild.get(), *oldChild, replaceChildMethodName, es))
|
| + if (!checkReplaceChild(*this, newChild.get(), *oldChild, replaceChildMethodName, exceptionState))
|
| return;
|
|
|
| // NotFoundError: Raised if oldChild is not a child of this node.
|
| if (oldChild->parentNode() != this) {
|
| - es.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(replaceChildMethodName, "Node", "The node to be replaced is not a child of this node."));
|
| + exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(replaceChildMethodName, "Node", "The node to be replaced is not a child of this node."));
|
| return;
|
| }
|
|
|
| @@ -340,24 +340,24 @@ void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
|
|
|
| // Remove the node we're replacing
|
| RefPtr<Node> removedChild = oldChild;
|
| - removeChild(oldChild, es);
|
| - if (es.hadException())
|
| + removeChild(oldChild, exceptionState);
|
| + if (exceptionState.hadException())
|
| return;
|
|
|
| if (next && (next->previousSibling() == newChild || next == newChild)) // nothing to do
|
| return;
|
|
|
| // Does this one more time because removeChild() fires a MutationEvent.
|
| - if (!checkReplaceChild(*this, newChild.get(), *oldChild, replaceChildMethodName, es))
|
| + if (!checkReplaceChild(*this, newChild.get(), *oldChild, replaceChildMethodName, exceptionState))
|
| return;
|
|
|
| NodeVector targets;
|
| - collectChildrenAndRemoveFromOldParent(*newChild, targets, es);
|
| - if (es.hadException())
|
| + collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState);
|
| + if (exceptionState.hadException())
|
| return;
|
|
|
| // Does this yet another check because collectChildrenAndRemoveFromOldParent() fires a MutationEvent.
|
| - if (!checkReplaceChild(*this, newChild.get(), *oldChild, replaceChildMethodName, es))
|
| + if (!checkReplaceChild(*this, newChild.get(), *oldChild, replaceChildMethodName, exceptionState))
|
| return;
|
|
|
| InspectorInstrumentation::willInsertDOMNode(this);
|
| @@ -427,7 +427,7 @@ void ContainerNode::disconnectDescendantFrames()
|
| ChildFrameDisconnector(*this).disconnect();
|
| }
|
|
|
| -void ContainerNode::removeChild(Node* oldChild, ExceptionState& es)
|
| +void ContainerNode::removeChild(Node* oldChild, ExceptionState& exceptionState)
|
| {
|
| // Check that this node is not "floating".
|
| // If it is, it can be deleted as a side effect of sending mutation events.
|
| @@ -437,7 +437,7 @@ void ContainerNode::removeChild(Node* oldChild, ExceptionState& es)
|
|
|
| // NotFoundError: Raised if oldChild is not a child of this node.
|
| if (!oldChild || oldChild->parentNode() != this) {
|
| - es.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute("removeChild", "Node", "The node to be removed is not a child of this node."));
|
| + exceptionState.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute("removeChild", "Node", "The node to be removed is not a child of this node."));
|
| return;
|
| }
|
|
|
| @@ -451,7 +451,7 @@ void ContainerNode::removeChild(Node* oldChild, ExceptionState& es)
|
| // Events fired when blurring currently focused node might have moved this
|
| // child into a different parent.
|
| if (child->parentNode() != this) {
|
| - es.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, 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?"));
|
| return;
|
| }
|
|
|
| @@ -459,7 +459,7 @@ void ContainerNode::removeChild(Node* oldChild, ExceptionState& es)
|
|
|
| // Mutation events might have moved this child into a different parent.
|
| if (child->parentNode() != this) {
|
| - es.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, 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?"));
|
| return;
|
| }
|
|
|
| @@ -573,7 +573,7 @@ void ContainerNode::removeChildren()
|
| dispatchSubtreeModifiedEvent();
|
| }
|
|
|
| -void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& es)
|
| +void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& exceptionState)
|
| {
|
| RefPtr<ContainerNode> protect(this);
|
|
|
| @@ -582,7 +582,7 @@ void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& es)
|
| ASSERT(refCount() || parentOrShadowHostNode());
|
|
|
| // Make sure adding the new child is ok
|
| - if (!checkAddChild(*this, newChild.get(), appendChildMethodName, es))
|
| + if (!checkAddChild(*this, newChild.get(), appendChildMethodName, exceptionState))
|
| return;
|
| ASSERT(newChild);
|
|
|
| @@ -590,15 +590,15 @@ void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& es)
|
| return;
|
|
|
| NodeVector targets;
|
| - collectChildrenAndRemoveFromOldParent(*newChild, targets, es);
|
| - if (es.hadException())
|
| + collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState);
|
| + if (exceptionState.hadException())
|
| return;
|
|
|
| if (targets.isEmpty())
|
| return;
|
|
|
| // We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
|
| - if (!checkAcceptChildGuaranteedNodeTypes(*this, *newChild, appendChildMethodName, es))
|
| + if (!checkAcceptChildGuaranteedNodeTypes(*this, *newChild, appendChildMethodName, exceptionState))
|
| return;
|
|
|
| InspectorInstrumentation::willInsertDOMNode(this);
|
| @@ -683,9 +683,9 @@ void ContainerNode::childrenChanged(bool changedByParser, Node*, Node*, int chil
|
|
|
| void ContainerNode::cloneChildNodes(ContainerNode *clone)
|
| {
|
| - TrackExceptionState es;
|
| - for (Node* n = firstChild(); n && !es.hadException(); n = n->nextSibling())
|
| - clone->appendChild(n->cloneNode(true), es);
|
| + TrackExceptionState exceptionState;
|
| + for (Node* n = firstChild(); n && !exceptionState.hadException(); n = n->nextSibling())
|
| + clone->appendChild(n->cloneNode(true), exceptionState);
|
| }
|
|
|
|
|
|
|