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 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 static inline ExceptionCode checkAcceptChild(ContainerNode* newParent, Node* new
Child, Node* oldChild) | 161 static inline ExceptionCode checkAcceptChild(ContainerNode* newParent, Node* new
Child, Node* oldChild) |
162 { | 162 { |
163 // Not mentioned in spec: throw NOT_FOUND_ERR if newChild is null | 163 // Not mentioned in spec: throw NOT_FOUND_ERR if newChild is null |
164 if (!newChild) | 164 if (!newChild) |
165 return NOT_FOUND_ERR; | 165 return NOT_FOUND_ERR; |
166 | 166 |
167 // Use common case fast path if possible. | 167 // Use common case fast path if possible. |
168 if ((newChild->isElementNode() || newChild->isTextNode()) && newParent->isEl
ementNode()) { | 168 if ((newChild->isElementNode() || newChild->isTextNode()) && newParent->isEl
ementNode()) { |
169 ASSERT(!newParent->isReadOnlyNode()); | |
170 ASSERT(!newParent->isDocumentTypeNode()); | 169 ASSERT(!newParent->isDocumentTypeNode()); |
171 ASSERT(isChildTypeAllowed(newParent, newChild)); | 170 ASSERT(isChildTypeAllowed(newParent, newChild)); |
172 if (containsConsideringHostElements(newChild, newParent)) | 171 if (containsConsideringHostElements(newChild, newParent)) |
173 return HIERARCHY_REQUEST_ERR; | 172 return HIERARCHY_REQUEST_ERR; |
174 return 0; | 173 return 0; |
175 } | 174 } |
176 | 175 |
177 // This should never happen, but also protect release builds from tree corru
ption. | 176 // This should never happen, but also protect release builds from tree corru
ption. |
178 ASSERT(!newChild->isPseudoElement()); | 177 ASSERT(!newChild->isPseudoElement()); |
179 if (newChild->isPseudoElement()) | 178 if (newChild->isPseudoElement()) |
180 return HIERARCHY_REQUEST_ERR; | 179 return HIERARCHY_REQUEST_ERR; |
181 | 180 |
182 if (newParent->isReadOnlyNode()) | |
183 return NO_MODIFICATION_ALLOWED_ERR; | |
184 if (newChild->inDocument() && newChild->isDocumentTypeNode()) | 181 if (newChild->inDocument() && newChild->isDocumentTypeNode()) |
185 return HIERARCHY_REQUEST_ERR; | 182 return HIERARCHY_REQUEST_ERR; |
186 if (containsConsideringHostElements(newChild, newParent)) | 183 if (containsConsideringHostElements(newChild, newParent)) |
187 return HIERARCHY_REQUEST_ERR; | 184 return HIERARCHY_REQUEST_ERR; |
188 | 185 |
189 if (oldChild && newParent->isDocumentNode()) { | 186 if (oldChild && newParent->isDocumentNode()) { |
190 if (!toDocument(newParent)->canReplaceChild(newChild, oldChild)) | 187 if (!toDocument(newParent)->canReplaceChild(newChild, oldChild)) |
191 return HIERARCHY_REQUEST_ERR; | 188 return HIERARCHY_REQUEST_ERR; |
192 } else if (!isChildTypeAllowed(newParent, newChild)) | 189 } else if (!isChildTypeAllowed(newParent, newChild)) |
193 return HIERARCHY_REQUEST_ERR; | 190 return HIERARCHY_REQUEST_ERR; |
194 | 191 |
195 return 0; | 192 return 0; |
196 } | 193 } |
197 | 194 |
198 static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode* newParent,
Node* newChild, ExceptionCode& ec) | 195 static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode* newParent,
Node* newChild, ExceptionCode& ec) |
199 { | 196 { |
200 ASSERT(!newParent->isReadOnlyNode()); | |
201 ASSERT(!newParent->isDocumentTypeNode()); | 197 ASSERT(!newParent->isDocumentTypeNode()); |
202 ASSERT(isChildTypeAllowed(newParent, newChild)); | 198 ASSERT(isChildTypeAllowed(newParent, newChild)); |
203 if (newChild->contains(newParent)) { | 199 if (newChild->contains(newParent)) { |
204 ec = HIERARCHY_REQUEST_ERR; | 200 ec = HIERARCHY_REQUEST_ERR; |
205 return false; | 201 return false; |
206 } | 202 } |
207 | 203 |
208 return true; | 204 return true; |
209 } | 205 } |
210 | 206 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec) | 463 bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec) |
468 { | 464 { |
469 // Check that this node is not "floating". | 465 // Check that this node is not "floating". |
470 // If it is, it can be deleted as a side effect of sending mutation events. | 466 // If it is, it can be deleted as a side effect of sending mutation events. |
471 ASSERT(refCount() || parentOrShadowHostNode()); | 467 ASSERT(refCount() || parentOrShadowHostNode()); |
472 | 468 |
473 RefPtr<Node> protect(this); | 469 RefPtr<Node> protect(this); |
474 | 470 |
475 ec = 0; | 471 ec = 0; |
476 | 472 |
477 // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | |
478 if (isReadOnlyNode()) { | |
479 ec = NO_MODIFICATION_ALLOWED_ERR; | |
480 return false; | |
481 } | |
482 | |
483 // NOT_FOUND_ERR: Raised if oldChild is not a child of this node. | 473 // NOT_FOUND_ERR: Raised if oldChild is not a child of this node. |
484 if (!oldChild || oldChild->parentNode() != this) { | 474 if (!oldChild || oldChild->parentNode() != this) { |
485 ec = NOT_FOUND_ERR; | 475 ec = NOT_FOUND_ERR; |
486 return false; | 476 return false; |
487 } | 477 } |
488 | 478 |
489 RefPtr<Node> child = oldChild; | 479 RefPtr<Node> child = oldChild; |
490 | 480 |
491 document()->removeFocusedNodeOfSubtree(child.get()); | 481 document()->removeFocusedNodeOfSubtree(child.get()); |
492 | 482 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 return true; | 935 return true; |
946 | 936 |
947 if (node->isElementNode() && toElement(node)->shadow()) | 937 if (node->isElementNode() && toElement(node)->shadow()) |
948 return true; | 938 return true; |
949 | 939 |
950 return false; | 940 return false; |
951 } | 941 } |
952 #endif | 942 #endif |
953 | 943 |
954 } // namespace WebCore | 944 } // namespace WebCore |
OLD | NEW |