Esempio n. 1
0
FloatSize SVGSVGElement::currentViewportSize() const
{
    if (hasIntrinsicWidth() && hasIntrinsicHeight())
        return FloatSize(floatValueForLength(intrinsicWidth(), 0), floatValueForLength(intrinsicHeight(), 0));

    if (!renderer())
        return { };

    if (is<RenderSVGRoot>(*renderer())) {
        auto& root = downcast<RenderSVGRoot>(*renderer());
        return root.contentBoxRect().size() / root.style().effectiveZoom();
    }

    return downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
}
Esempio n. 2
0
FloatSize SVGSVGElement::currentViewportSize() const
{
    if (hasIntrinsicWidth() && hasIntrinsicHeight()) {
        Length intrinsicWidth = this->intrinsicWidth();
        Length intrinsicHeight = this->intrinsicHeight();
        return FloatSize(floatValueForLength(intrinsicWidth, 0), floatValueForLength(intrinsicHeight, 0));
    }

    if (!renderer())
        return FloatSize();

    if (is<RenderSVGRoot>(*renderer())) {
        LayoutRect contentBoxRect = downcast<RenderSVGRoot>(*renderer()).contentBoxRect();
        return FloatSize(contentBoxRect.width() / renderer()->style().effectiveZoom(), contentBoxRect.height() / renderer()->style().effectiveZoom());
    }

    FloatRect viewportRect = downcast<RenderSVGViewportContainer>(*renderer()).viewport();
    return FloatSize(viewportRect.width(), viewportRect.height());
}
Esempio n. 3
0
FloatRect SVGSVGElement::currentViewBoxRect() const {
  if (m_viewSpec)
    return m_viewSpec->viewBox()->value();

  FloatRect useViewBox = viewBox()->currentValue()->value();
  if (!useViewBox.isEmpty())
    return useViewBox;
  if (!shouldSynthesizeViewBox())
    return FloatRect();

  // If no viewBox is specified but non-relative width/height values, then we
  // should always synthesize a viewBox if we're embedded through a SVGImage.
  FloatSize synthesizedViewBoxSize(intrinsicWidth(), intrinsicHeight());
  if (!hasIntrinsicWidth())
    synthesizedViewBoxSize.setWidth(width()->currentValue()->scaleByPercentage(
        currentViewportSize().width()));
  if (!hasIntrinsicHeight())
    synthesizedViewBoxSize.setHeight(
        height()->currentValue()->scaleByPercentage(
            currentViewportSize().height()));
  return FloatRect(FloatPoint(), synthesizedViewBoxSize);
}