void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom)
{
int top = borderTop() + paddingTop();
int bottom = borderBottom() + paddingBottom() + horizontalScrollbarHeight();
// Fieldsets need to find their legend and position it inside the border of the object. // The legend then gets skipped during normal layout. RenderObject* legend = layoutLegend(relayoutChildren);
//遍历子节点
RenderBox* next = firstChildBox(); while (next) { RenderBox* child = next; next = child->nextSiblingBox();
if (legend == child) continue; // Skip the legend, since it has already been positioned up in the fieldset's border. // Make sure we layout children if they need it. // FIXME: Technically percentage height objects only need a relayout if their percentage isn't going to be turned into // an auto value. Add a method to determine this, so that we can avoid the relayout. if (relayoutChildren || ((child->style()->height().isPercent() || child->style()->minHeight().isPercent() || child->style()->maxHeight().isPercent()) && !isRenderView())) child->setChildNeedsLayout(true, false);
// If relayoutChildren is set and we have percentage padding, we also need to invalidate the child's pref widths. if (relayoutChildren && (child->style()->paddingLeft().isPercent() || child->style()->paddingRight().isPercent())) child->setPrefWidthsDirty(true, false);
// Handle the four types of special elements first. These include positioned content, floating content, compacts and // run-ins. When we encounter these four types of objects, we don't actually lay them out as normal flow blocks. if (handleSpecialChild(child, marginInfo)) continue;
// Lay out the child. layoutBlockChild(child, marginInfo, previousFloatBottom, maxFloatBottom); }
// Now do the handling of the bottom of the block, adding in our bottom border/padding and // determining the correct collapsed bottom margin information. handleBottomOfBlock(top, bottom, marginInfo); }
|