Skip to content

Commit 345fce9

Browse files
committed
Keep empty SVG documents safe during backdrop discovery
Guard absent root nodes when detecting background inputs and wrapping root filter, clipping, transform and opacity. Preserve an empty DrawingGroup for a newly constructed SVG with filters either enabled or disabled. Add both cases to the WPF regression executable and record the fix in the changelog. The complete native regression executable passes, including lighting, image loading, backdrop pixels and the empty-document cases.
1 parent dc7ff1e commit 345fce9

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ These entries describe the current repository source. They have not been assigne
4242

4343
#### Fixed
4444

45+
- Background-buffer discovery and root filter composition safely handle an uninitialized SVG document; empty drawings remain valid with filters enabled or disabled.
46+
4547
- The Acid1 sample's right pupil now uses modern `rgb(-5% 128 0%)` and renders green. RGB/RGBA parsing distinguishes space/slash syntax (mixed numeric/percentage channels allowed) from legacy commas (uniform channel units), accepts multiline CSS whitespace and rejects mixed separators or alpha without a slash. Pixel regressions cover the actual embedded sample and mixed channels/alpha.
4648

4749
- Animated clip geometry retains its native clocks through unions/transforms and bounding-box mapping. The original `clipping_css.svg` now moves/repeats correctly; `repeatDur` supports indefinite and finite durations, including frozen partial iterations.

‎Source/SVGImage/SVG/SVGRender.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ public DrawingGroup CreateDrawing(SVG svg)
147147
this.SVG = svg;
148148
animationScene = UseAnimations ? new SvgAnimationScene(svg) : null;
149149
bool camera = animationScene != null && animationScene.Tracks(svg.RootGroup).Any(t => t.Attribute == "viewBox");
150-
needsBackground=UseFilters && svg.RootGroup.SourceNode.SelectNodes(".//*[@in='BackgroundImage' or @in='BackgroundAlpha' or @in2='BackgroundImage' or @in2='BackgroundAlpha']").Count>0;
150+
needsBackground=UseFilters && (svg.RootGroup?.SourceNode?.SelectNodes(".//*[@in='BackgroundImage' or @in='BackgroundAlpha' or @in2='BackgroundImage' or @in2='BackgroundAlpha']").Count ?? 0)>0;
151151
BackdropContext rootBackdrop=null;
152152
if(needsBackground) NewBackdrop(svg.RootGroup,out rootBackdrop);
153153
var drawingGroup = this.LoadGroup(svg.Elements, camera ? null : svg.ViewBox, false, rootBackdrop);
154-
if (svg.RootGroup?.Mask != null || (UseFilters && svg.RootGroup?.Filter != null) || svg.RootGroup?.Transform != null || svg.RootGroup?.Clip != null || svg.RootGroup?.Opacity != 1 || (animationScene != null && animationScene.Tracks(svg.RootGroup).Count > 0))
154+
if (svg.RootGroup != null && (svg.RootGroup.Mask != null || (UseFilters && svg.RootGroup.Filter != null) || svg.RootGroup.Transform != null || svg.RootGroup.Clip != null || svg.RootGroup.Opacity != 1 || (animationScene != null && animationScene.Tracks(svg.RootGroup).Count > 0)))
155155
{
156156
var masked = new DrawingGroup();
157157
AddDrawingToGroup(masked, svg.RootGroup, drawingGroup);

‎Tests/RegressionTests/LightingImageBackdropTests.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ private static Drawing Render(string primitives, string content = "<rect x='20'
1313
=> GeometryTests.Svg(Filter + primitives + "</filter>" + content);
1414
internal static void Run()
1515
{
16+
foreach(bool enabled in new[]{true,false})
17+
if(!new SVGRender { UseFilters=enabled }.CreateDrawing(new SVGImage.SVG.SVG()).Bounds.IsEmpty)
18+
throw new Exception("An uninitialized SVG must render empty");
1619
Lighting(); Images(); Backdrops(); Samples();
1720
Console.WriteLine("Lighting, feImage and backdrop checks passed.");
1821
}

0 commit comments

Comments
 (0)