OLD | NEW |
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, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 ChildrenAffectedByFirstChildRules = 1 << 4, | 106 ChildrenAffectedByFirstChildRules = 1 << 4, |
107 ChildrenAffectedByLastChildRules = 1 << 5, | 107 ChildrenAffectedByLastChildRules = 1 << 5, |
108 ChildrenAffectedByDirectAdjacentRules = 1 << 6, | 108 ChildrenAffectedByDirectAdjacentRules = 1 << 6, |
109 ChildrenAffectedByIndirectAdjacentRules = 1 << 7, | 109 ChildrenAffectedByIndirectAdjacentRules = 1 << 7, |
110 ChildrenAffectedByForwardPositionalRules = 1 << 8, | 110 ChildrenAffectedByForwardPositionalRules = 1 << 8, |
111 ChildrenAffectedByBackwardPositionalRules = 1 << 9, | 111 ChildrenAffectedByBackwardPositionalRules = 1 << 9, |
112 | 112 |
113 NumberOfDynamicRestyleFlags = 10, | 113 NumberOfDynamicRestyleFlags = 10, |
114 }; | 114 }; |
115 | 115 |
| 116 // This constant controls how much buffer is initially allocated |
| 117 // for a Node Vector that is used to store child Nodes of a given Node. |
| 118 // FIXME: Optimize the value. |
| 119 const int initialNodeVectorSize = 11; |
| 120 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector; |
| 121 |
116 class ContainerNode : public Node { | 122 class ContainerNode : public Node { |
117 public: | 123 public: |
118 virtual ~ContainerNode(); | 124 virtual ~ContainerNode(); |
119 | 125 |
120 Node* firstChild() const { return m_firstChild; } | 126 Node* firstChild() const { return m_firstChild; } |
121 Node* lastChild() const { return m_lastChild; } | 127 Node* lastChild() const { return m_lastChild; } |
122 bool hasChildren() const { return m_firstChild; } | 128 bool hasChildren() const { return m_firstChild; } |
123 | 129 |
124 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling
(); } | 130 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling
(); } |
125 bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextN
ode(); } | 131 bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextN
ode(); } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Notification of document structure changes (see core/dom/Node.h for more
notification methods) | 213 // Notification of document structure changes (see core/dom/Node.h for more
notification methods) |
208 | 214 |
209 // Notifies the node that it's list of children have changed (either by addi
ng or removing child nodes), or a child | 215 // Notifies the node that it's list of children have changed (either by addi
ng or removing child nodes), or a child |
210 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha
s changed its value. | 216 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha
s changed its value. |
211 virtual void childrenChanged(bool createdByParser = false, Node* beforeChang
e = 0, Node* afterChange = 0, int childCountDelta = 0); | 217 virtual void childrenChanged(bool createdByParser = false, Node* beforeChang
e = 0, Node* afterChange = 0, int childCountDelta = 0); |
212 | 218 |
213 void disconnectDescendantFrames(); | 219 void disconnectDescendantFrames(); |
214 | 220 |
215 virtual void trace(Visitor*) OVERRIDE; | 221 virtual void trace(Visitor*) OVERRIDE; |
216 | 222 |
| 223 void notifyNodeInserted(Node&); |
| 224 void notifyNodeRemoved(Node&); |
| 225 |
217 protected: | 226 protected: |
218 ContainerNode(TreeScope*, ConstructionType = CreateContainer); | 227 ContainerNode(TreeScope*, ConstructionType = CreateContainer); |
219 | 228 |
220 template<class GenericNode, class GenericNodeContainer> | 229 template<class GenericNode, class GenericNodeContainer> |
221 friend void appendChildToContainer(GenericNode& child, GenericNodeContainer&
); | 230 friend void appendChildToContainer(GenericNode& child, GenericNodeContainer&
); |
222 | 231 |
223 template<class GenericNode, class GenericNodeContainer> | 232 template<class GenericNode, class GenericNodeContainer> |
224 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi
cNode*& tail, GenericNodeContainer&); | 233 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi
cNode*& tail, GenericNodeContainer&); |
225 | 234 |
226 #if !ENABLE(OILPAN) | 235 #if !ENABLE(OILPAN) |
227 void removeDetachedChildren(); | 236 void removeDetachedChildren(); |
228 #endif | 237 #endif |
229 | 238 |
230 void setFirstChild(Node* child) { m_firstChild = child; } | 239 void setFirstChild(Node* child) { m_firstChild = child; } |
231 void setLastChild(Node* child) { m_lastChild = child; } | 240 void setLastChild(Node* child) { m_lastChild = child; } |
232 | 241 |
233 private: | 242 private: |
234 void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild); | 243 void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild); |
235 void insertBeforeCommon(Node& nextChild, Node& oldChild); | 244 void insertBeforeCommon(Node& nextChild, Node& oldChild); |
236 void updateTreeAfterInsertion(Node& child); | 245 void updateTreeAfterInsertion(Node& child); |
237 void willRemoveChildren(); | 246 void willRemoveChildren(); |
238 void willRemoveChild(Node& child); | 247 void willRemoveChild(Node& child); |
239 | 248 |
| 249 void notifyNodeInsertedInternal(Node&, NodeVector& postInsertionNotification
Targets); |
| 250 |
240 bool hasRestyleFlag(DynamicRestyleFlags mask) const { return hasRareData() &
& hasRestyleFlagInternal(mask); } | 251 bool hasRestyleFlag(DynamicRestyleFlags mask) const { return hasRareData() &
& hasRestyleFlagInternal(mask); } |
241 bool hasRestyleFlags() const { return hasRareData() && hasRestyleFlagsIntern
al(); } | 252 bool hasRestyleFlags() const { return hasRareData() && hasRestyleFlagsIntern
al(); } |
242 void setRestyleFlag(DynamicRestyleFlags); | 253 void setRestyleFlag(DynamicRestyleFlags); |
243 bool hasRestyleFlagInternal(DynamicRestyleFlags) const; | 254 bool hasRestyleFlagInternal(DynamicRestyleFlags) const; |
244 bool hasRestyleFlagsInternal() const; | 255 bool hasRestyleFlagsInternal() const; |
245 | 256 |
246 inline bool checkAcceptChildGuaranteedNodeTypes(const Node& newChild, Except
ionState&) const; | 257 inline bool checkAcceptChildGuaranteedNodeTypes(const Node& newChild, Except
ionState&) const; |
247 inline bool checkAcceptChild(const Node* newChild, const Node* oldChild, Exc
eptionState&) const; | 258 inline bool checkAcceptChild(const Node* newChild, const Node* oldChild, Exc
eptionState&) const; |
248 inline bool containsConsideringHostElements(const Node&) const; | 259 inline bool containsConsideringHostElements(const Node&) const; |
249 inline bool isChildTypeAllowed(const Node& child) const; | 260 inline bool isChildTypeAllowed(const Node& child) const; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 ContainerNode* parent = parentNode(); | 355 ContainerNode* parent = parentNode(); |
345 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren
t : 0; | 356 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren
t : 0; |
346 } | 357 } |
347 | 358 |
348 inline ContainerNode* Node::parentElementOrDocumentFragment() const | 359 inline ContainerNode* Node::parentElementOrDocumentFragment() const |
349 { | 360 { |
350 ContainerNode* parent = parentNode(); | 361 ContainerNode* parent = parentNode(); |
351 return parent && (parent->isElementNode() || parent->isDocumentFragment()) ?
parent : 0; | 362 return parent && (parent->isElementNode() || parent->isDocumentFragment()) ?
parent : 0; |
352 } | 363 } |
353 | 364 |
354 // This constant controls how much buffer is initially allocated | |
355 // for a Node Vector that is used to store child Nodes of a given Node. | |
356 // FIXME: Optimize the value. | |
357 const int initialNodeVectorSize = 11; | |
358 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector; | |
359 | |
360 inline void getChildNodes(Node& node, NodeVector& nodes) | 365 inline void getChildNodes(Node& node, NodeVector& nodes) |
361 { | 366 { |
362 ASSERT(!nodes.size()); | 367 ASSERT(!nodes.size()); |
363 for (Node* child = node.firstChild(); child; child = child->nextSibling()) | 368 for (Node* child = node.firstChild(); child; child = child->nextSibling()) |
364 nodes.append(child); | 369 nodes.append(child); |
365 } | 370 } |
366 | 371 |
367 } // namespace WebCore | 372 } // namespace WebCore |
368 | 373 |
369 #endif // ContainerNode_h | 374 #endif // ContainerNode_h |
OLD | NEW |