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

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

Issue 24773003: Rename Node::attached() to confusingAndOftenMisusedAttached() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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/dom/ContainerNodeAlgorithms.h » ('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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 getChildNodes(node, nodes); 69 getChildNodes(node, nodes);
70 toContainerNode(node)->removeChildren(); 70 toContainerNode(node)->removeChildren();
71 } 71 }
72 72
73 void ContainerNode::removeDetachedChildren() 73 void ContainerNode::removeDetachedChildren()
74 { 74 {
75 if (connectedSubframeCount()) { 75 if (connectedSubframeCount()) {
76 for (Node* child = firstChild(); child; child = child->nextSibling()) 76 for (Node* child = firstChild(); child; child = child->nextSibling())
77 child->updateAncestorConnectedSubframeCountForRemoval(); 77 child->updateAncestorConnectedSubframeCountForRemoval();
78 } 78 }
79 // FIXME: We should be able to ASSERT(!attached()) here: https://bugs.webkit .org/show_bug.cgi?id=107801 79 // FIXME: We should be able to ASSERT(!confusingAndOftenMisusedAttached()) h ere: https://bugs.webkit.org/show_bug.cgi?id=107801
80 removeDetachedChildrenInContainer<Node, ContainerNode>(this); 80 removeDetachedChildrenInContainer<Node, ContainerNode>(this);
81 } 81 }
82 82
83 void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent) 83 void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
84 { 84 {
85 NodeVector children; 85 NodeVector children;
86 getChildNodes(oldParent, children); 86 getChildNodes(oldParent, children);
87 87
88 if (oldParent->document().hasMutationObserversOfType(MutationObserver::Child List)) { 88 if (oldParent->document().hasMutationObserversOfType(MutationObserver::Child List)) {
89 ChildListMutationScope mutation(oldParent); 89 ChildListMutationScope mutation(oldParent);
90 for (unsigned i = 0; i < children.size(); ++i) 90 for (unsigned i = 0; i < children.size(); ++i)
91 mutation.willRemoveChild(children[i].get()); 91 mutation.willRemoveChild(children[i].get());
92 } 92 }
93 93
94 // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each chi ld, 94 // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each chi ld,
95 // probably inside removeDetachedChildrenInContainer. 95 // probably inside removeDetachedChildrenInContainer.
96 96
97 oldParent->removeDetachedChildren(); 97 oldParent->removeDetachedChildren();
98 98
99 for (unsigned i = 0; i < children.size(); ++i) { 99 for (unsigned i = 0; i < children.size(); ++i) {
100 if (children[i]->attached()) 100 if (children[i]->confusingAndOftenMisusedAttached())
101 children[i]->detach(); 101 children[i]->detach();
102 // FIXME: We need a no mutation event version of adoptNode. 102 // FIXME: We need a no mutation event version of adoptNode.
103 RefPtr<Node> child = document().adoptNode(children[i].release(), ASSERT_ NO_EXCEPTION); 103 RefPtr<Node> child = document().adoptNode(children[i].release(), ASSERT_ NO_EXCEPTION);
104 // FIXME: Together with adoptNode above, the tree scope might get update d recursively twice 104 // FIXME: Together with adoptNode above, the tree scope might get update d recursively twice
105 // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree). 105 // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
106 // Can we do better? 106 // Can we do better?
107 treeScope().adoptIfNeeded(child.get()); 107 treeScope().adoptIfNeeded(child.get());
108 parserAppendChild(child.get()); 108 parserAppendChild(child.get());
109 } 109 }
110 } 110 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 492 }
493 493
494 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node* ol dChild) 494 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node* ol dChild)
495 { 495 {
496 NoEventDispatchAssertion assertNoEventDispatch; 496 NoEventDispatchAssertion assertNoEventDispatch;
497 497
498 ASSERT(oldChild); 498 ASSERT(oldChild);
499 ASSERT(oldChild->parentNode() == this); 499 ASSERT(oldChild->parentNode() == this);
500 500
501 // Remove from rendering tree 501 // Remove from rendering tree
502 if (oldChild->attached()) 502 if (oldChild->confusingAndOftenMisusedAttached())
503 oldChild->detach(); 503 oldChild->detach();
504 504
505 if (nextChild) 505 if (nextChild)
506 nextChild->setPreviousSibling(previousChild); 506 nextChild->setPreviousSibling(previousChild);
507 if (previousChild) 507 if (previousChild)
508 previousChild->setNextSibling(nextChild); 508 previousChild->setNextSibling(nextChild);
509 if (m_firstChild == oldChild) 509 if (m_firstChild == oldChild)
510 m_firstChild = nextChild; 510 m_firstChild = nextChild;
511 if (m_lastChild == oldChild) 511 if (m_lastChild == oldChild)
512 m_lastChild = previousChild; 512 m_lastChild = previousChild;
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 return true; 1001 return true;
1002 1002
1003 if (node->isElementNode() && toElement(node)->shadow()) 1003 if (node->isElementNode() && toElement(node)->shadow())
1004 return true; 1004 return true;
1005 1005
1006 return false; 1006 return false;
1007 } 1007 }
1008 #endif 1008 #endif
1009 1009
1010 } // namespace WebCore 1010 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/ContainerNodeAlgorithms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698