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

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

Issue 49153006: Have ContainerNodeAlgorithms deal with references instead of pointers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/ContainerNode.cpp » ('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 19 matching lines...) Expand all
30 #include "wtf/Vector.h" 30 #include "wtf/Vector.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 class ExceptionState; 34 class ExceptionState;
35 class FloatPoint; 35 class FloatPoint;
36 class HTMLCollection; 36 class HTMLCollection;
37 37
38 namespace Private { 38 namespace Private {
39 template<class GenericNode, class GenericNodeContainer> 39 template<class GenericNode, class GenericNodeContainer>
40 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Ge nericNodeContainer*); 40 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, Ge nericNodeContainer&);
41 }; 41 }
42 42
43 class NoEventDispatchAssertion { 43 class NoEventDispatchAssertion {
44 public: 44 public:
45 NoEventDispatchAssertion() 45 NoEventDispatchAssertion()
46 { 46 {
47 #ifndef NDEBUG 47 #ifndef NDEBUG
48 if (!isMainThread()) 48 if (!isMainThread())
49 return; 49 return;
50 s_count++; 50 s_count++;
51 #endif 51 #endif
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
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;
121 virtual void setHovered(bool = true) OVERRIDE; 121 virtual void setHovered(bool = true) OVERRIDE;
122 122
123 // ------------------------------------------------------------------------- ---- 123 // ------------------------------------------------------------------------- ----
124 // Notification of document structure changes (see core/dom/Node.h for more notification methods) 124 // Notification of document structure changes (see core/dom/Node.h for more notification methods)
125 125
126 // Notifies the node that it's list of children have changed (either by addi ng or removing child nodes), or a child 126 // Notifies the node that it's list of children have changed (either by addi ng or removing child nodes), or a child
127 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha s changed its value. 127 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha s changed its value.
128 virtual void childrenChanged(bool createdByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0); 128 virtual void childrenChanged(bool createdByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0);
129 129
130 void disconnectDescendantFrames(); 130 void disconnectDescendantFrames();
131 131
132 virtual bool childShouldCreateRenderer(const Node& child) const { return tru e; } 132 virtual bool childShouldCreateRenderer(const Node& child) const { return tru e; }
133 133
134 protected: 134 protected:
135 ContainerNode(TreeScope*, ConstructionType = CreateContainer); 135 ContainerNode(TreeScope*, ConstructionType = CreateContainer);
136 136
137 template<class GenericNode, class GenericNodeContainer> 137 template<class GenericNode, class GenericNodeContainer>
138 friend void appendChildToContainer(GenericNode* child, GenericNodeContainer* ); 138 friend void appendChildToContainer(GenericNode& child, GenericNodeContainer& );
139 139
140 template<class GenericNode, class GenericNodeContainer> 140 template<class GenericNode, class GenericNodeContainer>
141 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi cNode*& tail, GenericNodeContainer*); 141 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi cNode*& tail, GenericNodeContainer&);
142 142
143 void removeDetachedChildren(); 143 void removeDetachedChildren();
144 void setFirstChild(Node* child) { m_firstChild = child; } 144 void setFirstChild(Node* child) { m_firstChild = child; }
145 void setLastChild(Node* child) { m_lastChild = child; } 145 void setLastChild(Node* child) { m_lastChild = child; }
146 146
147 private: 147 private:
148 void removeBetween(Node* previousChild, Node* nextChild, Node* oldChild); 148 void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild);
149 void insertBeforeCommon(Node* nextChild, Node* oldChild); 149 void insertBeforeCommon(Node& nextChild, Node& oldChild);
150 150
151 void attachChildren(const AttachContext& = AttachContext()); 151 void attachChildren(const AttachContext& = AttachContext());
152 void detachChildren(const AttachContext& = AttachContext()); 152 void detachChildren(const AttachContext& = AttachContext());
153 153
154 bool getUpperLeftCorner(FloatPoint&) const; 154 bool getUpperLeftCorner(FloatPoint&) const;
155 bool getLowerRightCorner(FloatPoint&) const; 155 bool getLowerRightCorner(FloatPoint&) const;
156 156
157 Node* m_firstChild; 157 Node* m_firstChild;
158 Node* m_lastChild; 158 Node* m_lastChild;
159 }; 159 };
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
252 { 252 {
253 m_nextSnapshot = latestSnapshot; 253 m_nextSnapshot = latestSnapshot;
254 latestSnapshot = this; 254 latestSnapshot = this;
255 } 255 }
256 256
257 ~ChildNodesLazySnapshot() 257 ~ChildNodesLazySnapshot()
258 { 258 {
259 latestSnapshot = m_nextSnapshot; 259 latestSnapshot = m_nextSnapshot;
260 } 260 }
(...skipping 42 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/ContainerNode.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698