LayoutUnit RenderImage::computeReplacedLogicalWidth(bool includeMaxWidth) const { // If we've got an explicit width/height assigned, propagate it to the image resource. if (style()->logicalWidth().isFixed() && style()->logicalHeight().isFixed()) { LayoutUnit width = RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth); m_imageResource->setContainerSizeForRenderer(IntSize(width, computeReplacedLogicalHeight())); return width; } IntSize containerSize; if (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight()) { // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative. RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock(); if (containingBlock->isBox()) { RenderBox* box = toRenderBox(containingBlock); containerSize = IntSize(box->availableWidth(), box->availableHeight()); // Already contains zooming information. } } else { // Propagate the current zoomed image size to the image resource, otherwhise the image size will remain the same on-screen. CachedImage* cachedImage = m_imageResource->cachedImage(); if (cachedImage && cachedImage->image()) { containerSize = cachedImage->image()->size(); // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656 containerSize.setWidth(static_cast<LayoutUnit>(containerSize.width() * style()->effectiveZoom())); containerSize.setHeight(static_cast<LayoutUnit>(containerSize.height() * style()->effectiveZoom())); } } if (!containerSize.isEmpty()) { m_imageResource->setContainerSizeForRenderer(containerSize); const_cast<RenderImage*>(this)->updateIntrinsicSizeIfNeeded(containerSize, false); } return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth); }