Skip to content

usvg: allow building Tree programmatically (part 1: tree , path , group, fill, stroke) - #1137

Closed
mu-mostafa98 wants to merge 1 commit into
linebender:mainfrom
mu-mostafa98:usvg-for-servo-path-only
Closed

mu-mostafa98 wants to merge 1 commit into
linebender:mainfrom
mu-mostafa98:usvg-for-servo-path-only

Conversation

@mu-mostafa98

Copy link
Copy Markdown

Servo web engine builds usvg::Tree from XML, so only presentation attributes reach the renderer and the CSS cascade can't affect SVG (only inline style works).

To honor post-cascade computed values, Servo needs to build the tree programmatically instead.

Changes

Made public

  • Group::empty()
  • Path::new(...)

Implemented

  • setters for all fill data members
  • setters for all stroke data members
  • setters for group data members id, opacity
  • Group::push_child
  • Tree::new(size, root)
  • Stroke::default()

Only the usvg crate changes; resvg is untouched.
Later PRs add the remaining node kinds.

Signed-off-by: Mohamed Mostafa <mu.mostafa98@gmail.com>
@LaurenzV

Copy link
Copy Markdown
Collaborator

Sorry, but I'm not sure we are going to make the usvg:Tree modifiable. This actually was the case in the past, but we decided to make it read-only, allowing us to significantly simplify the implementation. See also #710 for some more context.

Giving users the ability to modify the tree arbitrarily could lead to unpredictable behavior because it might break assumptions we hold internally about the structure of the tree. It's definitely unfortunate, but given that we barely have any resources/time to maintain this library as is, I don't think it makes sense to attempt to expand the functionality provided even more. :(

@RazrFalcon

Copy link
Copy Markdown
Collaborator

Yes, the tree is read-only by design. This cannot and will not be changed anytime soon.

@mu-mostafa98

Copy link
Copy Markdown
Author

Thank you for clarifying the problem.

@mu-mostafa98
mu-mostafa98 deleted the usvg-for-servo-path-only branch September 24, 2026 04:27
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.

3 participants