Skip to content

Refactor background layer tiling into per-axis helpers - #645

Open
nicoburns wants to merge 1 commit into
mainfrom
devin/1786159426-bg-tiling-refactor
Open

Refactor background layer tiling into per-axis helpers#645
nicoburns wants to merge 1 commit into
mainfrom
devin/1786159426-bg-tiling-refactor

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Preparatory refactor for background-attachment: collapses the duplicated per-axis repeat/tiling math in draw_raster_image_layer and draw_gradient_layer into two pure per-axis helpers returning a uniform plan:

struct AxisTiling { translate: f64, rect_len: f64, count: u32, gap: f64 }

fn raster_axis_tiling(repeat, origin_start, origin_len, bg_pos, tile_len, image_len, ratio) -> AxisTiling
fn gradient_axis_tiling(repeat, origin_start, origin_len, clip_start, clip_len, bg_pos, tile_len) -> AxisTiling

Both draw fns now reduce to: compute x/y plans, build one transform from x.translate/y.translate, and run a single count × count fill loop. The layer geometry (positioning-area rect + translation) is now computed in exactly one place per path, so background-attachment: fixed/local can later be implemented by adjusting the axis inputs at a single site.

Semantics preserved, with two intentional deviations:

  • The gradient Repeat/Round special cases for the three (clip ⊃ origin) box pairs are generalized geometrically: tiling starts from the clip box edge whenever clip_start < origin_start, replacing the exhaustive (BorderBox, PaddingBox)-style tuple matches (equivalent for all existing combinations).
  • Fixes copy-paste bugs in the old gradient y-axis code, which used bg_pos_x instead of bg_pos_y in three extend(...) calls (affecting vertically-repeating gradients with a non-zero vertical background position).

Verified no regressions: just wpt css/css-backgrounds produces byte-identical per-test results before/after (250/705 passing, zero status changes).

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/adffb5f273074c819eda1794acd87032
Requested by: @nicoburns

WPT results

No changes in test results compared to main.

Generated by the WPT workflow.

@nicoburns nicoburns self-assigned this Aug 8, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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