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

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

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include "config.h"
28 #include "core/rendering/RenderObjectChildList.h"
29
30 #include "core/dom/AXObjectCache.h"
31 #include "core/layout/Layer.h"
32 #include "core/layout/LayoutCounter.h"
33 #include "core/rendering/RenderObject.h"
34 #include "core/rendering/RenderView.h"
35 #include "core/rendering/style/RenderStyle.h"
36
37 namespace blink {
38
39 void RenderObjectChildList::destroyLeftoverChildren()
40 {
41 while (firstChild()) {
42 // List markers are owned by their enclosing list and so don't get destr oyed by this container.
43 if (firstChild()->isListMarker()) {
44 firstChild()->remove();
45 continue;
46 }
47
48 // Destroy any anonymous children remaining in the render tree, as well as implicit (shadow) DOM elements like those used in the engine-based text field s.
49 if (firstChild()->node())
50 firstChild()->node()->setRenderer(0);
51 firstChild()->destroy();
52 }
53 }
54
55 RenderObject* RenderObjectChildList::removeChildNode(RenderObject* owner, Render Object* oldChild, bool notifyRenderer)
56 {
57 ASSERT(oldChild->parent() == owner);
58 ASSERT(this == owner->virtualChildren());
59
60 if (oldChild->isFloatingOrOutOfFlowPositioned())
61 toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists();
62
63 {
64 // FIXME: We should not be allowing paint invalidation during layout. cr bug.com/336250
65 AllowPaintInvalidationScope scoper(owner->frameView());
66
67 // So that we'll get the appropriate dirty bit set (either that a normal flow child got yanked or
68 // that a positioned child got yanked). We also issue paint invalidation s, so that the area exposed when the child
69 // disappears gets paint invalidated properly.
70 if (!owner->documentBeingDestroyed() && notifyRenderer && oldChild->ever HadLayout()) {
71 oldChild->setNeedsLayoutAndPrefWidthsRecalc();
72 invalidatePaintOnRemoval(*oldChild);
73 }
74 }
75
76 // If we have a line box wrapper, delete it.
77 if (oldChild->isBox())
78 toRenderBox(oldChild)->deleteLineBoxWrapper();
79
80 // If oldChild is the start or end of the selection, then clear the selectio n to
81 // avoid problems of invalid pointers.
82 // FIXME: The FrameSelection should be responsible for this when it
83 // is notified of DOM mutations.
84 if (!owner->documentBeingDestroyed() && oldChild->isSelectionBorder())
85 owner->view()->clearSelection();
86
87 if (!owner->documentBeingDestroyed() && notifyRenderer)
88 oldChild->willBeRemovedFromTree();
89
90 // WARNING: There should be no code running between willBeRemovedFromTree an d the actual removal below.
91 // This is needed to avoid race conditions where willBeRemovedFromTree would dirty the tree's structure
92 // and the code running here would force an untimely rebuilding, leaving |ol dChild| dangling.
93
94 if (oldChild->previousSibling())
95 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
96 if (oldChild->nextSibling())
97 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling()) ;
98
99 if (firstChild() == oldChild)
100 setFirstChild(oldChild->nextSibling());
101 if (lastChild() == oldChild)
102 setLastChild(oldChild->previousSibling());
103
104 oldChild->setPreviousSibling(0);
105 oldChild->setNextSibling(0);
106 oldChild->setParent(0);
107
108 // rendererRemovedFromTree walks the whole subtree. We can improve performan ce
109 // by skipping this step when destroying the entire tree.
110 if (!owner->documentBeingDestroyed())
111 LayoutCounter::rendererRemovedFromTree(oldChild);
112
113 if (AXObjectCache* cache = owner->document().existingAXObjectCache())
114 cache->childrenChanged(owner);
115
116 return oldChild;
117 }
118
119 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* n ewChild, RenderObject* beforeChild, bool notifyRenderer)
120 {
121 ASSERT(!newChild->parent());
122 ASSERT(this == owner->virtualChildren());
123 ASSERT(!owner->isRenderBlockFlow() || (!newChild->isTableSection() && !newCh ild->isTableRow() && !newChild->isTableCell()));
124
125 while (beforeChild && beforeChild->parent() && beforeChild->parent() != owne r)
126 beforeChild = beforeChild->parent();
127
128 // This should never happen, but if it does prevent render tree corruption
129 // where child->parent() ends up being owner but child->nextSibling()->paren t()
130 // is not owner.
131 if (beforeChild && beforeChild->parent() != owner) {
132 ASSERT_NOT_REACHED();
133 return;
134 }
135
136 newChild->setParent(owner);
137
138 if (firstChild() == beforeChild)
139 setFirstChild(newChild);
140
141 if (beforeChild) {
142 RenderObject* previousSibling = beforeChild->previousSibling();
143 if (previousSibling)
144 previousSibling->setNextSibling(newChild);
145 newChild->setPreviousSibling(previousSibling);
146 newChild->setNextSibling(beforeChild);
147 beforeChild->setPreviousSibling(newChild);
148 } else {
149 if (lastChild())
150 lastChild()->setNextSibling(newChild);
151 newChild->setPreviousSibling(lastChild());
152 setLastChild(newChild);
153 }
154
155 if (!owner->documentBeingDestroyed() && notifyRenderer)
156 newChild->insertedIntoTree();
157
158 if (!owner->documentBeingDestroyed()) {
159 LayoutCounter::rendererSubtreeAttached(newChild);
160 }
161
162 newChild->setNeedsLayoutAndPrefWidthsRecalc();
163 newChild->setShouldDoFullPaintInvalidation(PaintInvalidationRendererInsertio n);
164 if (!owner->normalChildNeedsLayout())
165 owner->setChildNeedsLayout(); // We may supply the static position for a n absolute positioned child.
166
167 if (AXObjectCache* cache = owner->document().axObjectCache())
168 cache->childrenChanged(owner);
169 }
170
171 void RenderObjectChildList::invalidatePaintOnRemoval(const RenderObject& oldChil d)
172 {
173 if (!oldChild.isRooted())
174 return;
175 if (oldChild.isBody()) {
176 oldChild.view()->setShouldDoFullPaintInvalidation();
177 return;
178 }
179 DisableCompositingQueryAsserts disabler;
180 oldChild.invalidatePaintUsingContainer(oldChild.containerForPaintInvalidatio n(), oldChild.previousPaintInvalidationRect(), PaintInvalidationRendererRemoval) ;
181 }
182
183 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObjectChildList.h ('k') | Source/core/rendering/RenderObjectInlines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698