OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 3 * (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ContainerNode& m_insertionPoint; | 66 ContainerNode& m_insertionPoint; |
67 }; | 67 }; |
68 | 68 |
69 namespace Private { | 69 namespace Private { |
70 | 70 |
71 template<class GenericNode, class GenericNodeContainer> | 71 template<class GenericNode, class GenericNodeContainer> |
72 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Ge
nericNodeContainer&); | 72 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Ge
nericNodeContainer&); |
73 | 73 |
74 } | 74 } |
75 | 75 |
| 76 #if !ENABLE(OILPAN) |
76 // Helper functions for TreeShared-derived classes, which have a 'Node' style in
terface | 77 // Helper functions for TreeShared-derived classes, which have a 'Node' style in
terface |
77 // This applies to 'ContainerNode' and 'SVGElementInstance' | 78 // This applies to 'ContainerNode' and 'SVGElementInstance' |
78 template<class GenericNode, class GenericNodeContainer> | 79 template<class GenericNode, class GenericNodeContainer> |
79 inline void removeDetachedChildrenInContainer(GenericNodeContainer& container) | 80 inline void removeDetachedChildrenInContainer(GenericNodeContainer& container) |
80 { | 81 { |
81 // List of nodes to be deleted. | 82 // List of nodes to be deleted. |
82 GenericNode* head = 0; | 83 GenericNode* head = 0; |
83 GenericNode* tail = 0; | 84 GenericNode* tail = 0; |
84 | 85 |
85 Private::addChildNodesToDeletionQueue<GenericNode, GenericNodeContainer>(hea
d, tail, container); | 86 Private::addChildNodesToDeletionQueue<GenericNode, GenericNodeContainer>(hea
d, tail, container); |
86 | 87 |
87 GenericNode* n; | 88 GenericNode* n; |
88 GenericNode* next; | 89 GenericNode* next; |
89 while ((n = head) != 0) { | 90 while ((n = head) != 0) { |
90 #if !ENABLE(OILPAN) | |
91 ASSERT_WITH_SECURITY_IMPLICATION(n->m_deletionHasBegun); | 91 ASSERT_WITH_SECURITY_IMPLICATION(n->m_deletionHasBegun); |
92 #endif | |
93 | 92 |
94 next = n->nextSibling(); | 93 next = n->nextSibling(); |
95 n->setNextSibling(0); | 94 n->setNextSibling(0); |
96 | 95 |
97 head = next; | 96 head = next; |
98 if (next == 0) | 97 if (next == 0) |
99 tail = 0; | 98 tail = 0; |
100 | 99 |
101 if (n->hasChildren()) | 100 if (n->hasChildren()) |
102 Private::addChildNodesToDeletionQueue<GenericNode, GenericNodeContai
ner>(head, tail, static_cast<GenericNodeContainer&>(*n)); | 101 Private::addChildNodesToDeletionQueue<GenericNode, GenericNodeContai
ner>(head, tail, static_cast<GenericNodeContainer&>(*n)); |
103 | 102 |
104 #if !ENABLE(OILPAN) | |
105 delete n; | 103 delete n; |
106 #endif | |
107 } | 104 } |
108 } | 105 } |
| 106 #endif |
109 | 107 |
110 template<class GenericNode, class GenericNodeContainer> | 108 template<class GenericNode, class GenericNodeContainer> |
111 inline void appendChildToContainer(GenericNode& child, GenericNodeContainer& con
tainer) | 109 inline void appendChildToContainer(GenericNode& child, GenericNodeContainer& con
tainer) |
112 { | 110 { |
113 child.setParentOrShadowHostNode(&container); | 111 child.setParentOrShadowHostNode(&container); |
114 | 112 |
115 GenericNode* lastChild = container.lastChild(); | 113 GenericNode* lastChild = container.lastChild(); |
116 if (lastChild) { | 114 if (lastChild) { |
117 child.setPreviousSibling(lastChild); | 115 child.setPreviousSibling(lastChild); |
118 lastChild->setNextSibling(&child); | 116 lastChild->setNextSibling(&child); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 for (GenericNode* n = container.firstChild(); n; n = next) { | 162 for (GenericNode* n = container.firstChild(); n; n = next) { |
165 ASSERT_WITH_SECURITY_IMPLICATION(!n->m_deletionHasBegun); | 163 ASSERT_WITH_SECURITY_IMPLICATION(!n->m_deletionHasBegun); |
166 | 164 |
167 next = n->nextSibling(); | 165 next = n->nextSibling(); |
168 n->setNextSibling(0); | 166 n->setNextSibling(0); |
169 n->setParentOrShadowHostNode(0); | 167 n->setParentOrShadowHostNode(0); |
170 container.setFirstChild(next); | 168 container.setFirstChild(next); |
171 if (next) | 169 if (next) |
172 next->setPreviousSibling(0); | 170 next->setPreviousSibling(0); |
173 | 171 |
174 #if ENABLE(OILPAN) | |
175 { | |
176 // Always notify nodes of removal from the document even if they | |
177 // are going to die. Nodes do not immediately die when their | |
178 // refcounts reach zero with Oilpan. They die at the next garbag
e | |
179 // collection. The notifications when removed from document | |
180 // allows us to perform cleanup on the nodes when they are remov
ed | |
181 // instead of when their destructors are called. | |
182 RefPtr<GenericNode> protect(n); // removedFromDocument may remov
e all references to this node. | |
183 NodeRemovalDispatcher<GenericNode, GenericNodeContainer, ShouldD
ispatchRemovalNotification<GenericNode>::value>::dispatch(*n, container); | |
184 } | |
185 if (!n->refCount()) { | |
186 // Add the node to the list of nodes to be deleted. | |
187 // Reuse the nextSibling pointer for this purpose. | |
188 if (tail) | |
189 tail->setNextSibling(n); | |
190 else | |
191 head = n; | |
192 | |
193 tail = n; | |
194 } | |
195 #else | |
196 if (!n->refCount()) { | 172 if (!n->refCount()) { |
197 #if SECURITY_ASSERT_ENABLED | 173 #if SECURITY_ASSERT_ENABLED |
198 n->m_deletionHasBegun = true; | 174 n->m_deletionHasBegun = true; |
199 #endif | 175 #endif |
200 // Add the node to the list of nodes to be deleted. | 176 // Add the node to the list of nodes to be deleted. |
201 // Reuse the nextSibling pointer for this purpose. | 177 // Reuse the nextSibling pointer for this purpose. |
202 if (tail) | 178 if (tail) |
203 tail->setNextSibling(n); | 179 tail->setNextSibling(n); |
204 else | 180 else |
205 head = n; | 181 head = n; |
206 | 182 |
207 tail = n; | 183 tail = n; |
208 } else { | 184 } else { |
209 RefPtr<GenericNode> protect(n); // removedFromDocument may remov
e all references to this node. | 185 RefPtr<GenericNode> protect(n); // removedFromDocument may remov
e all references to this node. |
210 NodeRemovalDispatcher<GenericNode, GenericNodeContainer, ShouldD
ispatchRemovalNotification<GenericNode>::value>::dispatch(*n, container); | 186 NodeRemovalDispatcher<GenericNode, GenericNodeContainer, ShouldD
ispatchRemovalNotification<GenericNode>::value>::dispatch(*n, container); |
211 } | 187 } |
212 #endif // ENABLE(OILPAN) | |
213 } | 188 } |
214 | 189 |
215 container.setLastChild(0); | 190 container.setLastChild(0); |
216 } | 191 } |
217 | 192 |
218 } // namespace Private | 193 } // namespace Private |
219 | 194 |
220 inline void ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(Node& nod
e) | 195 inline void ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(Node& nod
e) |
221 { | 196 { |
222 ASSERT(m_insertionPoint.inDocument()); | 197 ASSERT(m_insertionPoint.inDocument()); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 for (Node* child = m_root.firstChild(); child; child = child->nextSiblin
g()) | 333 for (Node* child = m_root.firstChild(); child; child = child->nextSiblin
g()) |
359 collectFrameOwners(*child); | 334 collectFrameOwners(*child); |
360 } | 335 } |
361 | 336 |
362 disconnectCollectedFrameOwners(); | 337 disconnectCollectedFrameOwners(); |
363 } | 338 } |
364 | 339 |
365 } // namespace WebCore | 340 } // namespace WebCore |
366 | 341 |
367 #endif // ContainerNodeAlgorithms_h | 342 #endif // ContainerNodeAlgorithms_h |
OLD | NEW |