Per SVG 2, SVGGraphicsElement.getBBox() must return an empty rect
(x=y=width=height=0) for a shape that is not rendered: a degenerate
geometry (rect with width=0/height=0,
circle with r=0, ellipse with
rx=0/ry=0) or a shape with a non-rendered ancestor
(<symbol>, <defs>,
<clipPath>, ...). Firefox and Safari return the empty rect;
pre-fix Blink returned the geometry-derived box.
The CL gates the new behavior behind a default-on kill switch
(SvgEmptyBBoxForNonRendered).
A single SVG with three non-rendered shapes: a zero-width rect, a
zero-radius circle, and a rect that only lives inside
a <symbol>. JS draws a dashed amber overlay from each
shape's getBBox(). Captured with headless_shell with
the SvgEmptyBBoxForNonRendered runtime feature toggled off and on
(demo source).
Each row calls getBBox() on the shape with the given id and
compares the result to the SVG 2 expected value. Open this page in your
browser; a fixed Chrome shows pass for every
row, pre-fix Chrome shows fail for the degenerate
cases.
| case | expected | got | verdict |
|---|
<svg width="0" height="0">
<rect id="r" x="10" y="20" width="0" height="50"/>
<circle id="c" cx="10" cy="20" r="0"/>
<ellipse id="e" cx="10" cy="20" rx="0" ry="30"/>
</svg>
<script>
console.log(JSON.stringify(document.getElementById('r').getBBox()));
console.log(JSON.stringify(document.getElementById('c').getBBox()));
console.log(JSON.stringify(document.getElementById('e').getBBox()));
</script>