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

Side by Side Diff: Source/WebCore/rendering/RenderObjectChildList.cpp

Issue 10914111: Merge 125737 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1229/
Patch Set: Created 8 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 firstChild()->destroy(); 56 firstChild()->destroy();
57 } else { 57 } else {
58 // Destroy any anonymous children remaining in the render tree, as w ell as implicit (shadow) DOM elements like those used in the engine-based text f ields. 58 // Destroy any anonymous children remaining in the render tree, as w ell as implicit (shadow) DOM elements like those used in the engine-based text f ields.
59 if (firstChild()->node()) 59 if (firstChild()->node())
60 firstChild()->node()->setRenderer(0); 60 firstChild()->node()->setRenderer(0);
61 firstChild()->destroy(); 61 firstChild()->destroy();
62 } 62 }
63 } 63 }
64 } 64 }
65 65
66 static RenderNamedFlowThread* renderNamedFlowThreadContainer(RenderObject* objec t)
67 {
68 while (object && object->isAnonymousBlock() && !object->isRenderNamedFlowThr ead())
69 object = object->parent();
70
71 return object && object->isRenderNamedFlowThread() ? toRenderNamedFlowThread (object) : 0;
72 }
73
74 RenderObject* RenderObjectChildList::removeChildNode(RenderObject* owner, Render Object* oldChild, bool fullRemove) 66 RenderObject* RenderObjectChildList::removeChildNode(RenderObject* owner, Render Object* oldChild, bool fullRemove)
75 { 67 {
76 ASSERT(oldChild->parent() == owner); 68 ASSERT(oldChild->parent() == owner);
77 69
78 if (oldChild->isFloatingOrOutOfFlowPositioned()) 70 if (oldChild->isFloatingOrOutOfFlowPositioned())
79 toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists(); 71 toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists();
80 72
81 // So that we'll get the appropriate dirty bit set (either that a normal flo w child got yanked or 73 // So that we'll get the appropriate dirty bit set (either that a normal flo w child got yanked or
82 // that a positioned child got yanked). We also repaint, so that the area e xposed when the child 74 // that a positioned child got yanked). We also repaint, so that the area e xposed when the child
83 // disappears gets repainted properly. 75 // disappears gets repainted properly.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 111
120 if (oldChild->isQuote()) 112 if (oldChild->isQuote())
121 toRenderQuote(oldChild)->detachQuote(); 113 toRenderQuote(oldChild)->detachQuote();
122 114
123 if (oldChild->inRenderFlowThread()) { 115 if (oldChild->inRenderFlowThread()) {
124 if (oldChild->isBox()) 116 if (oldChild->isBox())
125 oldChild->enclosingRenderFlowThread()->removeRenderBoxRegionInfo (toRenderBox(oldChild)); 117 oldChild->enclosingRenderFlowThread()->removeRenderBoxRegionInfo (toRenderBox(oldChild));
126 oldChild->enclosingRenderFlowThread()->clearRenderObjectCustomStyle( oldChild); 118 oldChild->enclosingRenderFlowThread()->clearRenderObjectCustomStyle( oldChild);
127 } 119 }
128 120
129 if (RenderNamedFlowThread* containerFlowThread = renderNamedFlowThreadCo ntainer(owner)) 121 if (RenderNamedFlowThread* containerFlowThread = owner->enclosingRenderN amedFlowThread())
130 containerFlowThread->removeFlowChild(oldChild); 122 containerFlowThread->removeFlowChild(oldChild);
131 123
132 #if ENABLE(SVG) 124 #if ENABLE(SVG)
133 // Update cached boundaries in SVG renderers, if a child is removed. 125 // Update cached boundaries in SVG renderers, if a child is removed.
134 owner->setNeedsBoundariesUpdate(); 126 owner->setNeedsBoundariesUpdate();
135 #endif 127 #endif
136 } 128 }
137 129
138 // If oldChild is the start or end of the selection, then clear the selectio n to 130 // If oldChild is the start or end of the selection, then clear the selectio n to
139 // avoid problems of invalid pointers. 131 // avoid problems of invalid pointers.
(...skipping 22 matching lines...) Expand all
162 if (!owner->documentBeingDestroyed()) { 154 if (!owner->documentBeingDestroyed()) {
163 RenderCounter::rendererRemovedFromTree(oldChild); 155 RenderCounter::rendererRemovedFromTree(oldChild);
164 } 156 }
165 157
166 if (AXObjectCache::accessibilityEnabled()) 158 if (AXObjectCache::accessibilityEnabled())
167 owner->document()->axObjectCache()->childrenChanged(owner); 159 owner->document()->axObjectCache()->childrenChanged(owner);
168 160
169 return oldChild; 161 return oldChild;
170 } 162 }
171 163
172 void RenderObjectChildList::appendChildNode(RenderObject* owner, RenderObject* n ewChild, bool fullAppend) 164 void RenderObjectChildList::appendChildNode(RenderObject* owner, RenderObject* n ewChild, bool notifyRenderer)
173 { 165 {
174 ASSERT(newChild->parent() == 0); 166 ASSERT(newChild->parent() == 0);
175 ASSERT(!owner->isBlockFlow() || (!newChild->isTableSection() && !newChild->i sTableRow() && !newChild->isTableCell())); 167 ASSERT(!owner->isBlockFlow() || (!newChild->isTableSection() && !newChild->i sTableRow() && !newChild->isTableCell()));
176 168
177 newChild->setParent(owner); 169 newChild->setParent(owner);
178 RenderObject* lChild = lastChild(); 170 RenderObject* lChild = lastChild();
179 171
180 if (lChild) { 172 if (lChild) {
181 newChild->setPreviousSibling(lChild); 173 newChild->setPreviousSibling(lChild);
182 lChild->setNextSibling(newChild); 174 lChild->setNextSibling(newChild);
183 } else 175 } else
184 setFirstChild(newChild); 176 setFirstChild(newChild);
185 177
186 setLastChild(newChild); 178 setLastChild(newChild);
187 179
188 if (fullAppend) { 180 if (notifyRenderer)
189 // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children 181 newChild->insertedIntoTree();
190 // and don't have a layer attached to ourselves.
191 RenderLayer* layer = 0;
192 if (newChild->firstChild() || newChild->hasLayer()) {
193 layer = owner->enclosingLayer();
194 newChild->addLayers(layer);
195 }
196
197 // if the new child is visible but this object was not, tell the layer i t has some visible content
198 // that needs to be drawn and layer visibility optimization can't be use d
199 if (owner->style()->visibility() != VISIBLE && newChild->style()->visibi lity() == VISIBLE && !newChild->hasLayer()) {
200 if (!layer)
201 layer = owner->enclosingLayer();
202 if (layer)
203 layer->setHasVisibleContent();
204 }
205
206 if (newChild->isListItem())
207 toRenderListItem(newChild)->updateListMarkerNumbers();
208
209 if (!newChild->isFloating() && owner->childrenInline())
210 owner->dirtyLinesFromChangedChild(newChild);
211
212 if (newChild->isRenderRegion())
213 toRenderRegion(newChild)->attachRegion();
214
215 // You can't attachQuote() otherwise the quote would be attached too ear ly
216 // and get the wrong depth since generated content is inserted into anon ymous
217 // renderers before going into the main render tree.
218
219 if (RenderNamedFlowThread* containerFlowThread = renderNamedFlowThreadCo ntainer(owner))
220 containerFlowThread->addFlowChild(newChild);
221 }
222 182
223 if (!owner->documentBeingDestroyed()) { 183 if (!owner->documentBeingDestroyed()) {
224 RenderCounter::rendererSubtreeAttached(newChild); 184 RenderCounter::rendererSubtreeAttached(newChild);
225 } 185 }
226 newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing blo ck hierarchy. 186 newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing blo ck hierarchy.
227 if (!owner->normalChildNeedsLayout()) 187 if (!owner->normalChildNeedsLayout())
228 owner->setChildNeedsLayout(true); // We may supply the static position f or an absolute positioned child. 188 owner->setChildNeedsLayout(true); // We may supply the static position f or an absolute positioned child.
229 189
230 if (AXObjectCache::accessibilityEnabled()) 190 if (AXObjectCache::accessibilityEnabled())
231 owner->document()->axObjectCache()->childrenChanged(owner); 191 owner->document()->axObjectCache()->childrenChanged(owner);
232 } 192 }
233 193
234 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c hild, RenderObject* beforeChild, bool fullInsert) 194 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c hild, RenderObject* beforeChild, bool notifyRenderer)
235 { 195 {
236 if (!beforeChild) { 196 if (!beforeChild) {
237 appendChildNode(owner, child, fullInsert); 197 appendChildNode(owner, child, notifyRenderer);
238 return; 198 return;
239 } 199 }
240 200
241 ASSERT(!child->parent()); 201 ASSERT(!child->parent());
242 while (beforeChild->parent() != owner && beforeChild->parent()->isAnonymousB lock()) 202 while (beforeChild->parent() != owner && beforeChild->parent()->isAnonymousB lock())
243 beforeChild = beforeChild->parent(); 203 beforeChild = beforeChild->parent();
244 ASSERT(beforeChild->parent() == owner); 204 ASSERT(beforeChild->parent() == owner);
245 205
246 ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTable Row() && !child->isTableCell())); 206 ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTable Row() && !child->isTableCell()));
247 207
248 if (beforeChild == firstChild()) 208 if (beforeChild == firstChild())
249 setFirstChild(child); 209 setFirstChild(child);
250 210
251 RenderObject* prev = beforeChild->previousSibling(); 211 RenderObject* prev = beforeChild->previousSibling();
252 child->setNextSibling(beforeChild); 212 child->setNextSibling(beforeChild);
253 beforeChild->setPreviousSibling(child); 213 beforeChild->setPreviousSibling(child);
254 if (prev) 214 if (prev)
255 prev->setNextSibling(child); 215 prev->setNextSibling(child);
256 child->setPreviousSibling(prev); 216 child->setPreviousSibling(prev);
257 217
258 child->setParent(owner); 218 child->setParent(owner);
259 219
260 if (fullInsert) { 220 if (notifyRenderer)
261 // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children 221 child->insertedIntoTree();
262 // and don't have a layer attached to ourselves.
263 RenderLayer* layer = 0;
264 if (child->firstChild() || child->hasLayer()) {
265 layer = owner->enclosingLayer();
266 child->addLayers(layer);
267 }
268
269 // if the new child is visible but this object was not, tell the layer i t has some visible content
270 // that needs to be drawn and layer visibility optimization can't be use d
271 if (owner->style()->visibility() != VISIBLE && child->style()->visibilit y() == VISIBLE && !child->hasLayer()) {
272 if (!layer)
273 layer = owner->enclosingLayer();
274 if (layer)
275 layer->setHasVisibleContent();
276 }
277
278 if (child->isListItem())
279 toRenderListItem(child)->updateListMarkerNumbers();
280
281 if (!child->isFloating() && owner->childrenInline())
282 owner->dirtyLinesFromChangedChild(child);
283
284 if (child->isRenderRegion())
285 toRenderRegion(child)->attachRegion();
286
287 // Calling attachQuote() here would be too early (before anonymous rende rers are inserted)
288 // see appendChild() for more explanation.
289
290 if (RenderNamedFlowThread* containerFlowThread = renderNamedFlowThreadCo ntainer(owner))
291 containerFlowThread->addFlowChild(child, beforeChild);
292 }
293 222
294 if (!owner->documentBeingDestroyed()) { 223 if (!owner->documentBeingDestroyed()) {
295 RenderCounter::rendererSubtreeAttached(child); 224 RenderCounter::rendererSubtreeAttached(child);
296 } 225 }
297 child->setNeedsLayoutAndPrefWidthsRecalc(); 226 child->setNeedsLayoutAndPrefWidthsRecalc();
298 if (!owner->normalChildNeedsLayout()) 227 if (!owner->normalChildNeedsLayout())
299 owner->setChildNeedsLayout(true); // We may supply the static position f or an absolute positioned child. 228 owner->setChildNeedsLayout(true); // We may supply the static position f or an absolute positioned child.
300 229
301 if (AXObjectCache::accessibilityEnabled()) 230 if (AXObjectCache::accessibilityEnabled())
302 owner->document()->axObjectCache()->childrenChanged(owner); 231 owner->document()->axObjectCache()->childrenChanged(owner);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (!generatedContentContainer) 506 if (!generatedContentContainer)
578 return; 507 return;
579 508
580 // Handle placement of run-ins. We do the run-in placement at the end since generatedContentContainer can get destroyed. 509 // Handle placement of run-ins. We do the run-in placement at the end since generatedContentContainer can get destroyed.
581 RenderObject* generatedContentContainerImmediateParent = generatedContentCon tainer->parent(); 510 RenderObject* generatedContentContainerImmediateParent = generatedContentCon tainer->parent();
582 if (generatedContentContainerImmediateParent->isRenderBlock()) 511 if (generatedContentContainerImmediateParent->isRenderBlock())
583 toRenderBlock(generatedContentContainerImmediateParent)->placeRunInIfNee ded(generatedContentContainer, PlaceGeneratedRunIn); 512 toRenderBlock(generatedContentContainerImmediateParent)->placeRunInIfNee ded(generatedContentContainer, PlaceGeneratedRunIn);
584 } 513 }
585 514
586 } // namespace WebCore 515 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/rendering/RenderObjectChildList.h ('k') | Source/WebCore/rendering/RenderQuote.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698