bool RenderSVGImage::updateImageViewport() { SVGImageElement* image = toSVGImageElement(element()); FloatRect oldBoundaries = m_objectBoundingBox; bool updatedViewport = false; SVGLengthContext lengthContext(image); m_objectBoundingBox = FloatRect(image->x()->currentValue()->value(lengthContext), image->y()->currentValue()->value(lengthContext), image->width()->currentValue()->value(lengthContext), image->height()->currentValue()->value(lengthContext)); bool boundsChanged = oldBoundaries != m_objectBoundingBox; // Images with preserveAspectRatio=none should force non-uniform scaling. This can be achieved // by setting the image's container size to its intrinsic size. // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The ‘preserveAspectRatio’ attribute. IntSize newViewportSize; if (image->preserveAspectRatio()->currentValue()->align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) { LayoutSize intrinsicSize = m_imageResource->intrinsicSize(style()->effectiveZoom()); if (intrinsicSize != m_imageResource->imageSize(style()->effectiveZoom())) { newViewportSize = roundedIntSize(intrinsicSize); updatedViewport = true; } } else if (boundsChanged) { newViewportSize = enclosingIntRect(m_objectBoundingBox).size(); updatedViewport = true; } if (updatedViewport) m_imageResource->setContainerSizeForRenderer(newViewportSize); m_needsBoundariesUpdate |= boundsChanged; return updatedViewport; }
void RenderSVGImage::layout() { ASSERT(needsLayout()); LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout()); SVGImageElement* image = static_cast<SVGImageElement*>(node()); bool updateCachedBoundariesInParents = false; if (m_needsTransformUpdate) { m_localTransform = image->animatedLocalTransform(); m_needsTransformUpdate = false; updateCachedBoundariesInParents = true; } // FIXME: Optimize caching the repaint rects. FloatRect oldBoundaries = m_localBounds; m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image)); m_cachedLocalRepaintRect = FloatRect(); if (!updateCachedBoundariesInParents) updateCachedBoundariesInParents = oldBoundaries != m_localBounds; // Invalidate all resources of this client if our layout changed. if (m_everHadLayout && selfNeedsLayout()) SVGResourcesCache::clientLayoutChanged(this); // If our bounds changed, notify the parents. if (updateCachedBoundariesInParents) RenderSVGModelObject::setNeedsBoundariesUpdate(); repainter.repaintAfterLayout(); setNeedsLayout(false); }
void RenderSVGImage::layout() { ASSERT(needsLayout()); LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); SVGImageElement* image = static_cast<SVGImageElement*>(node()); if (m_needsTransformUpdate) { m_localTransform = image->animatedLocalTransform(); m_needsTransformUpdate = false; } // minimum height setHeight(errorOccurred() ? intrinsicSize().height() : 0); calcWidth(); calcHeight(); m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image)); m_cachedLocalRepaintRect = FloatRect(); repainter.repaintAfterLayout(); setNeedsLayout(false); }
bool RenderSVGImage::updateImageViewport() { SVGImageElement* image = static_cast<SVGImageElement*>(node()); FloatRect oldBoundaries = m_objectBoundingBox; SVGLengthContext lengthContext(image); m_objectBoundingBox = FloatRect(image->x().value(lengthContext), image->y().value(lengthContext), image->width().value(lengthContext), image->height().value(lengthContext)); if (oldBoundaries == m_objectBoundingBox) return false; m_imageResource->setContainerSizeForRenderer(enclosingIntRect(m_objectBoundingBox).size()); m_needsBoundariesUpdate = true; return true; }
AffineTransform RenderSVGImage::translationForAttributes() { SVGImageElement *image = static_cast<SVGImageElement*>(node()); return AffineTransform().translate(image->x().value(), image->y().value()); }
FloatRect RenderSVGImage::relativeBBox(bool includeStroke) const { SVGImageElement* image = static_cast<SVGImageElement*>(node()); return FloatRect(image->x().value(), image->y().value(), width(), height()); }