Created attachment 78209 [details] SVG image for testcase I'm seeing a very weird effect with butterfly.svg in an <img> element. Testcase coming.
Created attachment 78210 [details] Testcase For some reason, the butterfly image in the <img> changes size based on the window size.
Ouch, stupid bug. One of the many cases, where we're not taking care of the SVG embedded in HTML correctly. If you set isLayoutSizeChanged to false, hardcoded in SVGRenderSupport.cpp: void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout) { bool layoutSizeChanged = false; //findTreeRootObject(start)->isLayoutSizeChanged(); Does the problem disappear?
> void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout) > { > bool layoutSizeChanged = false; //findTreeRootObject(start)->isLayoutSizeChanged(); > > Does the problem disappear? No.
This seems to be related to this code in RenderImage::computeReplacedLogicalWidth(): if (m_imageResource->imageHasRelativeWidth()) if (RenderObject* cb = isPositioned() ? container() : containingBlock()) { if (cb->isBox()) m_imageResource->setImageContainerSize(IntSize(toRenderBox(cb)->availableWidth(), toRenderBox(cb)->availableHeight())); } which was added in http://trac.webkit.org/changeset/28856 I don't grok why the image container size would be relative to the size of the containing block. Beth, do you recall?
(In reply to comment #4) > This seems to be related to this code in RenderImage::computeReplacedLogicalWidth(): > > if (m_imageResource->imageHasRelativeWidth()) > if (RenderObject* cb = isPositioned() ? container() : containingBlock()) { > if (cb->isBox()) > m_imageResource->setImageContainerSize(IntSize(toRenderBox(cb)->availableWidth(), toRenderBox(cb)->availableHeight())); > } > > which was added in http://trac.webkit.org/changeset/28856 > > I don't grok why the image container size would be relative to the size of the containing block. Beth, do you recall? I don't recall all of the specifics…but I think that we decided to treat SVG-as-image as a regular image with width:100%, which would calculate based on the containing block.
(In reply to comment #5) > (In reply to comment #4) > > This seems to be related to this code in RenderImage::computeReplacedLogicalWidth(): > > > > if (m_imageResource->imageHasRelativeWidth()) > > if (RenderObject* cb = isPositioned() ? container() : containingBlock()) { > > if (cb->isBox()) > > m_imageResource->setImageContainerSize(IntSize(toRenderBox(cb)->availableWidth(), toRenderBox(cb)->availableHeight())); > > } > > > > which was added in http://trac.webkit.org/changeset/28856 > > > > I don't grok why the image container size would be relative to the size of the containing block. Beth, do you recall? > > I don't recall all of the specifics…but I think that we decided to treat SVG-as-image as a regular image with width:100%, which would calculate based on the containing block. But in this testcase the image has a fixed size. I don't see why the containing block would come into it.
(In reply to comment #6) n this testcase the image has a fixed size. I don't see why the containing block would come into it. Yeah, I definitely agree that there is a bug in the code.
<rdar://problem/5812360>
47156 fixes this.
Fixed in r98852. Thanks for the testcase!