Ejemplo n.º 1
0
void RenderPartObject::layout()
{
    ASSERT(needsLayout());
    ASSERT(minMaxKnown());

    FrameView* childFrameView = static_cast<FrameView*>(m_widget);
    RenderView* childRoot = 0;
    
    bool flatten = m_widget && element()->hasTagName(iframeTag) && element() && element()->document()->frame() && 
        element()->document()->frame()->settings()->flatFrameSetLayoutEnabled() && 
        (static_cast<HTMLIFrameElement*>(element())->scrollingMode() != ScrollBarAlwaysOff || !style()->width().isFixed() || !style()->height().isFixed()) &&
        (childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->renderer()) : 0);

    if (flatten) {
        
        if (!childRoot->minMaxKnown())
            childRoot->calcMinMaxWidth();
        
        calcWidth();
        calcHeight();
        
        bool scrolling = static_cast<HTMLIFrameElement*>(element())->scrollingMode() != ScrollBarAlwaysOff;
        if (scrolling || !style()->width().isFixed())
            m_width = max(m_width, childRoot->minWidth());

        updateWidgetPosition();
        do
            childFrameView->layout();
        while (childFrameView->layoutPending() || childRoot->needsLayout());     
        
        if (scrolling || !style()->height().isFixed())
            m_height = max(m_height, childFrameView->contentsHeight());
        if (scrolling || !style()->width().isFixed())
            m_width = max(m_width, childFrameView->contentsWidth());
        
        updateWidgetPosition();
        
        ASSERT(!childFrameView->layoutPending());
        ASSERT(!childRoot->needsLayout());
        ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout());
    } else {
    calcWidth();
    calcHeight();

    RenderPart::layout();
    }
    setNeedsLayout(false);
}
Ejemplo n.º 2
0
bool FrameView::needsLayout() const
{
    RenderView* renderView = this->renderView();
    return layoutPending()
        || (renderView && renderView->needsLayout())
        || isSubtreeLayout();
}
Ejemplo n.º 3
0
bool FrameView::needsLayout() const
{
    // It is possible that our document will not have a body yet. If this is the case, 
    // then we are not allowed to schedule layouts yet, so we won't be pending layout.
    if (!m_frame)
        return false;
    RenderView* root = m_frame->contentRenderer();
    Document * doc = m_frame->document();
    // doc->hasChangedChild() condition can occur when using WebKit ObjC interface
    return layoutPending() || (root && root->needsLayout()) || d->m_layoutRoot || (doc && doc->hasChangedChild()) || m_frame->needsReapplyStyles();
}
Ejemplo n.º 4
0
void RenderFrameBase::layoutWithFlattening(bool fixedWidth, bool fixedHeight)
{
    FrameView* childFrameView = static_cast<FrameView*>(widget());
    RenderView* childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->contentRenderer()) : 0;

    // Do not expand frames which has zero width or height
    if (!width() || !height() || !childRoot) {
        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 || !fixedWidth) {
        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 || !fixedHeight || childRoot->isFrameSet())
        setHeight(max(height(), childFrameView->contentsHeight() + vBorder));
    if (isScrollable || !fixedWidth || childRoot->isFrameSet())
        setWidth(max(width(), childFrameView->contentsWidth() + hBorder));

    updateWidgetPosition();

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

    setNeedsLayout(false);
}
Ejemplo n.º 5
0
void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight)
{
    FrameView* childFrameView = toFrameView(widget());
    RenderView* childRoot = childFrameView ? childFrameView->frame().contentRenderer() : 0;

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

    // need to update to calculate min/max correctly
    updateWidgetPosition();

    // 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) {
        setWidth(std::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(std::max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder));
    if (isScrollable || !hasFixedWidth || childRoot->isFrameSet())
        setWidth(std::max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder));

    updateWidgetPosition();

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

    clearNeedsLayout();
}
Ejemplo n.º 6
0
void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
{
    ASSERT(m_frame->view() == this);

    if (!m_frame->document()->isActive())
        return;

    RenderView* renderView = this->renderView();
    if (renderView && renderView->needsLayout()) {
        if (relayoutRoot)
            relayoutRoot->markContainingBlocksForLayout(false);
        return;
    }

    if (layoutPending() || !m_layoutSchedulingEnabled) {
        if (m_layoutSubtreeRoot != relayoutRoot) {
            if (isObjectAncestorContainerOf(m_layoutSubtreeRoot, relayoutRoot)) {
                // Keep the current root
                relayoutRoot->markContainingBlocksForLayout(false, m_layoutSubtreeRoot);
                ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->container()->needsLayout());
            } else if (isSubtreeLayout() && isObjectAncestorContainerOf(relayoutRoot, m_layoutSubtreeRoot)) {
                // Re-root at relayoutRoot
                m_layoutSubtreeRoot->markContainingBlocksForLayout(false, relayoutRoot);
                m_layoutSubtreeRoot = relayoutRoot;
                ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->container()->needsLayout());
            } else {
                // Just do a full relayout
                if (isSubtreeLayout())
                    m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
                m_layoutSubtreeRoot = 0;
                relayoutRoot->markContainingBlocksForLayout(false);
            }
        }
    } else if (m_layoutSchedulingEnabled) {
        m_layoutSubtreeRoot = relayoutRoot;
        ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->container()->needsLayout());
        m_hasPendingLayout = true;

        m_frame->document()->scheduleVisualUpdate();
    }
}
Ejemplo n.º 7
0
void RenderIFrame::layoutSeamlessly()
{
    updateLogicalWidth();
    // FIXME: Containers set their height to 0 before laying out their kids (as we're doing here)
    // however, this causes FrameView::layout() to add vertical scrollbars, incorrectly inflating
    // the resulting contentHeight(). We'll need to make FrameView::layout() smarter.
    setLogicalHeight(0);
    updateWidgetPosition(); // Tell the Widget about our new width/height (it will also layout the child document).

    // Laying out our kids is normally responsible for adjusting our height, so we set it here.
    // Replaced elements normally do not respect padding, but seamless elements should: we'll add
    // both padding and border to the child's logical height here.
    FrameView* childFrameView = toFrameView(widget());
    if (childFrameView) // Widget should never be null during layout(), but just in case.
        setLogicalHeight(childFrameView->contentsHeight() + borderTop() + borderBottom() + paddingTop() + paddingBottom());
    updateLogicalHeight();

    updateWidgetPosition(); // Notify the Widget of our final height.

    // Assert that the child document did a complete layout.
    RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRenderer() : 0;
    ASSERT(!childFrameView || !childFrameView->layoutPending());
    ASSERT_UNUSED(childRoot, !childRoot || !childRoot->needsLayout());
}
void RenderPartObject::layout()
{
    ASSERT(needsLayout());

#ifdef FLATTEN_IFRAME
    RenderPart::calcWidth();
    RenderPart::calcHeight();
    // Calculate the styled dimensions by subtracting the border and padding.
    int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight();
    int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom();
    int styleWidth = width() - extraWidth;
    int styleHeight = height() - extraHeight;
    // Some IFrames have a width and/or height of 1 when they are meant to be
    // hidden. If that is the case, do not try to expand.
    if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView() &&
            styleWidth > 1 && styleHeight > 1) {
        HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node());
        bool scrolling = element->scrollingMode() != ScrollbarAlwaysOff;
        bool widthIsFixed = style()->width().isFixed();
        bool heightIsFixed = style()->height().isFixed();
        // If an iframe has a fixed dimension and suppresses scrollbars, it
        // will disrupt layout if we force it to expand. Plus on a desktop,
        // the extra content is not accessible.
        if (scrolling || !widthIsFixed || !heightIsFixed) {
            FrameView* view = static_cast<FrameView*>(widget());
            RenderView* root = view ? view->frame()->contentRenderer() : NULL;
            if (root && style()->visibility() != HIDDEN) {
                // Update the dimensions to get the correct minimum preferred
                // width
                updateWidgetPosition();

                // Use the preferred width if it is larger and only if
                // scrollbars are visible or the width style is not fixed.
                if (scrolling || !widthIsFixed)
                    setWidth(max(width(), root->minPrefWidth()) + extraWidth);

                // Resize the view to recalc the height.
                int h = height() - extraHeight;
                int w = width() - extraWidth;
                if (w > view->width())
                    h = 0;
                if (w != view->width() || h != view->height()) {
                    view->resize(w, h);
                }

                // Layout the view.
//SAMSUNG CHANGE >>
		  // Browser freeze issue in http://www.enuri.com/
                /* do {
                    view->layout();
                } while (view->layoutPending() || root->needsLayout()); */
                
		  node()->document()->page()->mainFrame()->view()->layoutIfNeededRecursive();
 //SAMSUNG CHANGE <<


                int contentHeight = view->contentsHeight();
                int contentWidth = view->contentsWidth();
                // Only change the width or height if scrollbars are visible or
                // if the style is not a fixed value. Use the maximum value so
                // that iframes never shrink.
                if (scrolling || !heightIsFixed)
                    setHeight(max(height(), contentHeight + extraHeight));
                if (scrolling || !widthIsFixed)
                    setWidth(max(width(), contentWidth + extraWidth));

                // Update one last time
                updateWidgetPosition();

                // Layout one more time to ensure all objects have the correct
                // height.
                view->layout();

#if !ASSERT_DISABLED
                ASSERT(!view->layoutPending());
                ASSERT(!root->needsLayout());
                // Sanity check when assertions are enabled.
                RenderObject* c = root->nextInPreOrder();
                while (c) {
                    ASSERT(!c->needsLayout());
                    c = c->nextInPreOrder();
                }
#endif
            }
        }
    }
#else
    calcWidth();
    calcHeight();
#endif

    RenderPart::layout();

    m_overflow.clear();
    addShadowOverflow();

    setNeedsLayout(false);
}