| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef ContainerNodeAlgorithms_h | 22 #ifndef ContainerNodeAlgorithms_h |
| 23 #define ContainerNodeAlgorithms_h | 23 #define ContainerNodeAlgorithms_h |
| 24 | 24 |
| 25 #include "core/dom/Document.h" | 25 #include "core/dom/Document.h" |
| 26 #include "core/dom/ScriptForbiddenScope.h" | |
| 27 #include "core/inspector/InspectorInstrumentation.h" | |
| 28 #include "wtf/Assertions.h" | 26 #include "wtf/Assertions.h" |
| 29 | 27 |
| 30 namespace WebCore { | 28 namespace WebCore { |
| 31 | 29 |
| 32 class ChildNodeInsertionNotifier { | |
| 33 public: | |
| 34 explicit ChildNodeInsertionNotifier(ContainerNode& insertionPoint) | |
| 35 : m_insertionPoint(insertionPoint) | |
| 36 { | |
| 37 } | |
| 38 | |
| 39 void notify(Node&); | |
| 40 | |
| 41 private: | |
| 42 void notifyNodeInserted(Node&); | |
| 43 | |
| 44 ContainerNode& m_insertionPoint; | |
| 45 Vector< RefPtr<Node> > m_postInsertionNotificationTargets; | |
| 46 }; | |
| 47 | |
| 48 inline void ChildNodeInsertionNotifier::notify(Node& node) | |
| 49 { | |
| 50 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | |
| 51 | |
| 52 InspectorInstrumentation::didInsertDOMNode(&node); | |
| 53 | |
| 54 RefPtr<Document> protectDocument(node.document()); | |
| 55 RefPtr<Node> protectNode(node); | |
| 56 | |
| 57 { | |
| 58 NoEventDispatchAssertion assertNoEventDispatch; | |
| 59 ScriptForbiddenScope forbidScript; | |
| 60 notifyNodeInserted(node); | |
| 61 } | |
| 62 | |
| 63 for (size_t i = 0; i < m_postInsertionNotificationTargets.size(); ++i) { | |
| 64 Node* targetNode = m_postInsertionNotificationTargets[i].get(); | |
| 65 if (targetNode->inDocument()) | |
| 66 targetNode->didNotifySubtreeInsertionsToDocument(); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 class ChildNodeRemovalNotifier { | |
| 71 public: | |
| 72 explicit ChildNodeRemovalNotifier(ContainerNode& insertionPoint) | |
| 73 : m_insertionPoint(insertionPoint) | |
| 74 { | |
| 75 } | |
| 76 | |
| 77 void notify(Node&); | |
| 78 | |
| 79 private: | |
| 80 void notifyNodeRemoved(Node&); | |
| 81 | |
| 82 ContainerNode& m_insertionPoint; | |
| 83 }; | |
| 84 | |
| 85 inline void ChildNodeRemovalNotifier::notify(Node& node) | |
| 86 { | |
| 87 ScriptForbiddenScope forbidScript; | |
| 88 NoEventDispatchAssertion assertNoEventDispatch; | |
| 89 notifyNodeRemoved(node); | |
| 90 } | |
| 91 | |
| 92 namespace Private { | 30 namespace Private { |
| 93 | 31 |
| 94 template<class GenericNode, class GenericNodeContainer> | 32 template<class GenericNode, class GenericNodeContainer> |
| 95 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Ge
nericNodeContainer&); | 33 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Ge
nericNodeContainer&); |
| 96 | 34 |
| 97 } | 35 } |
| 98 | 36 |
| 99 #if !ENABLE(OILPAN) | 37 #if !ENABLE(OILPAN) |
| 100 // Helper functions for TreeShared-derived classes, which have a 'Node' style in
terface | 38 // Helper functions for TreeShared-derived classes, which have a 'Node' style in
terface |
| 101 // This applies to 'ContainerNode' and 'SVGElementInstance' | 39 // This applies to 'ContainerNode' and 'SVGElementInstance' |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // no-op, by default | 92 // no-op, by default |
| 155 } | 93 } |
| 156 }; | 94 }; |
| 157 | 95 |
| 158 template<class GenericNode, class GenericNodeContainer> | 96 template<class GenericNode, class GenericNodeContainer> |
| 159 struct NodeRemovalDispatcher<GenericNode, GenericNodeContainer, true> { | 97 struct NodeRemovalDispatcher<GenericNode, GenericNodeContainer, true> { |
| 160 static void dispatch(GenericNode& node, GenericNodeContainer& container) | 98 static void dispatch(GenericNode& node, GenericNodeContainer& container) |
| 161 { | 99 { |
| 162 container.document().adoptIfNeeded(node); | 100 container.document().adoptIfNeeded(node); |
| 163 if (node.inDocument()) | 101 if (node.inDocument()) |
| 164 ChildNodeRemovalNotifier(container).notify(node); | 102 container.notifyNodeRemoved(node); |
| 165 } | 103 } |
| 166 }; | 104 }; |
| 167 | 105 |
| 168 template<class GenericNode> | 106 template<class GenericNode> |
| 169 struct ShouldDispatchRemovalNotification { | 107 struct ShouldDispatchRemovalNotification { |
| 170 static const bool value = false; | 108 static const bool value = false; |
| 171 }; | 109 }; |
| 172 | 110 |
| 173 template<> | 111 template<> |
| 174 struct ShouldDispatchRemovalNotification<Node> { | 112 struct ShouldDispatchRemovalNotification<Node> { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 147 } |
| 210 | 148 |
| 211 container.setLastChild(0); | 149 container.setLastChild(0); |
| 212 } | 150 } |
| 213 | 151 |
| 214 } // namespace Private | 152 } // namespace Private |
| 215 | 153 |
| 216 } // namespace WebCore | 154 } // namespace WebCore |
| 217 | 155 |
| 218 #endif // ContainerNodeAlgorithms_h | 156 #endif // ContainerNodeAlgorithms_h |
| OLD | NEW |