| 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 28 matching lines...) Expand all Loading... |
| 39 void notifyInsertedIntoDocument(Node*); | 39 void notifyInsertedIntoDocument(Node*); |
| 40 void notify(Node*); | 40 void notify(Node*); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 void notifyDescendantInsertedIntoDocument(ContainerNode*); | 43 void notifyDescendantInsertedIntoDocument(ContainerNode*); |
| 44 void notifyDescendantInsertedIntoTree(ContainerNode*); | 44 void notifyDescendantInsertedIntoTree(ContainerNode*); |
| 45 void notifyNodeInsertedIntoDocument(Node*); | 45 void notifyNodeInsertedIntoDocument(Node*); |
| 46 void notifyNodeInsertedIntoTree(ContainerNode*); | 46 void notifyNodeInsertedIntoTree(ContainerNode*); |
| 47 | 47 |
| 48 ContainerNode* m_insertionPoint; | 48 ContainerNode* m_insertionPoint; |
| 49 Vector< RefPtr<Node> > m_postInsertionNotificationTargets; |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 class ChildNodeRemovalNotifier { | 52 class ChildNodeRemovalNotifier { |
| 52 public: | 53 public: |
| 53 explicit ChildNodeRemovalNotifier(ContainerNode* insertionPoint) | 54 explicit ChildNodeRemovalNotifier(ContainerNode* insertionPoint) |
| 54 : m_insertionPoint(insertionPoint) | 55 : m_insertionPoint(insertionPoint) |
| 55 { | 56 { |
| 56 } | 57 } |
| 57 | 58 |
| 58 void notify(Node*); | 59 void notify(Node*); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 191 |
| 191 inline void ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(Node* nod
e) | 192 inline void ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(Node* nod
e) |
| 192 { | 193 { |
| 193 ASSERT(m_insertionPoint->inDocument()); | 194 ASSERT(m_insertionPoint->inDocument()); |
| 194 RefPtr<Node> protect(node); | 195 RefPtr<Node> protect(node); |
| 195 Node::InsertionNotificationRequest request = node->insertedInto(m_insertionP
oint); | 196 Node::InsertionNotificationRequest request = node->insertedInto(m_insertionP
oint); |
| 196 | 197 |
| 197 if (node->isContainerNode()) | 198 if (node->isContainerNode()) |
| 198 notifyDescendantInsertedIntoDocument(toContainerNode(node)); | 199 notifyDescendantInsertedIntoDocument(toContainerNode(node)); |
| 199 | 200 |
| 200 if (request == Node::InsertionShouldCallDidNotifyDescendantInsertions) | 201 switch (request) { |
| 202 case Node::InsertionDone: |
| 203 break; |
| 204 case Node::InsertionShouldCallDidNotifyDescendantInsertions: |
| 201 node->didNotifyDescendantInsertions(m_insertionPoint); | 205 node->didNotifyDescendantInsertions(m_insertionPoint); |
| 206 break; |
| 207 case Node::InsertionShouldCallDidNotifySubtreeInsertions: |
| 208 m_postInsertionNotificationTargets.append(node); |
| 209 break; |
| 210 } |
| 202 } | 211 } |
| 203 | 212 |
| 204 inline void ChildNodeInsertionNotifier::notifyNodeInsertedIntoTree(ContainerNode
* node) | 213 inline void ChildNodeInsertionNotifier::notifyNodeInsertedIntoTree(ContainerNode
* node) |
| 205 { | 214 { |
| 206 ASSERT(!m_insertionPoint->inDocument()); | 215 ASSERT(!m_insertionPoint->inDocument()); |
| 207 forbidEventDispatch(); | 216 forbidEventDispatch(); |
| 208 | 217 |
| 209 Node::InsertionNotificationRequest request = node->insertedInto(m_insertionP
oint); | 218 Node::InsertionNotificationRequest request = node->insertedInto(m_insertionP
oint); |
| 210 | 219 |
| 211 notifyDescendantInsertedIntoTree(node); | 220 notifyDescendantInsertedIntoTree(node); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 228 InspectorInstrumentation::didInsertDOMNode(node->document(), node); | 237 InspectorInstrumentation::didInsertDOMNode(node->document(), node); |
| 229 #endif | 238 #endif |
| 230 | 239 |
| 231 RefPtr<Document> protectDocument(node->document()); | 240 RefPtr<Document> protectDocument(node->document()); |
| 232 RefPtr<Node> protectNode(node); | 241 RefPtr<Node> protectNode(node); |
| 233 | 242 |
| 234 if (m_insertionPoint->inDocument()) | 243 if (m_insertionPoint->inDocument()) |
| 235 notifyNodeInsertedIntoDocument(node); | 244 notifyNodeInsertedIntoDocument(node); |
| 236 else if (node->isContainerNode()) | 245 else if (node->isContainerNode()) |
| 237 notifyNodeInsertedIntoTree(toContainerNode(node)); | 246 notifyNodeInsertedIntoTree(toContainerNode(node)); |
| 247 |
| 248 for (size_t i = 0; i < m_postInsertionNotificationTargets.size(); ++i) |
| 249 m_postInsertionNotificationTargets[i]->didNotifySubtreeInsertions(m_inse
rtionPoint); |
| 238 } | 250 } |
| 239 | 251 |
| 240 | 252 |
| 241 inline void ChildNodeRemovalNotifier::notifyNodeRemovedFromDocument(Node* node) | 253 inline void ChildNodeRemovalNotifier::notifyNodeRemovedFromDocument(Node* node) |
| 242 { | 254 { |
| 243 ASSERT(m_insertionPoint->inDocument()); | 255 ASSERT(m_insertionPoint->inDocument()); |
| 244 node->removedFrom(m_insertionPoint); | 256 node->removedFrom(m_insertionPoint); |
| 245 | 257 |
| 246 if (node->isContainerNode()) | 258 if (node->isContainerNode()) |
| 247 notifyDescendantRemovedFromDocument(toContainerNode(node)); | 259 notifyDescendantRemovedFromDocument(toContainerNode(node)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 for (unsigned i = 0; i < size; ++i) { | 331 for (unsigned i = 0; i < size; ++i) { |
| 320 Target& target = m_list[i]; | 332 Target& target = m_list[i]; |
| 321 if (target.isValid()) | 333 if (target.isValid()) |
| 322 target.disconnect(); | 334 target.disconnect(); |
| 323 } | 335 } |
| 324 } | 336 } |
| 325 | 337 |
| 326 } // namespace WebCore | 338 } // namespace WebCore |
| 327 | 339 |
| 328 #endif // ContainerNodeAlgorithms_h | 340 #endif // ContainerNodeAlgorithms_h |
| OLD | NEW |