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

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

Issue 1237623006: Post-Mutation Event checks must re-check document constraints. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline. Created 5 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') | no next file » | 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 5fa16c018262ac61a3d5429fa0dd8150c3f94634..34d268362a14daf227997aa7cf7282e1fd024df9 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -145,29 +145,21 @@ bool ContainerNode::checkAcceptChild(const Node* newChild, const Node* oldChild,
return false;
}
- if (containsConsideringHostElements(*newChild)) {
- exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent.");
- return false;
- }
-
- if (isDocumentNode())
- return toDocument(this)->canAcceptChild(*newChild, oldChild, exceptionState);
-
- if (!isChildTypeAllowed(*newChild)) {
- exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + nodeName() + "'.");
- return false;
- }
-
- return true;
+ return checkAcceptChildGuaranteedNodeTypes(*newChild, oldChild, exceptionState);
}
-bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, ExceptionState& exceptionState) const
+bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, const Node* oldChild, ExceptionState& exceptionState) const
{
- ASSERT(isChildTypeAllowed(newChild));
+ if (isDocumentNode())
+ return toDocument(this)->canAcceptChild(newChild, oldChild, exceptionState);
if (newChild.containsIncludingHostElements(*this)) {
exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent.");
return false;
}
+ if (!isChildTypeAllowed(newChild)) {
+ exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '" + newChild.nodeName() + "' may not be inserted inside nodes of type '" + nodeName() + "'.");
+ return false;
+ }
return true;
}
@@ -214,7 +206,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<
return newChild;
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
- if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) {
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, nullptr, exceptionState)) {
if (exceptionState.hadException())
return nullptr;
return newChild;
@@ -737,7 +729,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::appendChild(PassRefPtrWillBeRawPtr<N
return newChild;
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
- if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) {
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, nullptr, exceptionState)) {
if (exceptionState.hadException())
return nullptr;
return newChild;
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698