Ejemplo n.º 1
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.height();

    if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().isSpecified())
        return RenderReplaced::computeReplacedLogicalHeight();

    if (svgSVGElement().heightAttributeEstablishesViewport()) {
        Length height = svgSVGElement().intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
        if (height.isPercent()) {
            RenderBlock* cb = containingBlock();
            ASSERT(cb);
            while (cb->isAnonymous() && !cb->isRenderView()) {
                cb = cb->containingBlock();
                cb->addPercentHeightDescendant(const_cast<RenderSVGRoot&>(*this));
            }
        } else
            RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot&>(*this));

        return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding), &view());
    }

    // SVG embedded through object/embed/iframe.
    if (isEmbeddedThroughFrameContainingSVGDocument())
        return frame().ownerRenderer()->availableLogicalHeight(IncludeMarginBorderPadding);

    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
    return RenderReplaced::computeReplacedLogicalHeight();
}
Ejemplo n.º 2
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    LayoutUnit replacedHeight = m_containerSize.height();
    if (replacedHeight > 0)
        return replacedHeight;

    replacedHeight = RenderBox::computeReplacedLogicalHeight();
    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
    if (!frame)
        return replacedHeight;

    if (!isEmbeddedThroughFrameContainingSVGDocument())
        return replacedHeight;

    RenderPart* ownerRenderer = frame->ownerRenderer();
    ASSERT(ownerRenderer);

    RenderStyle* ownerRendererStyle = ownerRenderer->style();
    ASSERT(ownerRendererStyle);

    Length ownerHeight = ownerRendererStyle->height();
    if (ownerHeight.isAuto())
        return replacedHeight;

    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
    // See comment in RenderSVGRoot::computeReplacedLogicalWidth().
    // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element that
    // are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's height;
    // otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height.
    return ownerRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight));
}
Ejemplo n.º 3
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    ASSERT(svg);

    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.height();

    if (hasReplacedLogicalHeight())
        return RenderReplaced::computeReplacedLogicalHeight();

    if (svg->heightAttributeEstablishesViewport()) {
        Length height = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
        if (height.isPercent()) {
            RenderBlock* cb = containingBlock();
            ASSERT(cb);
            while (cb->isAnonymous()) {
                cb = cb->containingBlock();
                cb->addPercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
            }
        } else
            RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this));

        return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
    }

    // Only SVGs embedded in <object> reach this point.
    ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
    return document()->frame()->ownerRenderer()->availableLogicalHeight();
}
Ejemplo n.º 4
0
LayoutUnit LayoutSVGRoot::computeReplacedLogicalHeight() const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.height();

    if (isEmbeddedThroughFrameContainingSVGDocument())
        return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding);

    return LayoutReplaced::computeReplacedLogicalHeight();
}
Ejemplo n.º 5
0
LayoutUnit LayoutSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.width();

    if (isEmbeddedThroughFrameContainingSVGDocument())
        return containingBlock()->availableLogicalWidth();

    return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
}
Ejemplo n.º 6
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.height();

    if (isEmbeddedThroughFrameContainingSVGDocument())
        return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding);

    if (style().logicalHeight().isSpecified() || style().logicalMaxHeight().isSpecified())
        return RenderReplaced::computeReplacedLogicalHeight();

    if (svgSVGElement().hasIntrinsicHeight())
        return resolveLengthAttributeForSVG(svgSVGElement().intrinsicHeight(), style().effectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding).toFloat());

    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
    return RenderReplaced::computeReplacedLogicalHeight();
}
Ejemplo n.º 7
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.width();

    if (isEmbeddedThroughFrameContainingSVGDocument())
        return containingBlock()->availableLogicalWidth();

    if (style().logicalWidth().isSpecified() || style().logicalMaxWidth().isSpecified())
        return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);

    if (svgSVGElement().hasIntrinsicWidth())
        return resolveLengthAttributeForSVG(svgSVGElement().intrinsicWidth(), style().effectiveZoom(), containingBlock()->availableLogicalWidth(), &view());

    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
    return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
}
Ejemplo n.º 8
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
{
    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    LayoutUnit replacedWidth = m_containerSize.width();
    if (replacedWidth > 0)
        return replacedWidth;

    replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
    if (!frame)
        return replacedWidth;

    if (!isEmbeddedThroughFrameContainingSVGDocument())
        return replacedWidth;

    RenderPart* ownerRenderer = frame->ownerRenderer();
    RenderStyle* ownerRendererStyle = ownerRenderer->style();
    ASSERT(ownerRendererStyle);
    ASSERT(frame->contentRenderer());

    Length ownerWidth = ownerRendererStyle->width();
    if (ownerWidth.isAuto())
        return replacedWidth;

    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
    // The SVG user agent negotiates with its parent user agent to determine the viewport into which the SVG user agent can render
    // the document. In some circumstances, SVG content will be embedded (by reference or inline) within a containing document.
    // This containing document might include attributes, properties and/or other parameters (explicit or implicit) which specify
    // or provide hints about the dimensions of the viewport for the SVG content. SVG content itself optionally can provide
    // information about the appropriate viewport region for the content via the ‘width’ and ‘height’ XML attributes on the
    // outermost svg element. The negotiation process uses any information provided by the containing document and the SVG
    // content itself to choose the viewport location and size.

    // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
    // * the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]),
    //   or the SVG content is embedded inline within a containing document;
    // * and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL];
    // * and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element
    //   (e.g., the ‘object’ element) or on the containing document's outermost svg element that are sufficient to establish
    //   the width of the viewport.
    //
    // Under these conditions, the positioning properties establish the viewport's width.
    return ownerRenderer->computeReplacedLogicalWidthRespectingMinMaxWidth(ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth), includeMaxWidth);
}
Ejemplo n.º 9
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
{
    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    ASSERT(svg);

    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.width();

    if (style()->logicalWidth().isSpecified())
        return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);

    if (svg->widthAttributeEstablishesViewport())
        return resolveLengthAttributeForSVG(svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalWidth());

    // Only SVGs embedded in <object> reach this point.
    ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
    return document()->frame()->ownerRenderer()->availableLogicalWidth();
}
Ejemplo n.º 10
0
LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
{
    SVGSVGElement* svg = toSVGSVGElement(node());
    ASSERT(svg);

    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    if (!m_containerSize.isEmpty())
        return m_containerSize.width();

    if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSpecified())
        return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);

    if (svg->widthAttributeEstablishesViewport())
        return resolveLengthAttributeForSVG(svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalWidth(), view());

    // SVG embedded through object/embed/iframe.
    if (isEmbeddedThroughFrameContainingSVGDocument())
        return document()->frame()->ownerRenderer()->availableLogicalWidth();

    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
    return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
}