Exemple #1
0
void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight)
{
    FrameView* childFrameView = static_cast<FrameView*>(widget());
    RenderView* childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->contentRenderer()) : 0;

    if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) {
        updateWidgetPosition();
        if (childFrameView)
            childFrameView->layout();
        setNeedsLayout(false);
        return;
    }

    // need to update to calculate min/max correctly
    updateWidgetPosition();
    if (childRoot->preferredLogicalWidthsDirty())
        childRoot->computePreferredLogicalWidths();

    // if scrollbars are off, and the width or height are fixed
    // we obey them and do not expand. With frame flattening
    // no subframe much ever become scrollable.

    HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node());
    bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;

    // consider iframe inset border
    int hBorder = borderLeft() + borderRight();
    int vBorder = borderTop() + borderBottom();

    // make sure minimum preferred width is enforced
    if (isScrollable || !hasFixedWidth) {
        setWidth(max(width(), childRoot->minPreferredLogicalWidth() + hBorder));
        // update again to pass the new width to the child frame
        updateWidgetPosition();
        childFrameView->layout();
    }

    // expand the frame by setting frame height = content height
    if (isScrollable || !hasFixedHeight || childRoot->isFrameSet())
        setHeight(max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder));
    if (isScrollable || !hasFixedWidth || childRoot->isFrameSet())
        setWidth(max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder));

    updateWidgetPosition();

    ASSERT(!childFrameView->layoutPending());
    ASSERT(!childRoot->needsLayout());
    ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout());

    setNeedsLayout(false);
}
Exemple #2
0
void RenderFrameBase::peformLayoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight)
{
    if (!childRenderView())
        return;

    if (!shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) {
        if (updateWidgetPosition() == ChildWidgetState::Destroyed)
            return;
        childView()->layout();
        return;
    }

    // need to update to calculate min/max correctly
    if (updateWidgetPosition() == ChildWidgetState::Destroyed)
        return;
    
    // if scrollbars are off, and the width or height are fixed
    // we obey them and do not expand. With frame flattening
    // no subframe much ever become scrollable.
    bool isScrollable = frameOwnerElement().scrollingMode() != ScrollbarAlwaysOff;

    // consider iframe inset border
    int hBorder = borderLeft() + borderRight();
    int vBorder = borderTop() + borderBottom();

    // make sure minimum preferred width is enforced
    if (isScrollable || !hasFixedWidth) {
        ASSERT(childRenderView());
        setWidth(std::max(width(), childRenderView()->minPreferredLogicalWidth() + hBorder));
        // update again to pass the new width to the child frame
        if (updateWidgetPosition() == ChildWidgetState::Destroyed)
            return;
        childView()->layout();
    }

    ASSERT(childView());
    // expand the frame by setting frame height = content height
    if (isScrollable || !hasFixedHeight || childRenderView()->isFrameSet())
        setHeight(std::max<LayoutUnit>(height(), childView()->contentsHeight() + vBorder));
    if (isScrollable || !hasFixedWidth || childRenderView()->isFrameSet())
        setWidth(std::max<LayoutUnit>(width(), childView()->contentsWidth() + hBorder));

    if (updateWidgetPosition() == ChildWidgetState::Destroyed)
        return;

    ASSERT(!childView()->layoutPending());
    ASSERT(!childRenderView()->needsLayout());
    ASSERT(!childRenderView()->firstChild() || !childRenderView()->firstChild()->firstChildSlow() || !childRenderView()->firstChild()->firstChildSlow()->needsLayout());
}