Files
shinyobjectz 3892ac4367 background-clip: text clips a background to the element's text, as Chrome does (closes #37). Gradient text, a common headline style, came out as a gradient box with the text invisible. Two gaps: the vendored stylo knew the text value only for Gecko, so in Servo mode the declaration didn't parse (and #34's note didn't list it: stylo doesn't report a drop of a property the block already set, here through its background shorthand), and blitz-paint had no text clip. Now stylo takes text for Servo too, and blitz-paint draws a background with a text clip in a group that the text then masks (Compose::DestIn). The mask is the element's own inline layout plus the text of every element inside it, at its place (draw_text_mask: glyphs opaque, without their shadows). A scroller's offset isn't applied inside the mask.
Test: bench/background-clip-text/check.sh draws "Gradient" three ways: with background-clip, with -webkit-background-clip alone, and through a block inside the clipped one. The G's stem must be the gradient's pink, and the box beside and above each word must be the page's #111, as Chrome 148 gives them. Before: 6 of 10 pixels failed (the gradient box). After: PASS. TSX's backgroundClip and WebkitBackgroundClip, and an inline <span> inside, also match Chrome by eye.

fps, the same 300-frame page with three clipped lines, before (17:54 build) and after, back to back in three rounds: 493/542/533 vs 518/599/489 fps incl. encode, no cost beyond the noise.
2026-11-07 18:28:19 -08:00

11 lines
878 B
HTML

<!doctype html><html><body style="margin:0;background:#111">
<!-- #37: gradient text. The first line clips its background to its text with background-clip, the second with
-webkit-background-clip alone (as older Tailwind and most snippets write it), the third through a block inside
the clipped one, whose text is in the clip too. bench/background-clip-text/check.sh -->
<div data-composition-id="main" data-start="0" data-duration="1" data-width="640" data-height="360" style="font:bold 96px sans-serif;line-height:120px;color:transparent">
<div style="background:linear-gradient(90deg,#f0c,#0cf);background-clip:text">Gradient</div>
<div style="background:linear-gradient(90deg,#f0c,#0cf);-webkit-background-clip:text">Gradient</div>
<div style="background:linear-gradient(90deg,#f0c,#0cf);background-clip:text"><div>Gradient</div></div>
</div>
</body></html>