+
Skip to content

svg: fix nested use nodes #3616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025
Merged

svg: fix nested use nodes #3616

merged 1 commit into from
Jul 18, 2025

Conversation

mgrudzinska
Copy link
Collaborator

Previously, only single-level references were supported. If a node pointed to another element that itself contained a node, the reference wasn’t resolved.
This has been fixed by replacing the array of postponed elements with a list. The list is traversed, and nodes aren’t cloned while they or any of their children remain unresolved. In such cases, the target element also gets added to the list, enabling recursive resolution of nested href references.

@issue: #3615

samples:
Archiwum.zip

before:
Zrzut ekranu 2025-07-14 o 23 29 10

after:
Zrzut ekranu 2025-07-14 o 23 28 52

@mgrudzinska mgrudzinska self-assigned this Jul 14, 2025
@mgrudzinska mgrudzinska requested a review from JSUYA as a code owner July 14, 2025 21:31
@mgrudzinska mgrudzinska added the svg SVG features label Jul 14, 2025

This comment was marked as outdated.

This comment was marked as outdated.

@mgrudzinska mgrudzinska force-pushed the mira/svg branch 2 times, most recently from 9615549 to 8812667 Compare July 14, 2025 21:54
@thorvg thorvg deleted a comment from github-actions bot Jul 14, 2025
@thorvg thorvg deleted a comment from github-actions bot Jul 14, 2025
@hermet hermet requested a review from Copilot July 15, 2025 01:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes support for nested <use> nodes in SVG parsing by implementing recursive resolution of href references. Previously, only single-level <use> references were supported, causing rendering issues when a <use> node referenced another element that itself contained <use> nodes.

Key changes:

  • Replaced Array-based postponed element tracking with an Inlist for better traversal control
  • Added recursive checking to prevent cloning nodes with unresolved dependencies
  • Implemented proper memory management for the new list-based approach

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/loaders/svg/tvgSvgLoaderCommon.h Updated SvgNodeIdPair structure and changed cloneNodes from Array to Inlist
src/loaders/svg/tvgSvgLoader.cpp Added recursive dependency checking and updated postponed node processing logic

@mgrudzinska mgrudzinska force-pushed the mira/svg branch 3 times, most recently from 05b06fa to bc0bf97 Compare July 17, 2025 20:57
@mgrudzinska mgrudzinska requested review from hermet and JSUYA July 17, 2025 21:00
Copy link
Member

@JSUYA JSUYA left a comment

Choose a reason for hiding this comment

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

LGTM

Previously, only single-level <use> references were supported.
If a <use> node pointed to another element that itself contained
a <use> node, the reference wasn’t resolved.
This has been fixed by replacing the array of postponed elements
with a list. The list is traversed, and nodes aren’t cloned while
they or any of their children remain unresolved. In such cases,
the target element also gets added to the list, enabling recursive
resolution of nested href references.

issue: #3615
@hermet hermet merged commit d8bbb0d into main Jul 18, 2025
15 checks passed
@hermet hermet deleted the mira/svg branch July 18, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
svg SVG features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载