Apply root element margins and propagate body background to the canvas - #640
Open
nicoburns wants to merge 1 commit into
Open
Apply root element margins and propagate body background to the canvas#640nicoburns wants to merge 1 commit into
nicoburns wants to merge 1 commit into
Conversation
The root element's margins offset its border box within the viewport (they never collapse with descendants per CSS2 8.3.1), but compute_root_layout always positions the border box at the origin. When the root element's background is entirely transparent/none, the body's background propagates to the canvas (CSS Backgrounds 2.11.2): it is painted across the whole canvas with its positioning area determined as if it were painted for the root element, and the body does not paint it again itself. Fixes WPT margin-collapse-020/021.
Contributor
🤖 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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes WPT
css/CSS2/margin-padding-clear/margin-collapse-020.xhtandmargin-collapse-021.xht.Two related root/body issues:
Root element margins —
taffy::compute_root_layoutresolves the root element's margins but always positions its border box at the origin.resolve_layoutnow offsets the root'slocationby its resolved margins after root layout (RTL-aware for the horizontal axis); per CSS2 §8.3.1 the root's margins never collapse with descendants.Body background propagation (CSS Backgrounds §2.11.2) — when the root element's background is entirely transparent/none, the
body's background propagates to the canvas. Previously only the body's background color was used as the canvas color while the body still painted its background at its own position; with root margins applied this left the canvas mispositioned relative to the test's expectation.BlitzDomPainternow resolves acanvas_bg_body_idup front; that body's background (color and images) is painted for the canvas with its positioning area determined as if it were painted for the root element, and is skipped during the body's own painting:background_is_nonechecks bothbackground-color: transparentand allbackground-image: none, so a root with only a background image (as in margin-collapse-020) correctly prevents propagation.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/19d83a7d94fb4e43a489abaa566115ba
Requested by: @nicoburns
WPT results
16 newly passing, 7 newly failing (net +9).
Full diff (23 changed tests)
Generated by the WPT workflow.