Skip to content

Support patternContentUnits=objectBoundingBox for pattern fills#120

Merged
swhitty merged 1 commit into
swhitty:mainfrom
rursache:fix/52-base64-image-in-pattern
Apr 22, 2026
Merged

Support patternContentUnits=objectBoundingBox for pattern fills#120
swhitty merged 1 commit into
swhitty:mainfrom
rursache:fix/52-base64-image-in-pattern

Conversation

@rursache
Copy link
Copy Markdown
Contributor

Summary

  • Implement patternContentUnits="objectBoundingBox" support for pattern fills
  • When this attribute is set, pattern coordinates are in [0,1] range relative to the filled element's bounding box
  • The pattern frame is now scaled to the shape's bounding box at render time
  • Also fixes a bug in firstGraphicsElement(with:) where the search would stop prematurely at the first container element, even if the target element was a later sibling

Test plan

  • Added testDOMPatternObjectBoundingBox() verifying objectBoundingBox patterns preserve content units
  • Added testDOMPatternUserSpaceOnUse() verifying default patterns use userSpaceOnUse
  • Added firstGraphicsElementSearchesPastContainers() verifying element lookup doesn't stop at containers
  • All 196 tests pass

Closes #52

When a pattern uses patternContentUnits="objectBoundingBox", scale
the pattern frame to the bounding box of the filled element. This
fixes rendering of patterns that reference images via <use> elements
in <defs>, where the pattern coordinates are in [0,1] range.

Also fixes a bug in firstGraphicsElement(with:) where the search
would stop prematurely at the first container element, even if the
target element was a later sibling.

Closes #52
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 77.96610% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.37%. Comparing base (6238058) to head (ea017f7).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...Sources/LayerTree/LayerTree.CommandGenerator.swift 28.57% 10 Missing ⚠️
...wiftDraw/Sources/LayerTree/LayerTree.Pattern.swift 50.00% 2 Missing ⚠️
DOM/Sources/DOM.Use.swift 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
+ Coverage   89.02%   89.37%   +0.35%     
==========================================
  Files         159      159              
  Lines       11959    15441    +3482     
==========================================
+ Hits        10646    13801    +3155     
- Misses       1313     1640     +327     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swhitty swhitty merged commit d3f21a2 into swhitty:main Apr 22, 2026
10 of 11 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.

Embedded Base64 image isn’t rendered

2 participants