final long height = last.getY() + last.getHeight() - nodeY;
// make sure that the finished-box inherits the margins ..
final long marginsTop = node.getEffectiveMarginTop();
final long marginsBottom = last.getEffectiveMarginBottom();
final FinishedRenderNode replacement =
new FinishedRenderNode(width, height, marginsTop, marginsBottom);
RenderNode removeNode = node;
while (removeNode != last)
{
final RenderNode next = removeNode.getNext();
if (removeNode.isOpen())
{
throw new IllegalStateException();
}
box.remove(removeNode);
removeNode = next;
}
if (last.isOpen())
{
throw new IllegalStateException();
}
box.replaceChild(last, replacement);
if (replacement.getParent() != box)
{
throw new IllegalStateException();
}
return (box.getLastChild() != replacement);
}