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

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

Issue 674553002: Move parts of core/dom to C++11 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make Windows shut up when I just try following the style guide Created 6 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/AttributeCollection.h ('k') | Source/core/dom/ContainerNode.cpp » ('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, 2009, 2010, 2011, 2013 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All r ights 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 19 matching lines...) Expand all
30 #include "wtf/OwnPtr.h" 30 #include "wtf/OwnPtr.h"
31 #include "wtf/Vector.h" 31 #include "wtf/Vector.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 class ClassCollection; 35 class ClassCollection;
36 class ExceptionState; 36 class ExceptionState;
37 class FloatPoint; 37 class FloatPoint;
38 class HTMLCollection; 38 class HTMLCollection;
39 template <typename NodeType> class StaticNodeTypeList; 39 template <typename NodeType> class StaticNodeTypeList;
40 typedef StaticNodeTypeList<Element> StaticElementList; 40 using StaticElementList = StaticNodeTypeList<Element>;
41 class TagCollection; 41 class TagCollection;
42 42
43 enum DynamicRestyleFlags { 43 enum DynamicRestyleFlags {
44 ChildrenOrSiblingsAffectedByFocus = 1 << 0, 44 ChildrenOrSiblingsAffectedByFocus = 1 << 0,
45 ChildrenOrSiblingsAffectedByHover = 1 << 1, 45 ChildrenOrSiblingsAffectedByHover = 1 << 1,
46 ChildrenOrSiblingsAffectedByActive = 1 << 2, 46 ChildrenOrSiblingsAffectedByActive = 1 << 2,
47 ChildrenOrSiblingsAffectedByDrag = 1 << 3, 47 ChildrenOrSiblingsAffectedByDrag = 1 << 3,
48 ChildrenAffectedByFirstChildRules = 1 << 4, 48 ChildrenAffectedByFirstChildRules = 1 << 4,
49 ChildrenAffectedByLastChildRules = 1 << 5, 49 ChildrenAffectedByLastChildRules = 1 << 5,
50 ChildrenAffectedByDirectAdjacentRules = 1 << 6, 50 ChildrenAffectedByDirectAdjacentRules = 1 << 6,
51 ChildrenAffectedByIndirectAdjacentRules = 1 << 7, 51 ChildrenAffectedByIndirectAdjacentRules = 1 << 7,
52 ChildrenAffectedByForwardPositionalRules = 1 << 8, 52 ChildrenAffectedByForwardPositionalRules = 1 << 8,
53 ChildrenAffectedByBackwardPositionalRules = 1 << 9, 53 ChildrenAffectedByBackwardPositionalRules = 1 << 9,
54 54
55 NumberOfDynamicRestyleFlags = 10, 55 NumberOfDynamicRestyleFlags = 10,
56 }; 56 };
57 57
58 // This constant controls how much buffer is initially allocated 58 // This constant controls how much buffer is initially allocated
59 // for a Node Vector that is used to store child Nodes of a given Node. 59 // for a Node Vector that is used to store child Nodes of a given Node.
60 // FIXME: Optimize the value. 60 // FIXME: Optimize the value.
61 const int initialNodeVectorSize = 11; 61 const int initialNodeVectorSize = 11;
62 typedef WillBeHeapVector<RefPtrWillBeMember<Node>, initialNodeVectorSize> NodeVe ctor; 62 using NodeVector = WillBeHeapVector<RefPtrWillBeMember<Node>, initialNodeVectorS ize>;
63 63
64 class ContainerNode : public Node { 64 class ContainerNode : public Node {
65 public: 65 public:
66 virtual ~ContainerNode(); 66 virtual ~ContainerNode();
67 67
68 Node* firstChild() const { return m_firstChild; } 68 Node* firstChild() const { return m_firstChild; }
69 Node* lastChild() const { return m_lastChild; } 69 Node* lastChild() const { return m_lastChild; }
70 bool hasChildren() const { return m_firstChild; } 70 bool hasChildren() const { return m_firstChild; }
71 71
72 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling (); } 72 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling (); }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha s changed its value. 196 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha s changed its value.
197 virtual void childrenChanged(const ChildrenChange&); 197 virtual void childrenChanged(const ChildrenChange&);
198 198
199 void disconnectDescendantFrames(); 199 void disconnectDescendantFrames();
200 200
201 virtual void trace(Visitor*) override; 201 virtual void trace(Visitor*) override;
202 202
203 protected: 203 protected:
204 ContainerNode(TreeScope*, ConstructionType = CreateContainer); 204 ContainerNode(TreeScope*, ConstructionType = CreateContainer);
205 205
206 void invalidateNodeListCachesInAncestors(const QualifiedName* attrName = 0, Element* attributeOwnerElement = 0); 206 void invalidateNodeListCachesInAncestors(const QualifiedName* attrName = nul lptr, Element* attributeOwnerElement = nullptr);
207 207
208 #if !ENABLE(OILPAN) 208 #if !ENABLE(OILPAN)
209 void removeDetachedChildren(); 209 void removeDetachedChildren();
210 #endif 210 #endif
211 211
212 void setFirstChild(Node* child) { m_firstChild = child; } 212 void setFirstChild(Node* child) { m_firstChild = child; }
213 void setLastChild(Node* child) { m_lastChild = child; } 213 void setLastChild(Node* child) { m_lastChild = child; }
214 214
215 // Utility functions for NodeListsNodeData API. 215 // Utility functions for NodeListsNodeData API.
216 template <typename Collection> PassRefPtrWillBeRawPtr<Collection> ensureCach edCollection(CollectionType); 216 template <typename Collection> PassRefPtrWillBeRawPtr<Collection> ensureCach edCollection(CollectionType);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 inline ContainerNode::ContainerNode(TreeScope* treeScope, ConstructionType type) 276 inline ContainerNode::ContainerNode(TreeScope* treeScope, ConstructionType type)
277 : Node(treeScope, type) 277 : Node(treeScope, type)
278 , m_firstChild(nullptr) 278 , m_firstChild(nullptr)
279 , m_lastChild(nullptr) 279 , m_lastChild(nullptr)
280 { 280 {
281 } 281 }
282 282
283 inline void ContainerNode::attachChildren(const AttachContext& context) 283 inline void ContainerNode::attachChildren(const AttachContext& context)
284 { 284 {
285 AttachContext childrenContext(context); 285 AttachContext childrenContext(context);
286 childrenContext.resolvedStyle = 0; 286 childrenContext.resolvedStyle = nullptr;
287 287
288 for (Node* child = firstChild(); child; child = child->nextSibling()) { 288 for (Node* child = firstChild(); child; child = child->nextSibling()) {
289 ASSERT(child->needsAttach() || childAttachedAllowedWhenAttachingChildren (this)); 289 ASSERT(child->needsAttach() || childAttachedAllowedWhenAttachingChildren (this));
290 if (child->needsAttach()) 290 if (child->needsAttach())
291 child->attach(childrenContext); 291 child->attach(childrenContext);
292 } 292 }
293 } 293 }
294 294
295 inline void ContainerNode::detachChildren(const AttachContext& context) 295 inline void ContainerNode::detachChildren(const AttachContext& context)
296 { 296 {
297 AttachContext childrenContext(context); 297 AttachContext childrenContext(context);
298 childrenContext.resolvedStyle = 0; 298 childrenContext.resolvedStyle = nullptr;
299 299
300 for (Node* child = firstChild(); child; child = child->nextSibling()) 300 for (Node* child = firstChild(); child; child = child->nextSibling())
301 child->detach(childrenContext); 301 child->detach(childrenContext);
302 } 302 }
303 303
304 inline unsigned Node::countChildren() const 304 inline unsigned Node::countChildren() const
305 { 305 {
306 if (!isContainerNode()) 306 if (!isContainerNode())
307 return 0; 307 return 0;
308 return toContainerNode(this)->countChildren(); 308 return toContainerNode(this)->countChildren();
309 } 309 }
310 310
311 inline Node* Node::firstChild() const 311 inline Node* Node::firstChild() const
312 { 312 {
313 if (!isContainerNode()) 313 if (!isContainerNode())
314 return 0; 314 return nullptr;
315 return toContainerNode(this)->firstChild(); 315 return toContainerNode(this)->firstChild();
316 } 316 }
317 317
318 inline Node* Node::lastChild() const 318 inline Node* Node::lastChild() const
319 { 319 {
320 if (!isContainerNode()) 320 if (!isContainerNode())
321 return 0; 321 return nullptr;
322 return toContainerNode(this)->lastChild(); 322 return toContainerNode(this)->lastChild();
323 } 323 }
324 324
325 inline ContainerNode* Node::parentElementOrShadowRoot() const 325 inline ContainerNode* Node::parentElementOrShadowRoot() const
326 { 326 {
327 ContainerNode* parent = parentNode(); 327 ContainerNode* parent = parentNode();
328 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren t : 0; 328 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren t : nullptr;
329 } 329 }
330 330
331 inline ContainerNode* Node::parentElementOrDocumentFragment() const 331 inline ContainerNode* Node::parentElementOrDocumentFragment() const
332 { 332 {
333 ContainerNode* parent = parentNode(); 333 ContainerNode* parent = parentNode();
334 return parent && (parent->isElementNode() || parent->isDocumentFragment()) ? parent : 0; 334 return parent && (parent->isElementNode() || parent->isDocumentFragment()) ? parent : nullptr;
335 } 335 }
336 336
337 inline bool Node::isTreeScope() const 337 inline bool Node::isTreeScope() const
338 { 338 {
339 return &treeScope().rootNode() == this; 339 return &treeScope().rootNode() == this;
340 } 340 }
341 341
342 inline void getChildNodes(ContainerNode& node, NodeVector& nodes) 342 inline void getChildNodes(ContainerNode& node, NodeVector& nodes)
343 { 343 {
344 ASSERT(!nodes.size()); 344 ASSERT(!nodes.size());
345 for (Node* child = node.firstChild(); child; child = child->nextSibling()) 345 for (Node* child = node.firstChild(); child; child = child->nextSibling())
346 nodes.append(child); 346 nodes.append(child);
347 } 347 }
348 348
349 } // namespace blink 349 } // namespace blink
350 350
351 #endif // ContainerNode_h 351 #endif // ContainerNode_h
OLDNEW
« no previous file with comments | « Source/core/dom/AttributeCollection.h ('k') | Source/core/dom/ContainerNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698