| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 void ContainerNode::removeDetachedChildren() | 78 void ContainerNode::removeDetachedChildren() |
| 79 { | 79 { |
| 80 ASSERT(!connectedSubframeCount()); | 80 ASSERT(!connectedSubframeCount()); |
| 81 ASSERT(needsAttach()); | 81 ASSERT(needsAttach()); |
| 82 removeDetachedChildrenInContainer(*this); | 82 removeDetachedChildrenInContainer(*this); |
| 83 } | 83 } |
| 84 #endif | 84 #endif |
| 85 | 85 |
| 86 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent) | 86 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent) |
| 87 { | 87 { |
| 88 while (RefPtrWillBeRawPtr<Node> child = oldParent.firstChild()) | 88 while (RefPtrWillBeRawPtr<Node> child = oldParent.firstChild()) { |
| 89 // Explicitly remove since appending can fail, but this loop shouldn't b
e infinite. |
| 90 oldParent.parserRemoveChild(*child); |
| 89 parserAppendChild(child.get()); | 91 parserAppendChild(child.get()); |
| 92 } |
| 90 } | 93 } |
| 91 | 94 |
| 92 ContainerNode::~ContainerNode() | 95 ContainerNode::~ContainerNode() |
| 93 { | 96 { |
| 94 ASSERT(needsAttach()); | 97 ASSERT(needsAttach()); |
| 95 #if !ENABLE(OILPAN) | 98 #if !ENABLE(OILPAN) |
| 96 willBeDeletedFromDocument(); | 99 willBeDeletedFromDocument(); |
| 97 removeDetachedChildren(); | 100 removeDetachedChildren(); |
| 98 #endif | 101 #endif |
| 99 } | 102 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 if (m_lastChild) { | 285 if (m_lastChild) { |
| 283 child.setPreviousSibling(m_lastChild); | 286 child.setPreviousSibling(m_lastChild); |
| 284 m_lastChild->setNextSibling(&child); | 287 m_lastChild->setNextSibling(&child); |
| 285 } else { | 288 } else { |
| 286 setFirstChild(&child); | 289 setFirstChild(&child); |
| 287 } | 290 } |
| 288 | 291 |
| 289 setLastChild(&child); | 292 setLastChild(&child); |
| 290 } | 293 } |
| 291 | 294 |
| 295 bool ContainerNode::checkParserAcceptChild(const Node& newChild) const |
| 296 { |
| 297 if (!isDocumentNode()) |
| 298 return true; |
| 299 // TODO(esprehn): Are there other conditions where the parser can create |
| 300 // invalid trees? |
| 301 return toDocument(*this).canAcceptChild(newChild, nullptr, IGNORE_EXCEPTION)
; |
| 302 } |
| 303 |
| 292 void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No
de& nextChild) | 304 void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No
de& nextChild) |
| 293 { | 305 { |
| 294 ASSERT(newChild); | 306 ASSERT(newChild); |
| 295 ASSERT(nextChild.parentNode() == this); | 307 ASSERT(nextChild.parentNode() == this); |
| 296 ASSERT(!newChild->isDocumentFragment()); | 308 ASSERT(!newChild->isDocumentFragment()); |
| 297 ASSERT(!isHTMLTemplateElement(this)); | 309 ASSERT(!isHTMLTemplateElement(this)); |
| 298 | 310 |
| 299 if (nextChild.previousSibling() == newChild || &nextChild == newChild) // no
thing to do | 311 if (nextChild.previousSibling() == newChild || &nextChild == newChild) // no
thing to do |
| 300 return; | 312 return; |
| 301 | 313 |
| 314 if (!checkParserAcceptChild(*newChild)) |
| 315 return; |
| 316 |
| 302 RefPtrWillBeRawPtr<Node> protect(this); | 317 RefPtrWillBeRawPtr<Node> protect(this); |
| 303 | 318 |
| 304 // FIXME: parserRemoveChild can run script which could then insert the | 319 // FIXME: parserRemoveChild can run script which could then insert the |
| 305 // newChild back into the page. Loop until the child is actually removed. | 320 // newChild back into the page. Loop until the child is actually removed. |
| 306 // See: fast/parser/execute-script-during-adoption-agency-removal.html | 321 // See: fast/parser/execute-script-during-adoption-agency-removal.html |
| 307 while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode()) | 322 while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode()) |
| 308 parent->parserRemoveChild(*newChild); | 323 parent->parserRemoveChild(*newChild); |
| 309 | 324 |
| 310 if (document() != newChild->document()) | 325 if (document() != newChild->document()) |
| 311 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 326 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 dispatchSubtreeModifiedEvent(); | 771 dispatchSubtreeModifiedEvent(); |
| 757 return newChild; | 772 return newChild; |
| 758 } | 773 } |
| 759 | 774 |
| 760 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) | 775 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) |
| 761 { | 776 { |
| 762 ASSERT(newChild); | 777 ASSERT(newChild); |
| 763 ASSERT(!newChild->isDocumentFragment()); | 778 ASSERT(!newChild->isDocumentFragment()); |
| 764 ASSERT(!isHTMLTemplateElement(this)); | 779 ASSERT(!isHTMLTemplateElement(this)); |
| 765 | 780 |
| 781 if (!checkParserAcceptChild(*newChild)) |
| 782 return; |
| 783 |
| 766 RefPtrWillBeRawPtr<Node> protect(this); | 784 RefPtrWillBeRawPtr<Node> protect(this); |
| 767 | 785 |
| 768 // FIXME: parserRemoveChild can run script which could then insert the | 786 // FIXME: parserRemoveChild can run script which could then insert the |
| 769 // newChild back into the page. Loop until the child is actually removed. | 787 // newChild back into the page. Loop until the child is actually removed. |
| 770 // See: fast/parser/execute-script-during-adoption-agency-removal.html | 788 // See: fast/parser/execute-script-during-adoption-agency-removal.html |
| 771 while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode()) | 789 while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode()) |
| 772 parent->parserRemoveChild(*newChild); | 790 parent->parserRemoveChild(*newChild); |
| 773 | 791 |
| 774 if (document() != newChild->document()) | 792 if (document() != newChild->document()) |
| 775 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 793 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 return true; | 1521 return true; |
| 1504 | 1522 |
| 1505 if (node->isElementNode() && toElement(node)->shadow()) | 1523 if (node->isElementNode() && toElement(node)->shadow()) |
| 1506 return true; | 1524 return true; |
| 1507 | 1525 |
| 1508 return false; | 1526 return false; |
| 1509 } | 1527 } |
| 1510 #endif | 1528 #endif |
| 1511 | 1529 |
| 1512 } // namespace blink | 1530 } // namespace blink |
| OLD | NEW |