Skip to content

svg: move stylesheet parsing and matching to craft-svg - #3797

Merged
dylanmtaylor merged 4 commits into
mainfrom
refactor/shared-svg-stylesheet
Nov 17, 2026
Merged

dylanmtaylor merged 4 commits into
mainfrom
refactor/shared-svg-stylesheet

Conversation

@dylanmtaylor

@dylanmtaylor dylanmtaylor commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Remove EffectCraft's local simple CSS stylesheet parser, selector index and matcher in favor of craft_svg::simple_css.
  • Keep the exact element tag/id/classes and aggregate matching-work callback, specificity/source order and inline overrides.
  • Preserve float color values and malformed SVG path behavior: neither color nor path parsing changes in this slice.
  • Move three structural parser tests alongside the implementation in the shared prerequisite; retain the app's rendered styles, hostile CSS work, selector/declaration limits and SVG integration tests.

Dependency and scope

Depends on storytold/craft-libs#1968, pinned at c3d9015ec985450386a86b04713d6f1cee597951. Do not merge until the shared PR lands, the pin is updated to merged main and fresh hosted gates pass. Shared adds an explicit 64 MiB aggregate stylesheet-text limit before copying. This is a complete stylesheet parser/matcher route, not the complete SVG parser cutover.

Shared source preserves FredApps and NetterSilver as primary authors of their respective port commits. NetterSilver's nested at-rule skip and regression test are retained. The dependency update prunes unused image-codec transitive packages because shared craft-svg made those dependencies optional behind tree; Effect's existing feature set is unchanged.

Validation

  • Six tiny standalone shared tests passed, including copied structural tests, matching order, budgets, accepted malformed prefix and limits.
  • Locked metadata, rustfmt of edited Rust and CRLF-aware whitespace checks passed.
  • Independent source review found no blocking cascade/matcher behavior change.
  • Full app/workspace tests have not run locally; hosted gates are required. No rendering or full parity-corpus pass is claimed.

Summary by CodeRabbit

  • Improvements
    • Improved handling of CSS stylesheets and inline styles in SVG content. Supported CSS rules and inline declarations are processed consistently, helping supported styling appear more reliably in rendered graphics. No new styling capabilities are added.

Integration update

Shared #1968 merged as 006ed3d965d5f3b77829b87a43eacd5ca0b4f997. Consumer now pins that merged commit at head b29778b577fc58429137db5f7753c08172267637, with current Effect main integrated. Fresh hosted gates are required; earlier green checks do not cover this repin. The shared revision includes the merged SVG guard literal-marker hardening; CSS implementation is unchanged. Metadata --locked and whitespace checks passed for this update.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The SVG crate now uses shared CSS parsing and rule matching from craft_svg::simple_css. The craft-svg dependency revision changed, and two tests of the removed local parser were deleted.

Changes: SVG CSS handling

Layer / File(s) Summary
Shared CSS parsing and rule application
Cargo.toml, crates/svg/src/lib.rs, crates/svg/src/tests.rs
craft-svg now points to revision af9985523a079c9e25c638003dbd9aa09fa4d254. SVG CSS parsing and inline declarations use shared APIs. Rule matching delegates to the shared stylesheet and passes charge_css as the work-budget callback. Two tests of the removed local parser are deleted.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: fredapps, echelon

Merge Risk: Minimal · up to f65ad

This change moves SVG stylesheet parsing and matching to the shared craft-svg crate without any identified behavior regression. Rendering behavior should be unchanged. Confirm that the CI gates pass on the updated dependency before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: stylesheet parsing and matching move from the local EffectCraft implementation to the shared craft-svg crate. The raw summary confirms crates/svg/src/lib.rs now delega…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: stylesheet parsing and matching move from the local EffectCraft implementation to the shared craft-svg crate. The raw summary confirms crates/svg/src/lib.rs now delegates CSS parsing, rule indexing, and matching to craft_svg::simple_css, and the Cargo.toml pin is updated to support that move. The title is concise and specific, and it uses a conventional 'area: summary' form.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b29778b and f65ad2a.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 1

  • Cargo.toml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

@sonarqubecloud

Copy link
Copy Markdown

@dylanmtaylor
dylanmtaylor merged commit c7068ae into main Nov 17, 2026
12 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