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

Side by Side Diff: Source/core/dom/ContainerNode.cpp

Issue 1117973003: parserInsertBefore and parserRemoveChild should check newChild for a parent. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update comment. Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/html/parser/HTMLConstructionSite.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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).
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
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
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/html/parser/HTMLConstructionSite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698