| OLD | NEW |
| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/rendering/RenderObjectChildList.h" | 28 #include "core/layout/LayoutObjectChildList.h" |
| 29 | 29 |
| 30 #include "core/dom/AXObjectCache.h" | 30 #include "core/dom/AXObjectCache.h" |
| 31 #include "core/layout/Layer.h" | 31 #include "core/layout/Layer.h" |
| 32 #include "core/layout/LayoutCounter.h" | 32 #include "core/layout/LayoutCounter.h" |
| 33 #include "core/rendering/RenderObject.h" | 33 #include "core/layout/LayoutObject.h" |
| 34 #include "core/rendering/RenderView.h" | 34 #include "core/rendering/RenderView.h" |
| 35 #include "core/rendering/style/RenderStyle.h" | 35 #include "core/rendering/style/RenderStyle.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 void RenderObjectChildList::destroyLeftoverChildren() | 39 void LayoutObjectChildList::destroyLeftoverChildren() |
| 40 { | 40 { |
| 41 while (firstChild()) { | 41 while (firstChild()) { |
| 42 // List markers are owned by their enclosing list and so don't get destr
oyed by this container. | 42 // List markers are owned by their enclosing list and so don't get destr
oyed by this container. |
| 43 if (firstChild()->isListMarker()) { | 43 if (firstChild()->isListMarker()) { |
| 44 firstChild()->remove(); | 44 firstChild()->remove(); |
| 45 continue; | 45 continue; |
| 46 } | 46 } |
| 47 | 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. | 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()) | 49 if (firstChild()->node()) |
| 50 firstChild()->node()->setRenderer(0); | 50 firstChild()->node()->setRenderer(0); |
| 51 firstChild()->destroy(); | 51 firstChild()->destroy(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 RenderObject* RenderObjectChildList::removeChildNode(RenderObject* owner, Render
Object* oldChild, bool notifyRenderer) | 55 LayoutObject* LayoutObjectChildList::removeChildNode(LayoutObject* owner, Layout
Object* oldChild, bool notifyRenderer) |
| 56 { | 56 { |
| 57 ASSERT(oldChild->parent() == owner); | 57 ASSERT(oldChild->parent() == owner); |
| 58 ASSERT(this == owner->virtualChildren()); | 58 ASSERT(this == owner->virtualChildren()); |
| 59 | 59 |
| 60 if (oldChild->isFloatingOrOutOfFlowPositioned()) | 60 if (oldChild->isFloatingOrOutOfFlowPositioned()) |
| 61 toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists(); | 61 toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists(); |
| 62 | 62 |
| 63 { | 63 { |
| 64 // FIXME: We should not be allowing paint invalidation during layout. cr
bug.com/336250 | 64 // FIXME: We should not be allowing paint invalidation during layout. cr
bug.com/336250 |
| 65 AllowPaintInvalidationScope scoper(owner->frameView()); | 65 AllowPaintInvalidationScope scoper(owner->frameView()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // by skipping this step when destroying the entire tree. | 109 // by skipping this step when destroying the entire tree. |
| 110 if (!owner->documentBeingDestroyed()) | 110 if (!owner->documentBeingDestroyed()) |
| 111 LayoutCounter::rendererRemovedFromTree(oldChild); | 111 LayoutCounter::rendererRemovedFromTree(oldChild); |
| 112 | 112 |
| 113 if (AXObjectCache* cache = owner->document().existingAXObjectCache()) | 113 if (AXObjectCache* cache = owner->document().existingAXObjectCache()) |
| 114 cache->childrenChanged(owner); | 114 cache->childrenChanged(owner); |
| 115 | 115 |
| 116 return oldChild; | 116 return oldChild; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* n
ewChild, RenderObject* beforeChild, bool notifyRenderer) | 119 void LayoutObjectChildList::insertChildNode(LayoutObject* owner, LayoutObject* n
ewChild, LayoutObject* beforeChild, bool notifyRenderer) |
| 120 { | 120 { |
| 121 ASSERT(!newChild->parent()); | 121 ASSERT(!newChild->parent()); |
| 122 ASSERT(this == owner->virtualChildren()); | 122 ASSERT(this == owner->virtualChildren()); |
| 123 ASSERT(!owner->isRenderBlockFlow() || (!newChild->isTableSection() && !newCh
ild->isTableRow() && !newChild->isTableCell())); | 123 ASSERT(!owner->isRenderBlockFlow() || (!newChild->isTableSection() && !newCh
ild->isTableRow() && !newChild->isTableCell())); |
| 124 | 124 |
| 125 while (beforeChild && beforeChild->parent() && beforeChild->parent() != owne
r) | 125 while (beforeChild && beforeChild->parent() && beforeChild->parent() != owne
r) |
| 126 beforeChild = beforeChild->parent(); | 126 beforeChild = beforeChild->parent(); |
| 127 | 127 |
| 128 // This should never happen, but if it does prevent render tree corruption | 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() | 129 // where child->parent() ends up being owner but child->nextSibling()->paren
t() |
| 130 // is not owner. | 130 // is not owner. |
| 131 if (beforeChild && beforeChild->parent() != owner) { | 131 if (beforeChild && beforeChild->parent() != owner) { |
| 132 ASSERT_NOT_REACHED(); | 132 ASSERT_NOT_REACHED(); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 newChild->setParent(owner); | 136 newChild->setParent(owner); |
| 137 | 137 |
| 138 if (firstChild() == beforeChild) | 138 if (firstChild() == beforeChild) |
| 139 setFirstChild(newChild); | 139 setFirstChild(newChild); |
| 140 | 140 |
| 141 if (beforeChild) { | 141 if (beforeChild) { |
| 142 RenderObject* previousSibling = beforeChild->previousSibling(); | 142 LayoutObject* previousSibling = beforeChild->previousSibling(); |
| 143 if (previousSibling) | 143 if (previousSibling) |
| 144 previousSibling->setNextSibling(newChild); | 144 previousSibling->setNextSibling(newChild); |
| 145 newChild->setPreviousSibling(previousSibling); | 145 newChild->setPreviousSibling(previousSibling); |
| 146 newChild->setNextSibling(beforeChild); | 146 newChild->setNextSibling(beforeChild); |
| 147 beforeChild->setPreviousSibling(newChild); | 147 beforeChild->setPreviousSibling(newChild); |
| 148 } else { | 148 } else { |
| 149 if (lastChild()) | 149 if (lastChild()) |
| 150 lastChild()->setNextSibling(newChild); | 150 lastChild()->setNextSibling(newChild); |
| 151 newChild->setPreviousSibling(lastChild()); | 151 newChild->setPreviousSibling(lastChild()); |
| 152 setLastChild(newChild); | 152 setLastChild(newChild); |
| 153 } | 153 } |
| 154 | 154 |
| 155 if (!owner->documentBeingDestroyed() && notifyRenderer) | 155 if (!owner->documentBeingDestroyed() && notifyRenderer) |
| 156 newChild->insertedIntoTree(); | 156 newChild->insertedIntoTree(); |
| 157 | 157 |
| 158 if (!owner->documentBeingDestroyed()) { | 158 if (!owner->documentBeingDestroyed()) { |
| 159 LayoutCounter::rendererSubtreeAttached(newChild); | 159 LayoutCounter::rendererSubtreeAttached(newChild); |
| 160 } | 160 } |
| 161 | 161 |
| 162 newChild->setNeedsLayoutAndPrefWidthsRecalc(); | 162 newChild->setNeedsLayoutAndPrefWidthsRecalc(); |
| 163 newChild->setShouldDoFullPaintInvalidation(PaintInvalidationRendererInsertio
n); | 163 newChild->setShouldDoFullPaintInvalidation(PaintInvalidationRendererInsertio
n); |
| 164 if (!owner->normalChildNeedsLayout()) | 164 if (!owner->normalChildNeedsLayout()) |
| 165 owner->setChildNeedsLayout(); // We may supply the static position for a
n absolute positioned child. | 165 owner->setChildNeedsLayout(); // We may supply the static position for a
n absolute positioned child. |
| 166 | 166 |
| 167 if (AXObjectCache* cache = owner->document().axObjectCache()) | 167 if (AXObjectCache* cache = owner->document().axObjectCache()) |
| 168 cache->childrenChanged(owner); | 168 cache->childrenChanged(owner); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void RenderObjectChildList::invalidatePaintOnRemoval(const RenderObject& oldChil
d) | 171 void LayoutObjectChildList::invalidatePaintOnRemoval(const LayoutObject& oldChil
d) |
| 172 { | 172 { |
| 173 if (!oldChild.isRooted()) | 173 if (!oldChild.isRooted()) |
| 174 return; | 174 return; |
| 175 if (oldChild.isBody()) { | 175 if (oldChild.isBody()) { |
| 176 oldChild.view()->setShouldDoFullPaintInvalidation(); | 176 oldChild.view()->setShouldDoFullPaintInvalidation(); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 DisableCompositingQueryAsserts disabler; | 179 DisableCompositingQueryAsserts disabler; |
| 180 oldChild.invalidatePaintUsingContainer(oldChild.containerForPaintInvalidatio
n(), oldChild.previousPaintInvalidationRect(), PaintInvalidationRendererRemoval)
; | 180 oldChild.invalidatePaintUsingContainer(oldChild.containerForPaintInvalidatio
n(), oldChild.previousPaintInvalidationRect(), PaintInvalidationRendererRemoval)
; |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |