Chromium Code Reviews| 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 oldParent.parserRemoveChild(*child); | |
| 90 treeScope().adoptIfNeeded(*child); | |
| 91 parserAppendChild(child.get()); | 89 parserAppendChild(child.get()); |
| 92 } | |
| 93 } | 90 } |
| 94 | 91 |
| 95 ContainerNode::~ContainerNode() | 92 ContainerNode::~ContainerNode() |
| 96 { | 93 { |
| 97 ASSERT(needsAttach()); | 94 ASSERT(needsAttach()); |
| 98 #if !ENABLE(OILPAN) | 95 #if !ENABLE(OILPAN) |
| 99 willBeDeletedFromDocument(); | 96 willBeDeletedFromDocument(); |
| 100 removeDetachedChildren(); | 97 removeDetachedChildren(); |
| 101 #endif | 98 #endif |
| 102 } | 99 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 if (m_lastChild) { | 282 if (m_lastChild) { |
| 286 child.setPreviousSibling(m_lastChild); | 283 child.setPreviousSibling(m_lastChild); |
| 287 m_lastChild->setNextSibling(&child); | 284 m_lastChild->setNextSibling(&child); |
| 288 } else { | 285 } else { |
| 289 setFirstChild(&child); | 286 setFirstChild(&child); |
| 290 } | 287 } |
| 291 | 288 |
| 292 setLastChild(&child); | 289 setLastChild(&child); |
| 293 } | 290 } |
| 294 | 291 |
| 295 void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No de& nextChild) | 292 void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No de& nextChild) |
|
adamk
2015/05/01 16:46:53
Please update the comment in ContainerNode.h, as i
| |
| 296 { | 293 { |
| 297 ASSERT(newChild); | 294 ASSERT(newChild); |
| 298 ASSERT(nextChild.parentNode() == this); | 295 ASSERT(nextChild.parentNode() == this); |
| 299 ASSERT(!newChild->isDocumentFragment()); | 296 ASSERT(!newChild->isDocumentFragment()); |
| 300 ASSERT(!isHTMLTemplateElement(this)); | 297 ASSERT(!isHTMLTemplateElement(this)); |
| 301 | 298 |
| 302 if (nextChild.previousSibling() == newChild || &nextChild == newChild) // no thing to do | 299 if (nextChild.previousSibling() == newChild || &nextChild == newChild) // no thing to do |
| 303 return; | 300 return; |
| 304 | 301 |
| 305 RefPtrWillBeRawPtr<Node> protect(this); | 302 RefPtrWillBeRawPtr<Node> protect(this); |
| 306 | 303 |
| 304 // FIXME: parserRemoveChild can run script which could then insert the | |
| 305 // newChild back into the page. Loop until the child is actually removed. | |
| 306 // See: fast/parser/execute-script-during-adoption-agency-removal.html | |
| 307 while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode()) | |
| 308 parent->parserRemoveChild(*newChild); | |
| 309 | |
| 307 if (document() != newChild->document()) | 310 if (document() != newChild->document()) |
| 308 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 311 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| 309 | 312 |
| 310 { | 313 { |
| 311 EventDispatchForbiddenScope assertNoEventDispatch; | 314 EventDispatchForbiddenScope assertNoEventDispatch; |
| 312 ScriptForbiddenScope forbidScript; | 315 ScriptForbiddenScope forbidScript; |
| 313 | 316 |
| 314 treeScope().adoptIfNeeded(*newChild); | 317 treeScope().adoptIfNeeded(*newChild); |
| 315 insertBeforeCommon(nextChild, *newChild); | 318 insertBeforeCommon(nextChild, *newChild); |
| 316 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 319 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 updateTreeAfterInsertion(child); | 748 updateTreeAfterInsertion(child); |
| 746 } | 749 } |
| 747 | 750 |
| 748 dispatchSubtreeModifiedEvent(); | 751 dispatchSubtreeModifiedEvent(); |
| 749 return newChild; | 752 return newChild; |
| 750 } | 753 } |
| 751 | 754 |
| 752 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) | 755 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) |
| 753 { | 756 { |
| 754 ASSERT(newChild); | 757 ASSERT(newChild); |
| 755 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re parenting (and want DOM mutation events). | |
|
esprehn
2015/05/01 05:36:58
Funny enough this ASSERT wasn't in parserInsertBef
adamk
2015/05/01 16:46:54
It's in insertBeforeCommon.
| |
| 756 ASSERT(!newChild->isDocumentFragment()); | 758 ASSERT(!newChild->isDocumentFragment()); |
| 757 ASSERT(!isHTMLTemplateElement(this)); | 759 ASSERT(!isHTMLTemplateElement(this)); |
| 758 | 760 |
| 759 RefPtrWillBeRawPtr<Node> protect(this); | 761 RefPtrWillBeRawPtr<Node> protect(this); |
| 760 | 762 |
| 763 // FIXME: parserRemoveChild can run script which could then insert the | |
| 764 // newChild back into the page. Loop until the child is actually removed. | |
| 765 // See: fast/parser/execute-script-during-adoption-agency-removal.html | |
| 766 while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode()) | |
| 767 parent->parserRemoveChild(*newChild); | |
| 768 | |
| 761 if (document() != newChild->document()) | 769 if (document() != newChild->document()) |
| 762 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 770 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| 763 | 771 |
| 764 { | 772 { |
| 765 EventDispatchForbiddenScope assertNoEventDispatch; | 773 EventDispatchForbiddenScope assertNoEventDispatch; |
| 766 ScriptForbiddenScope forbidScript; | 774 ScriptForbiddenScope forbidScript; |
| 767 | 775 |
| 768 treeScope().adoptIfNeeded(*newChild); | 776 treeScope().adoptIfNeeded(*newChild); |
| 769 appendChildCommon(*newChild); | 777 appendChildCommon(*newChild); |
| 770 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 778 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1492 return true; | 1500 return true; |
| 1493 | 1501 |
| 1494 if (node->isElementNode() && toElement(node)->shadow()) | 1502 if (node->isElementNode() && toElement(node)->shadow()) |
| 1495 return true; | 1503 return true; |
| 1496 | 1504 |
| 1497 return false; | 1505 return false; |
| 1498 } | 1506 } |
| 1499 #endif | 1507 #endif |
| 1500 | 1508 |
| 1501 } // namespace blink | 1509 } // namespace blink |
| OLD | NEW |