Skip to content

Implement background-clip: text - #1340

Merged
nicoburns merged 3 commits into
mainfrom
devin/1793319884-background-clip-text
Oct 30, 2026
Merged

nicoburns merged 3 commits into
mainfrom
devin/1793319884-background-clip-text

Conversation

@nicoburns

@nicoburns nicoburns commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Turns on Stylo's layout.css.background-clip.text.enabled pref and paints text-clipped backgrounds.

Each run of adjacent text-clipped background layers (including the background colour when the last layer is text-clipped) is painted into an isolation layer clipped to the border box. The run is then cut down with a Compose::DestIn layer containing a text mask. This is the same technique the CSS mask code uses.

The mask comes from a new dedicated draw_text_mask traversal. It walks layout_children rather than paint_children, because in-flow stacking contexts with a z-index get hoisted out of paint_children. It skips out-of-flow, display: none and non-visible nodes, and paints glyphs and text decorations with an opaque brush (a new brush_override on stroke_text). It applies transforms, scroll offsets and overflow clips, but not opacity, filters or blend modes. The transform and clip logic is now shared with render_element through node_transform, scrolled_transform and should_clip_node.

WPT css/css-backgrounds/background-clip: 13 → 25 passing. css/css-backgrounds + css/css-masking: 805 → 816 passing.

One new failure: css/css-backgrounds/background-multiple-layers-table-cell.html. Once the pref is on, its text-clipped table-row-group layer becomes valid, but table track backgrounds only paint solid colours. Still failing, due to features out of scope here:

  • background-clip on inline boxes (clip-text-inline, which draw_inline_backgrounds doesn't handle)
  • table track gradients
  • fragmentation
  • blend modes

WPT results

Subtests: 15 newly passing, 1 newly failing (net +14).

Subtest changes by area (5 areas)
+ css                 | +14 (+15 / -1) | 59.63% -> 59.64% ( +0.01%) | 118826 -> 118840 / 199259
+   css-backgrounds   | +13 (+14 / -1) | 73.32% -> 73.51% ( +0.19%) |   5117 ->   5130 /   6979
+     background-clip | +12 (+12 / -0) | 26.00% -> 50.00% (+24.00%) |     13 ->     25 /     50
+     parsing         |  +2 ( +2 / -0) | 90.35% -> 90.57% ( +0.21%) |    843 ->    845 /    933
+   css-transitions   |  +1 ( +1 / -0) | 65.86% -> 65.93% ( +0.07%) |    924 ->    925 /   1403
Full diff (16 changed tests)
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-descendants.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-ellipsis.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-flex.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-inline-block-child.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-multi-line.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-on-body-not-propagated-to-root.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-out-of-flow-child.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-relative-child.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-stacking-context-child-002.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-stacking-context-child.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-text-decorations.html
+ FAIL => PASS    [1/1]  +1  css/css-backgrounds/background-clip/clip-text-text-emphasis.html
- PASS => FAIL    [0/1]  -1  css/css-backgrounds/background-multiple-layers-table-cell.html
+ FAIL => FAIL   [7/11]  +1  css/css-backgrounds/parsing/background-clip-computed.html
+ FAIL => FAIL    [4/9]  +1  css/css-backgrounds/parsing/background-clip-valid.html
+ FAIL => FAIL  [31/32]  +1  css/css-transitions/all-interpolates-same-as-explicit-property.html

Generated by the WPT workflow.

@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1793319884-background-clip-text branch from 7578aac to d2c9275 Compare October 30, 2026 02:58
@nicoburns
nicoburns merged commit ac6f9f5 into main Oct 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant