OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 // This should never happen, but also protect release builds from tree corru
ption. | 141 // This should never happen, but also protect release builds from tree corru
ption. |
142 ASSERT(!newChild->isPseudoElement()); | 142 ASSERT(!newChild->isPseudoElement()); |
143 if (newChild->isPseudoElement()) { | 143 if (newChild->isPseudoElement()) { |
144 exceptionState.throwDOMException(HierarchyRequestError, "The new child e
lement is a pseudo-element."); | 144 exceptionState.throwDOMException(HierarchyRequestError, "The new child e
lement is a pseudo-element."); |
145 return false; | 145 return false; |
146 } | 146 } |
147 | 147 |
148 if (containsConsideringHostElements(*newChild)) { | 148 return checkAcceptChildGuaranteedNodeTypes(*newChild, oldChild, exceptionSta
te); |
| 149 } |
| 150 |
| 151 bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, co
nst Node* oldChild, ExceptionState& exceptionState) const |
| 152 { |
| 153 if (isDocumentNode()) |
| 154 return toDocument(this)->canAcceptChild(newChild, oldChild, exceptionSta
te); |
| 155 if (newChild.containsIncludingHostElements(*this)) { |
149 exceptionState.throwDOMException(HierarchyRequestError, "The new child e
lement contains the parent."); | 156 exceptionState.throwDOMException(HierarchyRequestError, "The new child e
lement contains the parent."); |
150 return false; | 157 return false; |
151 } | 158 } |
152 | 159 if (!isChildTypeAllowed(newChild)) { |
153 if (isDocumentNode()) | 160 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '
" + newChild.nodeName() + "' may not be inserted inside nodes of type '" + nodeN
ame() + "'."); |
154 return toDocument(this)->canAcceptChild(*newChild, oldChild, exceptionSt
ate); | |
155 | |
156 if (!isChildTypeAllowed(*newChild)) { | |
157 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '
" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + node
Name() + "'."); | |
158 return false; | |
159 } | |
160 | |
161 return true; | |
162 } | |
163 | |
164 bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, Ex
ceptionState& exceptionState) const | |
165 { | |
166 ASSERT(isChildTypeAllowed(newChild)); | |
167 if (newChild.containsIncludingHostElements(*this)) { | |
168 exceptionState.throwDOMException(HierarchyRequestError, "The new child e
lement contains the parent."); | |
169 return false; | 161 return false; |
170 } | 162 } |
171 return true; | 163 return true; |
172 } | 164 } |
173 | 165 |
174 PassRefPtrWillBeRawPtr<Node> ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<
Node> newChild, Node* refChild, ExceptionState& exceptionState) | 166 PassRefPtrWillBeRawPtr<Node> ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<
Node> newChild, Node* refChild, ExceptionState& exceptionState) |
175 { | 167 { |
176 #if !ENABLE(OILPAN) | 168 #if !ENABLE(OILPAN) |
177 // Check that this node is not "floating". | 169 // Check that this node is not "floating". |
178 // If it is, it can be deleted as a side effect of sending mutation events. | 170 // If it is, it can be deleted as a side effect of sending mutation events. |
(...skipping 28 matching lines...) Expand all Loading... |
207 RefPtrWillBeRawPtr<Node> next = refChild; | 199 RefPtrWillBeRawPtr<Node> next = refChild; |
208 | 200 |
209 NodeVector targets; | 201 NodeVector targets; |
210 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); | 202 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); |
211 if (exceptionState.hadException()) | 203 if (exceptionState.hadException()) |
212 return nullptr; | 204 return nullptr; |
213 if (targets.isEmpty()) | 205 if (targets.isEmpty()) |
214 return newChild; | 206 return newChild; |
215 | 207 |
216 // We need this extra check because collectChildrenAndRemoveFromOldParent()
can fire mutation events. | 208 // We need this extra check because collectChildrenAndRemoveFromOldParent()
can fire mutation events. |
217 if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) { | 209 if (!checkAcceptChildGuaranteedNodeTypes(*newChild, nullptr, exceptionState)
) { |
218 if (exceptionState.hadException()) | 210 if (exceptionState.hadException()) |
219 return nullptr; | 211 return nullptr; |
220 return newChild; | 212 return newChild; |
221 } | 213 } |
222 | 214 |
223 InspectorInstrumentation::willInsertDOMNode(this); | 215 InspectorInstrumentation::willInsertDOMNode(this); |
224 | 216 |
225 ChildListMutationScope mutation(*this); | 217 ChildListMutationScope mutation(*this); |
226 for (const auto& targetNode : targets) { | 218 for (const auto& targetNode : targets) { |
227 ASSERT(targetNode); | 219 ASSERT(targetNode); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 722 |
731 NodeVector targets; | 723 NodeVector targets; |
732 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); | 724 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); |
733 if (exceptionState.hadException()) | 725 if (exceptionState.hadException()) |
734 return nullptr; | 726 return nullptr; |
735 | 727 |
736 if (targets.isEmpty()) | 728 if (targets.isEmpty()) |
737 return newChild; | 729 return newChild; |
738 | 730 |
739 // We need this extra check because collectChildrenAndRemoveFromOldParent()
can fire mutation events. | 731 // We need this extra check because collectChildrenAndRemoveFromOldParent()
can fire mutation events. |
740 if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) { | 732 if (!checkAcceptChildGuaranteedNodeTypes(*newChild, nullptr, exceptionState)
) { |
741 if (exceptionState.hadException()) | 733 if (exceptionState.hadException()) |
742 return nullptr; | 734 return nullptr; |
743 return newChild; | 735 return newChild; |
744 } | 736 } |
745 | 737 |
746 InspectorInstrumentation::willInsertDOMNode(this); | 738 InspectorInstrumentation::willInsertDOMNode(this); |
747 | 739 |
748 // Now actually add the child(ren). | 740 // Now actually add the child(ren). |
749 ChildListMutationScope mutation(*this); | 741 ChildListMutationScope mutation(*this); |
750 for (const auto& targetNode : targets) { | 742 for (const auto& targetNode : targets) { |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 return true; | 1514 return true; |
1523 | 1515 |
1524 if (node->isElementNode() && toElement(node)->shadow()) | 1516 if (node->isElementNode() && toElement(node)->shadow()) |
1525 return true; | 1517 return true; |
1526 | 1518 |
1527 return false; | 1519 return false; |
1528 } | 1520 } |
1529 #endif | 1521 #endif |
1530 | 1522 |
1531 } // namespace blink | 1523 } // namespace blink |
OLD | NEW |