Open Bug 1916030 Opened 2 months ago Updated 2 months ago

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)

defect

Tracking

()

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

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.

Blocks: 1906145
Summary: Firefox fails to paint svg-as-an-image if it has a defined width or height of 0 and no viewBox → Firefox fails to paint svg-as-an-image, if the svg element has a width or height of 0 and no viewBox

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).

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).

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: