WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
52045
SVG image in HTML changes size as the window is resized
https://bugs.webkit.org/show_bug.cgi?id=52045
Summary
SVG image in HTML changes size as the window is resized
Simon Fraser (smfr)
Reported
2011-01-06 22:14:55 PST
Created
attachment 78209
[details]
SVG image for testcase I'm seeing a very weird effect with butterfly.svg in an <img> element. Testcase coming.
Attachments
SVG image for testcase
(30.46 KB, image/svg+xml)
2011-01-06 22:14 PST
,
Simon Fraser (smfr)
no flags
Details
Testcase
(301 bytes, text/html)
2011-01-06 22:16 PST
,
Simon Fraser (smfr)
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Simon Fraser (smfr)
Comment 1
2011-01-06 22:16:44 PST
Created
attachment 78210
[details]
Testcase For some reason, the butterfly image in the <img> changes size based on the window size.
Nikolas Zimmermann
Comment 2
2011-01-07 01:30:20 PST
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?
Simon Fraser (smfr)
Comment 3
2011-01-07 22:10:41 PST
> void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout) > { > bool layoutSizeChanged = false; //findTreeRootObject(start)->isLayoutSizeChanged(); > > Does the problem disappear?
No.
Simon Fraser (smfr)
Comment 4
2011-01-07 22:17:14 PST
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?
Beth Dakin
Comment 5
2011-01-10 11:35:53 PST
(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.
Simon Fraser (smfr)
Comment 6
2011-01-10 11:37:52 PST
(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.
Beth Dakin
Comment 7
2011-01-10 11:43:38 PST
(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.
Tim Horton
Comment 8
2011-07-07 14:13:52 PDT
<
rdar://problem/5812360
>
Nikolas Zimmermann
Comment 9
2011-07-23 05:02:07 PDT
47156 fixes this.
Nikolas Zimmermann
Comment 10
2011-10-31 08:31:03 PDT
Fixed in
r98852
. Thanks for the testcase!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug