Exemple #1
0
LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, RenderView& view)
    : m_isPaginated(pageLogicalHeight)
    , m_pageLogicalHeightChanged(pageLogicalHeightChanged)
    , m_containingBlockLogicalWidthChanged(false)
    , m_flowThread(0)
    , m_columnInfo(0)
    , m_next(0)
    , m_pageLogicalHeight(pageLogicalHeight)
    , m_renderer(view)
{
    ASSERT(!view.layoutState());
    view.pushLayoutState(*this);
}
void RenderMathMLBlock::computeChildrenPreferredLogicalHeights()
{
    ASSERT(needsLayout());

    // This is ugly, but disable fragmentation when computing the preferred heights.
    FragmentationDisabler fragmentationDisabler(this);

    // Ensure a full repaint will happen after layout finishes.
    setNeedsLayout(true, MarkOnlyThis);

    RenderView* renderView = view();
    bool hadLayoutState = renderView->layoutState();
    if (!hadLayoutState)
        renderView->pushLayoutState(this);
    {
        LayoutStateDisabler layoutStateDisabler(renderView);

        LayoutUnit oldAvailableLogicalWidth = availableLogicalWidth();
        setLogicalWidth(cLargeLogicalWidth);

        for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
            if (!child->isBox())
                continue;

            // Because our width changed, |child| may need layout.
            if (child->maxPreferredLogicalWidth() > oldAvailableLogicalWidth)
                child->setNeedsLayout(true, MarkOnlyThis);

            RenderMathMLBlock* childMathMLBlock = child->isRenderMathMLBlock() ? toRenderMathMLBlock(child) : 0;
            if (childMathMLBlock && !childMathMLBlock->isPreferredLogicalHeightDirty())
                continue;
            // Layout our child to compute its preferred logical height.
            child->layoutIfNeeded();
            if (childMathMLBlock)
                childMathMLBlock->setPreferredLogicalHeight(childMathMLBlock->logicalHeight());
        }
    }
    if (!hadLayoutState)
        renderView->popLayoutState(this);
}