Skip to content

Added support for mask-type style in mask attribute.#476

Merged
wieslawsoltes merged 5 commits into
wieslawsoltes:masterfrom
Lev02:SvgMaskType
Apr 22, 2026
Merged

Added support for mask-type style in mask attribute.#476
wieslawsoltes merged 5 commits into
wieslawsoltes:masterfrom
Lev02:SvgMaskType

Conversation

@Lev02
Copy link
Copy Markdown

@Lev02 Lev02 commented Mar 24, 2026

@awp-sirius
Copy link
Copy Markdown

Great!
This would be very useful for us.

@wieslawsoltes
Copy link
Copy Markdown
Owner

@codex full review, also validate its part of SVG static subset we support

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: f5fc95866f

ℹ️ 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".

if (Element != null
&& Element.TryGetAttribute("mask-type", out var maskTypeStr))
{
maskType = maskTypeStr == "alpha" ? MaskType.Alpha : MaskType.Luminance;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse mask-type value case-insensitively

The new mask-type parsing treats only the exact lowercase string "alpha" as alpha mode, but CSS keyword values are case-insensitive. Valid inputs like mask-type: Alpha (or other casing variants) will incorrectly fall back to luminance masking, producing different rendering than specified for alpha masks.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fix dc8f465

{
var maskType = MaskType.Luminance;
if (Element != null
&& Element.TryGetAttribute("mask-type", out var maskTypeStr))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Read mask-type from stylesheet-applied styles

Using TryGetAttribute("mask-type", ...) here misses most stylesheet-driven values because the underlying SVG style store returns only inline/presentation style keys for unknown properties. As a result, mask-type set via <style> selectors (for example class/element selectors) is ignored and masks are rendered as luminance instead of alpha.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Parsing of mask-type, which was set via selectors is a heavy performance task, which requires using reflection in that case. In my opinion it is redundant to cover that case.

@wieslawsoltes
Copy link
Copy Markdown
Owner

@Lev02 Please fix branch conflicts

# Conflicts:
#	src/Svg.Model/Drawables/DrawableBase.cs
#	src/Svg.Model/Drawables/Elements/MaskDrawable.cs
@Lev02
Copy link
Copy Markdown
Author

Lev02 commented Apr 10, 2026

@Lev02 Please fix branch conflicts

done

@awp-sirius
Copy link
Copy Markdown

Hey, when can we expect this in master?

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.

3 participants