This source file includes following definitions.
- destroyLeftoverChildren
- removeChildNode
- insertChildNode
#include "config.h"
#include "core/rendering/RenderObjectChildList.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/rendering/RenderCounter.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/style/RenderStyle.h"
namespace WebCore {
void RenderObjectChildList::destroyLeftoverChildren()
{
while (firstChild()) {
if (firstChild()->isListMarker() || (firstChild()->style()->styleType() == FIRST_LETTER && !firstChild()->isText())) {
firstChild()->remove();
} else {
if (firstChild()->node())
firstChild()->node()->setRenderer(0);
firstChild()->destroy();
}
}
}
RenderObject* RenderObjectChildList::removeChildNode(RenderObject* owner, RenderObject* oldChild, bool notifyRenderer)
{
ASSERT(oldChild->parent() == owner);
if (oldChild->isFloatingOrOutOfFlowPositioned())
toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists();
{
AllowRepaintScope scoper(owner->frameView());
if (!owner->documentBeingDestroyed() && notifyRenderer && oldChild->everHadLayout()) {
oldChild->setNeedsLayoutAndPrefWidthsRecalc();
if (oldChild->isBody())
owner->view()->repaint();
else
oldChild->repaint();
}
}
if (oldChild->isBox())
toRenderBox(oldChild)->deleteLineBoxWrapper();
if (!owner->documentBeingDestroyed() && oldChild->isSelectionBorder())
owner->view()->clearSelection();
if (!owner->documentBeingDestroyed() && notifyRenderer)
oldChild->willBeRemovedFromTree();
if (oldChild->previousSibling())
oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
if (oldChild->nextSibling())
oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
if (firstChild() == oldChild)
setFirstChild(oldChild->nextSibling());
if (lastChild() == oldChild)
setLastChild(oldChild->previousSibling());
oldChild->setPreviousSibling(0);
oldChild->setNextSibling(0);
oldChild->setParent(0);
if (!owner->documentBeingDestroyed())
RenderCounter::rendererRemovedFromTree(oldChild);
if (AXObjectCache* cache = owner->document().existingAXObjectCache())
cache->childrenChanged(owner);
return oldChild;
}
void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* newChild, RenderObject* beforeChild, bool notifyRenderer)
{
ASSERT(!newChild->parent());
ASSERT(!owner->isRenderBlockFlow() || (!newChild->isTableSection() && !newChild->isTableRow() && !newChild->isTableCell()));
while (beforeChild && beforeChild->parent() && beforeChild->parent() != owner)
beforeChild = beforeChild->parent();
if (beforeChild && beforeChild->parent() != owner) {
ASSERT_NOT_REACHED();
return;
}
newChild->setParent(owner);
if (firstChild() == beforeChild)
setFirstChild(newChild);
if (beforeChild) {
RenderObject* previousSibling = beforeChild->previousSibling();
if (previousSibling)
previousSibling->setNextSibling(newChild);
newChild->setPreviousSibling(previousSibling);
newChild->setNextSibling(beforeChild);
beforeChild->setPreviousSibling(newChild);
} else {
if (lastChild())
lastChild()->setNextSibling(newChild);
newChild->setPreviousSibling(lastChild());
setLastChild(newChild);
}
if (!owner->documentBeingDestroyed() && notifyRenderer)
newChild->insertedIntoTree();
if (!owner->documentBeingDestroyed()) {
RenderCounter::rendererSubtreeAttached(newChild);
}
newChild->setNeedsLayoutAndPrefWidthsRecalc();
if (!owner->normalChildNeedsLayout())
owner->setChildNeedsLayout();
if (AXObjectCache* cache = owner->document().axObjectCache())
cache->childrenChanged(owner);
}
}