Skip to content

Commit dc2099e

Browse files
committed
Make FragmentPainter the default paint path for WinForms/WPF (F2)
HtmlContainerInt.PerformPaint(RGraphics g) - the overload every WinForms/WPF control (HtmlPanel, HtmlLabel, HtmlToolTip, HtmlControl, HtmlRender's image/metafile renderers) ultimately calls - now paints through FragmentPainter whenever the fragment tree has exactly one fragmentainer, which is every case that reaches this overload today: WinForms/WPF's continuous single-surface rendering has no real page grid, so FragmentEmitter.Finish always gives it one fragmentainer spanning the whole document (its no-real-page-grid path, built back in D1). A caller with a real multi-page grid that somehow reaches this overload instead of the fragmentainer-aware one PdfGenerator always uses falls back to the old CssBox.Paint walk, unchanged - not a case that exists in this codebase today, but a safe fallback rather than silently truncating to one page's content if it ever did. No new verification needed beyond what already exists: this is the same swap Stage E1 already proved pixel-identical via a temporary redirect (reverted after that stage's commit) across the entire regression suite, now made permanent. The full existing suite (35 image-diff/fragment tests + 15 PDF/PdfSharp tests) stays green with zero baseline changes, run directly against this as the real default path for the first time - not a temporary redirect. FragmentPainter is now the only paint implementation reached by any of the three platform projects (WinForms/WPF via this overload, PdfSharp via the fragmentainer-aware one from F1) for ordinary content. CssBox.Paint/PaintImp remain as the one documented fallback and are not yet retired - that's F3, once this has had time to prove itself.
1 parent 3b840f0 commit dc2099e

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎Source/HtmlRenderer/Core/HtmlContainerInt.cs‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,21 @@ public void PerformPaint(RGraphics g)
810810
g.PushClip(new RRect(MarginLeft, MarginTop, PageSize.Width, PageSize.Height));
811811
}
812812

813-
if (_root != null)
813+
// The fragment tree has exactly one fragmentainer for every caller of this overload today
814+
// (WinForms/WPF's continuous single-surface rendering, and any other HasRealPageGrid=false
815+
// container - see FragmentEmitter.Finish's no-real-page-grid path) - FragmentPainter is a
816+
// faithful, verified replacement for CssBox.Paint there (see StageE1SmokeTest's pixel-for-
817+
// pixel comparison, and HtmlRenderingRegressionTests staying green under this path).
818+
// A caller with a real, multi-page grid that reaches this overload instead of the
819+
// fragmentainer-aware one (PdfGenerator always uses that one - see PdfGenerator.AddPdfPages)
820+
// falls back to the old live-tree walk, which paints every page's content onto one
821+
// continuous surface exactly as this method always has; splitting that across fragments
822+
// correctly is what the fragmentainer-aware overload below already does properly.
823+
if (FragmentTree != null && FragmentTree.Fragmentainers.Count == 1)
824+
{
825+
new Paint.FragmentPainter(this).Paint(g, FragmentTree.Fragmentainers[0]);
826+
}
827+
else if (_root != null)
814828
{
815829
_root.Paint(g);
816830
}
@@ -820,8 +834,7 @@ public void PerformPaint(RGraphics g)
820834

821835
/// <summary>
822836
/// Render one fragmentainer using the given device, reading from the immutable fragment tree
823-
/// rather than walking the mutable box tree directly. Not yet the default paint path - see
824-
/// <see cref="Paint.FragmentPainter"/>'s remarks for why.
837+
/// rather than walking the mutable box tree directly.
825838
/// </summary>
826839
/// <param name="g">the device to use to render</param>
827840
/// <param name="fragmentainer">the fragmentainer to paint</param>

0 commit comments

Comments
 (0)