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

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: Include future from patch for Issue 509912. 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
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 1f9886e28c02eb1ca33f1ed329975120d9ad47ce..1b79bd9c1c742bc7b2726f9fb32ab007f6b58a4a 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -145,26 +145,18 @@ 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;
- }
+ return checkAcceptChildGuaranteedNodeTypes(*newChild, oldChild, exceptionState);
+}
+bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, const Node* oldChild, ExceptionState& exceptionState) const
+{
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 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;
-}
-
-bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, ExceptionState& exceptionState) const
-{
- ASSERT(isChildTypeAllowed(newChild));
- if (newChild.contains(this)) {
+ if (newChild.containsIncludingHostElements(*this)) {
exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent.");
return false;
}
@@ -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;

Powered by Google App Engine
This is Rietveld 408576698