Implement border-shape in Gecko

bug 1982766 D341191 (parse) D341208 (paint) css-borders-4

What

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.

status Part 1 (parsing + computation) in review as D341191 (r?emilio); part 2 stacks painting of borders and background clipping on top. Outline, box-shadow and child-content clipping along the shape are follow-ups.
151reftest subtests green in css-borders/border-shape/
0unexpected results in the full directory sweep
46parsing subtests, computed / valid / invalid
2patches: D341191 parse, D341208 paint

It paints: before and after

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.

showcase.html -- six painted border-shape cases rectangles→shapes
Before today's Firefox: every border is a rectangle
before: all six cases paint rectangular borders, border-radius still applies
After patched build: borders follow the shapes
after: circle stroke, diamond frame, star border, rounded inset frame, clipped ellipse, leaf shape

WPT reftests

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.

Reference what it should look like
reference: green circle with purple ring
Gecko with part 2 painted by this patch
gecko: purple ring stroked along the circle, background clipped to the shape
Reference what it should look like
reference rendering
Gecko with part 2 painted by this patch
gecko: yellow diamond filled between outer polygon and inner circle

Parsing suites

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

Try it

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