Propagate root/body backgrounds to the canvas - #672
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
WPT regression sweep (all
|
| Test | Pre-existing limitation exposed |
|---|---|
css-transforms/perspective-split-by-zero-w.html |
perspective plane with w<0 split not rendered; the ref's z-index:-1 red detector patch only becomes visible once body bg correctly paints in the canvas layer |
css-images/linear-gradient-body-sibling-index.html |
sibling-index() in gradients unsupported (body bg was previously never painted at all: body height 0) |
css-image-animation/image-animation-body-background-no-propagation-paused.html |
GIF animation unsupported (same vacuous-pass story on main) |
Most interesting one — on main the ref's red "missing content" detector was hidden under the body background (wrong paint order); with propagation it correctly shows where the perspective plane isn't rendered:
linear-gradient-body-sibling-index (branch ref now correctly paints the propagated gradient; test misses it for lack of sibling-index support)
b72b836 to
6647af4
Compare
…ws under propagated backgrounds
6647af4 to
4ebb335
Compare
Summary
Fixes the
css/CSS2/backgrounds/background-root-*WPT tests (+30 net passes acrosscss/CSS2,css/css-backgrounds,css/css-flexbox,css/css-grid,css/css-position).Canvas background propagation (
blitz-paint): the root element's background (or the<body>'s, when the root's is entirely transparent) now propagates to the canvas per CSS2 §14.2:BlitzDomPainterresolves acanvas_bg_source_idand paints that element's background color and image layers over the whole canvas inpaint_scene, before rendering the tree.painting_rect_overrideonElementCx.draw_backgroundskips the source element so the propagated background isn't painted twice.Root element margin (
blitz-dom):resolve_layoutnow offsets the root element's box by its margin (taffy'scompute_root_layoutresolves the margin into the available size but leaveslocationat the origin). Required by mostbackground-root-*tests, and also fixesroot-box-001and twomargin-collapsetests.Repeat over the painting area (
blitz-paint):repeat/round/spacetiles now cover the background painting area (clip box, or whole canvas for the canvas background) rather than just the positioning area:This replaces the previous per-
(clip, origin)-combination special cases with a general formula, and makes e.g. tiles visible beneath translucent borders (as in thebackground-repeat-space-8reference).Outset box-shadow clipping: an element whose background propagates to the canvas paints no background of its own, so its outset shadow is now always clipped out of its border box (previously an opaque background was assumed to cover it).
Test results
Before/after comparison over
css/CSS2 css/css-backgrounds css/css-flexbox css/css-grid css/css-position: 30 tests fixed, 1 newly failing:css/CSS2/backgrounds/background-position-002.xht— the test page now renders correctly (body background propagated to canvas), but its reference page renders wrong due to a pre-existing bug: an absolutely positionedheight: 100%element resolves its height against the body instead of the initial containing block. Previously both pages were wrong in the same way, so the test "passed".Still failing (pre-existing, separate issues):
background-root-023(fixed-position offset affected by sibling margin),background-root-101/102/103(require script support).Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/cd28e74e905344f3b4530021070cd6b1
Requested by: @nicoburns
WPT results
37 newly passing, 4 newly failing (net +33).
Full diff (41 changed tests)
Generated by the WPT workflow.