Firefox fails to paint svg-as-an-image, if the svg element has a width or height of 0 and no viewBox
Categories
(Core :: SVG, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox139 | --- | fixed |
People
(Reporter: dholbert, Assigned: dholbert)
References
Details
Attachments
(6 files, 1 obsolete file)
Filing this as the underlying defect behind our WPT failure in bug 1906145.
Essentially, if an SVG image lacks a viewBox, and has a zero-sized width or height, then I think we synthesize a zero-sized viewBox from its width and height, and that means we don't paint anything when the image draws (because we scale up a zero-sized area to fill the image element's bounds, or something like that).
Other browsers do in fact paint in this case, though -- I suspect because they just decline to synthesize a viewBox from the SVG image's height and width, and they instead just use a viewBox based on the area that we're rendering to (the image element), or something along those lines.
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 1•1 year ago
|
||
| Assignee | ||
Comment 2•1 year ago
|
||
| Assignee | ||
Comment 3•1 year ago
|
||
| Assignee | ||
Comment 4•1 year ago
|
||
In all three testcases, we fail to paint the SVG in the top half of the testcase, whereas other engines reliably paint (when there's area to be painted).
Specifically:
- Firefox renders the top half with no cyan (i.e. not painting any content from the SVG image)
- Chromium renders the the top half with cyan backgrounds (for the img elements that are nonzero-sized).
- WebKit renders the top half with cyan backgrounds. (They also render all the img elements as being nonzero-sized, which disagrees with us and Chrome -- this sizing behavior is probably a WebKit bug).
| Assignee | ||
Comment 5•1 year ago
•
|
||
When fixing this, I plan to include (possibly-evolved-a-bit) versions of those 3 testcases as WPTs, along with similar tests for <embed>, <svg:image>, SVG-as-a-background-image-with-background-size, etc. (in all cases having width and/or height set to 0 on the <svg> element, but nonzero width and/or height on the embedding context).
| Assignee | ||
Comment 6•7 months ago
|
||
Try run with implementation changes, but still needing some new tests:
https://treeherder.mozilla.org/jobs?repo=try&revision=1b3d051ece5df8981c7ce4c7271444e7786e3ef0
| Assignee | ||
Comment 7•7 months ago
|
||
This patch doesn't change behavior; it's just moving existing logic to a helper
function, so that the next patch in the series can add an additional use of
this helper-function.
| Assignee | ||
Comment 8•7 months ago
|
||
| Assignee | ||
Comment 9•7 months ago
|
||
As discussed in (ancient) bug 614649: for SVG images that have a specified
'width' and/or 'height' on their root <svg> element, we need to synthesize a
viewBox using that width and/or 'height', in order for the SVG content to scale
up or down to fill an <img> element of a different size (rather than just
rendering at its native resolution into a viewport of that size, padding or
clipping its coordinate space).
But notably, we should not synthesize a viewBox if either 'width' or 'height'
are 0 (or 0%), because a 0-sized viewBox would result in nothing being
painted. That's the main thing that this new testcase is focusing on testing.
| Assignee | ||
Comment 10•7 months ago
|
||
Updated•7 months ago
|
Comment 11•7 months ago
|
||
Comment 13•7 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/4fafa6c67ac8
https://hg.mozilla.org/mozilla-central/rev/010466b2a459
https://hg.mozilla.org/mozilla-central/rev/081370c77dc9
Updated•7 months ago
|
Description
•