border-shape from
css-borders-4
lets an element's border follow an arbitrary basic shape. This two-part stack
adds the longhand to Gecko's Rust style system
(none | [<basic-shape> <geometry-box>?]{1,2}, reusing the
existing BasicShape machinery) and then actually paints it:
a single shape is stroked with the border width, a pair of shapes fills the
area between them, the background is clipped to the outer shape, and
border-radius is ignored while border-shape is in
effect. Behind layout.css.border-shape.enabled (default on in
Nightly). Chromium already ships this; this stack makes Gecko the second
engine to render it.
Six border-shape cases (showcase.html,
open it in Chrome or a patched Nightly), rendered by the same Gecko debug
build.
Before is today's Firefox: the property
is unknown, every border paints rectangular -- note the last card, where
border-radius: 999px wins and draws a circle.
After is the patched build: stroked
circle, diamond frame with a punched-out hole, star border, rounded frame
from two inset() shapes, background clipped to the ellipse, and
border-radius correctly ignored in favor of the leaf shape.


Visual reftests from css/css-borders/border-shape/. With part 2
applied, Gecko paints the shaped border and clips the background to the outer
shape -- the full directory runs with zero unexpected results, and the
painting reftests below flip from FAIL to PASS.




Part 1 of the stack is the grammar: every suite in
css/css-borders/tentative/parsing/ passes with the pref on.
| border-shape-computed.html | 22 Fail → 22 Pass |
| border-shape-valid.html | 12 Fail → 12 Pass |
| border-shape-invalid.html | 12 Pass → 12 Pass (now rejected by the real grammar, not by "unknown property") |
# Firefox Nightly with the stack
about:config -> layout.css.border-shape.enabled = true
CSS.supports("border-shape", "circle(50%)") // true
getComputedStyle(el).borderShape // "circle(50%)" etc.
/* and it paints: */
border: 10px solid purple;
border-shape: circle(50%); /* stroked circle border */
Live probe: demo.html sets each specified value and
reads back getComputedStyle() in your browser.