SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element)
Categories
(Core :: SVG, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox104 | --- | fixed |
People
(Reporter: fmuaddib, Assigned: longsonr)
References
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15
Steps to reproduce:
Just point to this url:
This is a svg frme by frame animation (pure SMIL).
Works fine on Chrome and Safari.
I also uploaded it as a gist on Github:
https://gist.github.com/Emasoft/1d87defdf81f9844ad8710e8176b7ec1
Actual results:
Blank page in Firefox (any version).
Works fine on Chrome and Safari.
Expected results:
The looping animation should have been displayed like in the other browsers.
Comment 2•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Graphics: WebRender' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•2 years ago
|
Assignee | ||
Comment 3•2 years ago
|
||
I think this is because of the width="0px" and height="0px" on the use element. The SVG 2 specification clarifies that these should be ignored if the use element points to something other than a symbol or svg element which is the case here.
Comment 4•2 years ago
•
|
||
Indeed, if you use devtools to remove those width="0px" height="0px"
attributes, then the animation plays just fine in Firefox.
The SVG 2 specification clarifies that these should be ignored if the use element points to something other than a symbol or svg element which is the case here.
Sounds like this is indeed a bug, and we should be ignoring those attributes.
Going into a bit more detail: it looks like our behavior (not-rendering the element) comes from the attribute definitions for use
in SVG 1.1 here:
https://www.w3.org/TR/SVG11/struct.html#UseElement
width = "<length>"
[...] A value of zero disables rendering of the element.
height = "<length>"
[...] A value of zero disables rendering of the element.
But indeed, SVG2 section https://www.w3.org/TR/SVG2/struct.html#UseElement clarifies this as Robert indicated:
The width and height attributes only have an effect
if the referenced element defines a viewport
(i.e., if it is a ‘svg’ or ‘symbol’);
[...]
If width or height is zero, and the properties have an effect
on the referenced element, then rendering of that element
will be disabled.
Comment 5•2 years ago
|
||
Here's a testcase getting to the root here, with <use>
pointing at a rect
element, 3 times, with width/height, just width, and just height being set to 0.
In all 3 cases, the use element should render its cloned rect, but Firefox does not render it (due to SVG1.1 spec text quoted above).
Updated•2 years ago
|
Updated•2 years ago
|
Comment 6•2 years ago
|
||
In the meantime: if you're running up against this bug in SVG content that you're writing yourself, you can avoid it by simply removing the width
and height
attributes from the use
element.
Per the quoted SVG2 spec text, those attributes are literally defined as having no effect in this case, so there shouldn't be any useful reason to have them there.
Reporter | ||
Comment 7•2 years ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #6)
In the meantime: if you're running up against this bug in SVG content that you're writing yourself, you can avoid it by simply removing the
width
andheight
attributes from theuse
element.
Yes, thanks for the suggestion. I will change my code to avoid generating those attributes for the use element.
Assignee | ||
Comment 8•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 9•2 years ago
|
||
Comment 10•2 years ago
|
||
Pushed by longsonr@gmail.com: https://hg.mozilla.org/integration/autoland/rev/ae6e6b9307a2 SVG <use> elements should render despite zero values in their width and height attributes (unless they're referencing a <svg> or <symbol> element) r=emilio
Comment 11•2 years ago
|
||
bugherder |
Assignee | ||
Updated•2 years ago
|
Description
•