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

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

Issue 54273007: Use more references in ContainerNode code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix crashes Created 7 years, 1 month 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
« no previous file with comments | « no previous file | Source/core/dom/ContainerNode.cpp » ('j') | Source/core/dom/Node.h » ('J')
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 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionState& = ASSERT_NO_EXCEPTION); 99 void insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionState& = ASSERT_NO_EXCEPTION);
100 void replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionState& = ASSERT_NO_EXCEPTION); 100 void replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionState& = ASSERT_NO_EXCEPTION);
101 void removeChild(Node* child, ExceptionState& = ASSERT_NO_EXCEPTION); 101 void removeChild(Node* child, ExceptionState& = ASSERT_NO_EXCEPTION);
102 void appendChild(PassRefPtr<Node> newChild, ExceptionState& = ASSERT_NO_EXCE PTION); 102 void appendChild(PassRefPtr<Node> newChild, ExceptionState& = ASSERT_NO_EXCE PTION);
103 103
104 // These methods are only used during parsing. 104 // These methods are only used during parsing.
105 // They don't send DOM mutation events or handle reparenting. 105 // They don't send DOM mutation events or handle reparenting.
106 // However, arbitrary code may be run by beforeload handlers. 106 // However, arbitrary code may be run by beforeload handlers.
107 void parserAppendChild(PassRefPtr<Node>); 107 void parserAppendChild(PassRefPtr<Node>);
108 void parserRemoveChild(Node&); 108 void parserRemoveChild(Node&);
109 void parserInsertBefore(PassRefPtr<Node> newChild, Node* refChild); 109 void parserInsertBefore(PassRefPtr<Node> newChild, Node& refChild);
110 void parserTakeAllChildrenFrom(ContainerNode*); 110 void parserTakeAllChildrenFrom(ContainerNode&);
111 111
112 void removeChildren(); 112 void removeChildren();
113 113
114 void cloneChildNodes(ContainerNode* clone); 114 void cloneChildNodes(ContainerNode* clone);
115 115
116 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; 116 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
117 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE; 117 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
118 virtual LayoutRect boundingBox() const OVERRIDE; 118 virtual LayoutRect boundingBox() const OVERRIDE;
119 virtual void setFocus(bool) OVERRIDE; 119 virtual void setFocus(bool) OVERRIDE;
120 virtual void setActive(bool active = true, bool pause = false) OVERRIDE; 120 virtual void setActive(bool active = true, bool pause = false) OVERRIDE;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 highest = node; 228 highest = node;
229 return highest; 229 return highest;
230 } 230 }
231 231
232 // This constant controls how much buffer is initially allocated 232 // This constant controls how much buffer is initially allocated
233 // for a Node Vector that is used to store child Nodes of a given Node. 233 // for a Node Vector that is used to store child Nodes of a given Node.
234 // FIXME: Optimize the value. 234 // FIXME: Optimize the value.
235 const int initialNodeVectorSize = 11; 235 const int initialNodeVectorSize = 11;
236 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector; 236 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector;
237 237
238 inline void getChildNodes(Node* node, NodeVector& nodes) 238 inline void getChildNodes(Node& node, NodeVector& nodes)
239 { 239 {
240 ASSERT(!nodes.size()); 240 ASSERT(!nodes.size());
241 for (Node* child = node->firstChild(); child; child = child->nextSibling()) 241 for (Node* child = node.firstChild(); child; child = child->nextSibling())
242 nodes.append(child); 242 nodes.append(child);
243 } 243 }
244 244
245 class ChildNodesLazySnapshot { 245 class ChildNodesLazySnapshot {
246 WTF_MAKE_NONCOPYABLE(ChildNodesLazySnapshot); 246 WTF_MAKE_NONCOPYABLE(ChildNodesLazySnapshot);
247 WTF_MAKE_FAST_ALLOCATED; 247 WTF_MAKE_FAST_ALLOCATED;
248 public: 248 public:
249 explicit ChildNodesLazySnapshot(Node& parentNode) 249 explicit ChildNodesLazySnapshot(Node& parentNode)
250 : m_currentNode(parentNode.firstChild()) 250 : m_currentNode(parentNode.firstChild())
251 , m_currentIndex(0) 251 , m_currentIndex(0)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 RefPtr<Node> m_currentNode; 304 RefPtr<Node> m_currentNode;
305 unsigned m_currentIndex; 305 unsigned m_currentIndex;
306 OwnPtr<Vector<RefPtr<Node> > > m_childNodes; // Lazily instantiated. 306 OwnPtr<Vector<RefPtr<Node> > > m_childNodes; // Lazily instantiated.
307 ChildNodesLazySnapshot* m_nextSnapshot; 307 ChildNodesLazySnapshot* m_nextSnapshot;
308 }; 308 };
309 309
310 } // namespace WebCore 310 } // namespace WebCore
311 311
312 #endif // ContainerNode_h 312 #endif // ContainerNode_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/ContainerNode.cpp » ('j') | Source/core/dom/Node.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698