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

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

Issue 23890025: WIP (Introduce WTF::NonNullPtr<T>.) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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/Attr.cpp ('k') | Source/core/dom/Document.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 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 oldParent->removeDetachedChildren(); 96 oldParent->removeDetachedChildren();
97 97
98 for (unsigned i = 0; i < children.size(); ++i) { 98 for (unsigned i = 0; i < children.size(); ++i) {
99 if (children[i]->attached()) 99 if (children[i]->attached())
100 children[i]->detach(); 100 children[i]->detach();
101 // FIXME: We need a no mutation event version of adoptNode. 101 // FIXME: We need a no mutation event version of adoptNode.
102 RefPtr<Node> child = document().adoptNode(children[i].release(), ASSERT_ NO_EXCEPTION); 102 RefPtr<Node> child = document().adoptNode(children[i].release(), ASSERT_ NO_EXCEPTION);
103 // FIXME: Together with adoptNode above, the tree scope might get update d recursively twice 103 // FIXME: Together with adoptNode above, the tree scope might get update d recursively twice
104 // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree). 104 // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
105 // Can we do better? 105 // Can we do better?
106 treeScope().adoptIfNeeded(child.get()); 106 treeScope()->adoptIfNeeded(child.get());
107 parserAppendChild(child.get()); 107 parserAppendChild(child.get());
108 } 108 }
109 } 109 }
110 110
111 ContainerNode::~ContainerNode() 111 ContainerNode::~ContainerNode()
112 { 112 {
113 if (Document* document = documentInternal()) 113 if (Document* document = documentInternal())
114 willBeDeletedFrom(document); 114 willBeDeletedFrom(document);
115 removeDetachedChildren(); 115 removeDetachedChildren();
116 } 116 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 // Due to arbitrary code running in response to a DOM mutation event it' s 255 // Due to arbitrary code running in response to a DOM mutation event it' s
256 // possible that "next" is no longer a child of "this". 256 // possible that "next" is no longer a child of "this".
257 // It's also possible that "child" has been inserted elsewhere. 257 // It's also possible that "child" has been inserted elsewhere.
258 // In either of those cases, we'll just stop. 258 // In either of those cases, we'll just stop.
259 if (next->parentNode() != this) 259 if (next->parentNode() != this)
260 break; 260 break;
261 if (child->parentNode()) 261 if (child->parentNode())
262 break; 262 break;
263 263
264 treeScope().adoptIfNeeded(child); 264 treeScope()->adoptIfNeeded(child);
265 265
266 insertBeforeCommon(next.get(), child); 266 insertBeforeCommon(next.get(), child);
267 267
268 updateTreeAfterInsertion(this, child); 268 updateTreeAfterInsertion(this, child);
269 } 269 }
270 270
271 dispatchSubtreeModifiedEvent(); 271 dispatchSubtreeModifiedEvent();
272 } 272 }
273 273
274 void ContainerNode::insertBeforeCommon(Node* nextChild, Node* newChild) 274 void ContainerNode::insertBeforeCommon(Node* nextChild, Node* newChild)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 // Due to arbitrary code running in response to a DOM mutation event it' s 383 // Due to arbitrary code running in response to a DOM mutation event it' s
384 // possible that "next" is no longer a child of "this". 384 // possible that "next" is no longer a child of "this".
385 // It's also possible that "child" has been inserted elsewhere. 385 // It's also possible that "child" has been inserted elsewhere.
386 // In either of those cases, we'll just stop. 386 // In either of those cases, we'll just stop.
387 if (next && next->parentNode() != this) 387 if (next && next->parentNode() != this)
388 break; 388 break;
389 if (child->parentNode()) 389 if (child->parentNode())
390 break; 390 break;
391 391
392 treeScope().adoptIfNeeded(child); 392 treeScope()->adoptIfNeeded(child);
393 393
394 // Add child before "next". 394 // Add child before "next".
395 { 395 {
396 NoEventDispatchAssertion assertNoEventDispatch; 396 NoEventDispatchAssertion assertNoEventDispatch;
397 if (next) 397 if (next)
398 insertBeforeCommon(next.get(), child); 398 insertBeforeCommon(next.get(), child);
399 else 399 else
400 appendChildToContainer(child, this); 400 appendChildToContainer(child, this);
401 } 401 }
402 402
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 ChildListMutationScope mutation(this); 613 ChildListMutationScope mutation(this);
614 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); + +it) { 614 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); + +it) {
615 Node* child = it->get(); 615 Node* child = it->get();
616 616
617 // If the child has a parent again, just stop what we're doing, because 617 // If the child has a parent again, just stop what we're doing, because
618 // that means someone is doing something with DOM mutation -- can't re-p arent 618 // that means someone is doing something with DOM mutation -- can't re-p arent
619 // a child that already has a parent. 619 // a child that already has a parent.
620 if (child->parentNode()) 620 if (child->parentNode())
621 break; 621 break;
622 622
623 treeScope().adoptIfNeeded(child); 623 treeScope()->adoptIfNeeded(child);
624 624
625 // Append child to the end of the list 625 // Append child to the end of the list
626 { 626 {
627 NoEventDispatchAssertion assertNoEventDispatch; 627 NoEventDispatchAssertion assertNoEventDispatch;
628 appendChildToContainer(child, this); 628 appendChildToContainer(child, this);
629 } 629 }
630 630
631 updateTreeAfterInsertion(this, child); 631 updateTreeAfterInsertion(this, child);
632 } 632 }
633 633
634 dispatchSubtreeModifiedEvent(); 634 dispatchSubtreeModifiedEvent();
635 } 635 }
636 636
637 void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) 637 void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild)
638 { 638 {
639 ASSERT(newChild); 639 ASSERT(newChild);
640 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re parenting (and want DOM mutation events). 640 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re parenting (and want DOM mutation events).
641 ASSERT(!newChild->isDocumentFragment()); 641 ASSERT(!newChild->isDocumentFragment());
642 ASSERT(!hasTagName(HTMLNames::templateTag)); 642 ASSERT(!hasTagName(HTMLNames::templateTag));
643 643
644 if (&document() != &newChild->document()) 644 if (&document() != &newChild->document())
645 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); 645 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
646 646
647 Node* last = m_lastChild; 647 Node* last = m_lastChild;
648 { 648 {
649 NoEventDispatchAssertion assertNoEventDispatch; 649 NoEventDispatchAssertion assertNoEventDispatch;
650 // FIXME: This method should take a PassRefPtr. 650 // FIXME: This method should take a PassRefPtr.
651 appendChildToContainer(newChild.get(), this); 651 appendChildToContainer(newChild.get(), this);
652 treeScope().adoptIfNeeded(newChild.get()); 652 treeScope()->adoptIfNeeded(newChild.get());
653 } 653 }
654 654
655 newChild->updateAncestorConnectedSubframeCountForInsertion(); 655 newChild->updateAncestorConnectedSubframeCountForInsertion();
656 656
657 ChildListMutationScope(this).childAdded(newChild.get()); 657 ChildListMutationScope(this).childAdded(newChild.get());
658 658
659 childrenChanged(true, last, 0, 1); 659 childrenChanged(true, last, 0, 1);
660 ChildNodeInsertionNotifier(this).notify(newChild.get()); 660 ChildNodeInsertionNotifier(this).notify(newChild.get());
661 } 661 }
662 662
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 return true; 993 return true;
994 994
995 if (node->isElementNode() && toElement(node)->shadow()) 995 if (node->isElementNode() && toElement(node)->shadow())
996 return true; 996 return true;
997 997
998 return false; 998 return false;
999 } 999 }
1000 #endif 1000 #endif
1001 1001
1002 } // namespace WebCore 1002 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Attr.cpp ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698