Skip to content

Handle <use> children in clipPath collection and add unit test#432

Merged
jwmcglynn merged 5 commits intomainfrom
codex/fix-bug-in-issue-238
Apr 5, 2026
Merged

Handle <use> children in clipPath collection and add unit test#432
jwmcglynn merged 5 commits intomainfrom
codex/fix-bug-in-issue-238

Conversation

@jwmcglynn
Copy link
Copy Markdown
Owner

@jwmcglynn jwmcglynn commented Apr 5, 2026

Motivation

  • Ensure clip paths can reference shapes via direct <use> children and simplify clip-path collection logic.

Description

  • Factored extraction logic into an appendClipPathFromEntity lambda inside RenderingContext::collectClipPaths to reduce duplication and centralize visibility/display checks.
  • Added support for <use> children by detecting ElementType::Use and walking the ComputedShadowTreeComponent mainBranch to collect clip paths from shadowed entities.
  • Re-enabled the previously skipped e-clipPath-044.svg test in the resvg test instantiation and added a new unit test SVGClipPathElementTests.RenderingUseChild that verifies a clipPath with a direct use child renders correctly.

Testing

  • Ran unit tests in donner/svg/tests, including SVGClipPathElementTests.RenderingUseChild, and they passed.
  • Ran the image comparison test suite (resvg_test_suite) for the ClipPath group with e-clipPath-044.svg now enabled, and the suite passed.

Resolves #238


Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd1a310a8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread donner/svg/renderer/RenderingContext.cc Outdated
Comment on lines +396 to +399
if (const auto* computedShadow = child.try_get<ComputedShadowTreeComponent>();
computedShadow && computedShadow->mainBranch) {
for (const Entity shadowEntity : computedShadow->mainBranch->shadowEntities) {
appendClipPathFromEntity(EntityHandle(registry_, shadowEntity));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor visibility before expanding clip-path shadow tree

collectClipPaths expands mainBranch->shadowEntities for every <use> child here, but this path never checks whether the <use> element itself is renderable first. In a <clipPath>, a <use display="none"> should contribute no geometry, yet its shadow entities are still appended (their own display defaults to visible), producing a non-empty clip and incorrect rendering. Gate this expansion on the <use> child’s computed display/visibility (or propagate ancestor display-none state while walking the shadow tree).

Useful? React with 👍 / 👎.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

❌ Patch coverage is 73.68421% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.74%. Comparing base (199cd20) to head (94d565d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
donner/svg/renderer/RenderingContext.cc 73.68% 6 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #432      +/-   ##
==========================================
- Coverage   78.77%   78.74%   -0.04%     
==========================================
  Files         268      268              
  Lines       18499    18534      +35     
  Branches     3351     3359       +8     
==========================================
+ Hits        14572    14594      +22     
- Misses       3091     3097       +6     
- Partials      836      843       +7     
Flag Coverage Δ
unittests 78.74% <73.68%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…t targets

Shadow entities from <use> elements don't carry shape data directly — they
reference a light entity via ShadowEntityComponent. The clip path collection
now resolves shadow entities to their light entity for ComputedPathComponent
lookup, and only checks the shadow root (not all descendants) to correctly
reject <use> references to <g> or <symbol> elements.
@jwmcglynn jwmcglynn force-pushed the codex/fix-bug-in-issue-238 branch from e3e8a6e to 94d565d Compare April 5, 2026 07:36
@jwmcglynn jwmcglynn merged commit 583a9b3 into main Apr 5, 2026
15 checks passed
@jwmcglynn jwmcglynn deleted the codex/fix-bug-in-issue-238 branch April 5, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<clipPath> support for <use> elements

1 participant