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(); }
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(); }