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

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

Issue 16951003: Fix broken AttachContext from r152289 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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
« no previous file with comments | « no previous file | Source/core/dom/ContainerNode.cpp » ('j') | Source/core/dom/Element.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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 attachChildren(); 130 void attachChildren(const AttachContext& = AttachContext());
131 void attachChildrenLazily(); 131 void attachChildrenLazily();
132 void detachChildren(); 132 void detachChildren(const AttachContext& = AttachContext());
133 void detachChildrenIfNeeded(); 133 void detachChildrenIfNeeded(const AttachContext& = AttachContext());
134 134
135 void disconnectDescendantFrames(); 135 void disconnectDescendantFrames();
136 136
137 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const { return true; } 137 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const { return true; }
138 138
139 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; 139 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
140 140
141 protected: 141 protected:
142 ContainerNode(TreeScope*, ConstructionType = CreateContainer); 142 ContainerNode(TreeScope*, ConstructionType = CreateContainer);
143 143
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // This will catch anyone doing an unnecessary cast. 189 // This will catch anyone doing an unnecessary cast.
190 void toContainerNode(const ContainerNode*); 190 void toContainerNode(const ContainerNode*);
191 191
192 inline ContainerNode::ContainerNode(TreeScope* treeScope, ConstructionType type) 192 inline ContainerNode::ContainerNode(TreeScope* treeScope, ConstructionType type)
193 : Node(treeScope, type) 193 : Node(treeScope, type)
194 , m_firstChild(0) 194 , m_firstChild(0)
195 , m_lastChild(0) 195 , m_lastChild(0)
196 { 196 {
197 } 197 }
198 198
199 inline void ContainerNode::attachChildren() 199 inline void ContainerNode::attachChildren(const AttachContext& context)
200 { 200 {
201 // the resolved style need not be passed to the children, as it represents o nly the parent's style
202 AttachContext childrenContext(context);
203 childrenContext.resolvedStyle = 0;
esprehn 2013/06/13 18:20:42 You should put this inside the constructor to just
stavila 2013/06/13 21:10:06 You mean the copy constructor should set by defaul
204
201 for (Node* child = firstChild(); child; child = child->nextSibling()) { 205 for (Node* child = firstChild(); child; child = child->nextSibling()) {
202 ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(t his)); 206 ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(t his));
203 if (!child->attached()) 207 if (!child->attached())
204 child->attach(); 208 child->attach(childrenContext);
205 } 209 }
206 } 210 }
207 211
208 inline void ContainerNode::attachChildrenLazily() 212 inline void ContainerNode::attachChildrenLazily()
209 { 213 {
210 for (Node* child = firstChild(); child; child = child->nextSibling()) 214 for (Node* child = firstChild(); child; child = child->nextSibling())
211 if (!child->attached()) 215 if (!child->attached())
212 child->lazyAttach(); 216 child->lazyAttach();
213 } 217 }
214 218
215 inline void ContainerNode::detachChildrenIfNeeded() 219 inline void ContainerNode::detachChildrenIfNeeded(const AttachContext& context)
216 { 220 {
221 // the resolved style need not be passed to the children, as it represents o nly the parent's style
222 AttachContext childrenContext(context);
223 childrenContext.resolvedStyle = 0;
224
217 for (Node* child = firstChild(); child; child = child->nextSibling()) { 225 for (Node* child = firstChild(); child; child = child->nextSibling()) {
218 if (child->attached()) 226 if (child->attached())
219 child->detach(); 227 child->detach(childrenContext);
220 } 228 }
221 } 229 }
222 230
223 inline void ContainerNode::detachChildren() 231 inline void ContainerNode::detachChildren(const AttachContext& context)
224 { 232 {
233 // the resolved style need not be passed to the children, as it represents o nly the parent's style
234 AttachContext childrenContext(context);
esprehn 2013/06/13 18:20:42 Please remove all the comments here, this should b
235 childrenContext.resolvedStyle = 0;
236
225 for (Node* child = firstChild(); child; child = child->nextSibling()) 237 for (Node* child = firstChild(); child; child = child->nextSibling())
226 child->detach(); 238 child->detach(childrenContext);
227 } 239 }
228 240
229 inline unsigned Node::childNodeCount() const 241 inline unsigned Node::childNodeCount() const
230 { 242 {
231 if (!isContainerNode()) 243 if (!isContainerNode())
232 return 0; 244 return 0;
233 return toContainerNode(this)->childNodeCount(); 245 return toContainerNode(this)->childNodeCount();
234 } 246 }
235 247
236 inline Node* Node::childNode(unsigned index) const 248 inline Node* Node::childNode(unsigned index) const
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 m_node->resumePostAttachCallbacks(); 375 m_node->resumePostAttachCallbacks();
364 } 376 }
365 377
366 private: 378 private:
367 ContainerNode* m_node; 379 ContainerNode* m_node;
368 }; 380 };
369 381
370 } // namespace WebCore 382 } // namespace WebCore
371 383
372 #endif // ContainerNode_h 384 #endif // ContainerNode_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/ContainerNode.cpp » ('j') | Source/core/dom/Element.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698