Changeset 139940 in webkit
- Timestamp:
- Jan 16, 2013 5:32:09 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r139939 r139940 1 2013-01-16 Elliott Sprehn <esprehn@chromium.org> 2 3 Merge RenderObjectChildList::appendChildNode and insertChildNode 4 https://bugs.webkit.org/show_bug.cgi?id=106392 5 6 Reviewed by Eric Seidel. 7 8 insertChildNode and appendChildNode are nearly identical methods and 9 we can combine them into insertChildNode and handle cases where the 10 renderer to insert before is null as if it was an append. 11 12 No new tests, just refactoring. 13 14 * rendering/RenderObjectChildList.cpp: 15 (WebCore::RenderObjectChildList::insertChildNode): 16 * rendering/RenderObjectChildList.h: 17 (RenderObjectChildList): 18 (WebCore::RenderObjectChildList::appendChildNode): 19 Now inline and delegates to insertChildNode. 20 1 21 2013-01-16 Elliott Sprehn <esprehn@chromium.org> 2 22 -
trunk/Source/WebCore/rendering/RenderObjectChildList.cpp
r139788 r139940 29 29 30 30 #include "AXObjectCache.h" 31 #include "ContentData.h"32 #include "RenderBlock.h"33 31 #include "RenderCounter.h" 34 #include "RenderLayer.h" 35 #include "RenderListItem.h" 36 #include "RenderNamedFlowThread.h" 37 #include "RenderRegion.h" 32 #include "RenderObject.h" 38 33 #include "RenderStyle.h" 39 34 #include "RenderView.h" … … 106 101 // rendererRemovedFromTree walks the whole subtree. We can improve performance 107 102 // by skipping this step when destroying the entire tree. 108 if (!owner->documentBeingDestroyed()) {103 if (!owner->documentBeingDestroyed()) 109 104 RenderCounter::rendererRemovedFromTree(oldChild); 110 }111 105 112 106 if (AXObjectCache::accessibilityEnabled()) … … 116 110 } 117 111 118 void RenderObjectChildList:: appendChildNode(RenderObject* owner, RenderObject* newChild, bool notifyRenderer)112 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* newChild, RenderObject* beforeChild, bool notifyRenderer) 119 113 { 120 ASSERT( newChild->parent() == 0);114 ASSERT(!newChild->parent()); 121 115 ASSERT(!owner->isBlockFlow() || (!newChild->isTableSection() && !newChild->isTableRow() && !newChild->isTableCell())); 122 116 117 while (beforeChild && beforeChild->parent() && beforeChild->parent() != owner) 118 beforeChild = beforeChild->parent(); 119 120 // This should never happen, but if it does prevent render tree corruption 121 // where child->parent() ends up being owner but child->nextSibling()->parent() 122 // is not owner. 123 if (beforeChild && beforeChild->parent() != owner) { 124 ASSERT_NOT_REACHED(); 125 return; 126 } 127 123 128 newChild->setParent(owner); 124 RenderObject* lChild = lastChild();125 129 126 if (lChild) { 127 newChild->setPreviousSibling(lChild); 128 lChild->setNextSibling(newChild); 129 } else 130 if (firstChild() == beforeChild) 130 131 setFirstChild(newChild); 131 132 132 setLastChild(newChild); 133 133 if (beforeChild) { 134 RenderObject* previousSibling = beforeChild->previousSibling(); 135 if (previousSibling) 136 previousSibling->setNextSibling(newChild); 137 newChild->setPreviousSibling(previousSibling); 138 newChild->setNextSibling(beforeChild); 139 beforeChild->setPreviousSibling(newChild); 140 } else { 141 if (lastChild()) 142 lastChild()->setNextSibling(newChild); 143 newChild->setPreviousSibling(lastChild()); 144 setLastChild(newChild); 145 } 146 134 147 if (!owner->documentBeingDestroyed() && notifyRenderer) 135 148 newChild->insertedIntoTree(); … … 138 151 RenderCounter::rendererSubtreeAttached(newChild); 139 152 } 140 newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy. 153 154 newChild->setNeedsLayoutAndPrefWidthsRecalc(); 141 155 if (!owner->normalChildNeedsLayout()) 142 156 owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. 143 144 if (AXObjectCache::accessibilityEnabled())145 owner->document()->axObjectCache()->childrenChanged(owner);146 }147 157 148 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* child, RenderObject* beforeChild, bool notifyRenderer)149 {150 if (!beforeChild) {151 appendChildNode(owner, child, notifyRenderer);152 return;153 }154 155 ASSERT(!child->parent());156 while (beforeChild->parent() && beforeChild->parent() != owner)157 beforeChild = beforeChild->parent();158 159 // This should never happen, but if it does prevent render tree corruption160 // where child->parent() ends up being owner but child->nextSibling()->parent()161 // is not owner.162 if (beforeChild->parent() != owner) {163 ASSERT_NOT_REACHED();164 return;165 }166 167 ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTableRow() && !child->isTableCell()));168 169 if (beforeChild == firstChild())170 setFirstChild(child);171 172 RenderObject* prev = beforeChild->previousSibling();173 child->setNextSibling(beforeChild);174 beforeChild->setPreviousSibling(child);175 if (prev)176 prev->setNextSibling(child);177 child->setPreviousSibling(prev);178 179 child->setParent(owner);180 181 if (!owner->documentBeingDestroyed() && notifyRenderer)182 child->insertedIntoTree();183 184 if (!owner->documentBeingDestroyed()) {185 RenderCounter::rendererSubtreeAttached(child);186 }187 child->setNeedsLayoutAndPrefWidthsRecalc();188 if (!owner->normalChildNeedsLayout())189 owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.190 191 158 if (AXObjectCache::accessibilityEnabled()) 192 159 owner->document()->axObjectCache()->childrenChanged(owner); -
trunk/Source/WebCore/rendering/RenderObjectChildList.h
r138909 r139940 32 32 33 33 class RenderObject; 34 class RenderStyle;35 34 36 35 class RenderObjectChildList { … … 44 43 RenderObject* firstChild() const { return m_firstChild; } 45 44 RenderObject* lastChild() const { return m_lastChild; } 46 45 47 46 // FIXME: Temporary while RenderBox still exists. Eventually this will just happen during insert/append/remove methods on the child list, and nobody 48 47 // will need to manipulate firstChild or lastChild directly. 49 48 void setFirstChild(RenderObject* child) { m_firstChild = child; } 50 49 void setLastChild(RenderObject* child) { m_lastChild = child; } 51 50 52 51 void destroyLeftoverChildren(); 53 52 54 53 RenderObject* removeChildNode(RenderObject* owner, RenderObject*, bool notifyRenderer = true); 55 void appendChildNode(RenderObject* owner, RenderObject*, bool notifyRenderer = true); 56 void insertChildNode(RenderObject* owner, RenderObject* child, RenderObject* before, bool notifyRenderer = true); 54 void insertChildNode(RenderObject* owner, RenderObject* newChild, RenderObject* beforeChild, bool notifyRenderer = true); 55 void appendChildNode(RenderObject* owner, RenderObject* newChild, bool notifyRenderer = true) 56 { 57 insertChildNode(owner, newChild, 0, notifyRenderer); 58 } 57 59 58 60 private:
Note: See TracChangeset
for help on using the changeset viewer.