Skip to content

CSS 2.1 test parity: outline and background paint coverage (stacked on #265) - #266

Merged
eXpl0it3r merged 3 commits into
ArthurHub:masterfrom
jhaygood86:feature/css21-paint-coverage
Nov 9, 2026
Merged

eXpl0it3r merged 3 commits into
ArthurHub:masterfrom
jhaygood86:feature/css21-paint-coverage

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Part 3 of a CSS 2.1 test-parity sweep against PeachPDF's Integration test suite. Stacked on #265/#264/#263 - the diff below includes all three until they merge. Only the last 2 commits (outline paint, background paint tests) are this PR's own.

Summary

Scope: chapter 18 (outline) and chapter 14 (background-color) - both had zero paint-level coverage.

  • outline: outline-style/-color/-width parsed fine at the CSS-OM level but had no CssBoxProperties fields and no paint code anywhere - an authored outline had zero visual effect. Implemented OutlineDrawHandler: a flat four-rectangle ring around the border-box edge (outline has no per-side bevel/corner-joining, unlike border), hooked in right after border painting per CSS2.1 Appendix E's paint order. Scoped to the common case - only solid/auto paint, outline-offset isn't implemented (no CSS-OM property for it exists here at all), and outline-style:auto can't actually be parsed from CSS text yet (would need a dedicated converter, not a shared-map edit - see the commit message). outline-color falls back to currentColor when unset.
  • background-color: the paint code already worked, just had zero test coverage. Added fill-geometry, transparent/default no-op, and paint-order tests.

Test plan

  • HtmlRenderer.Test full suite: 2449 passed, 0 failed
  • HtmlRenderer.IntegrationTest full suite: 384 passed, 0 failed
  • HtmlRenderer.PdfSharp.Test full suite: 39 passed, 0 failed
  • Full solution builds clean across net8.0, net8.0-windows, netstandard2.0, net462
  • Filed jhaygood86/PeachPDF#864 (:lang() untested) and jhaygood86/PeachPDF#865 (legacy clip: rect() untested beyond parsing) for gaps in PeachPDF's own suite, per this sweep's scope

@eXpl0it3r
eXpl0it3r force-pushed the feature/css21-paint-coverage branch 2 times, most recently from 053fd68 to 4691ef1 Compare November 9, 2026 07:49
@eXpl0it3r

Copy link
Copy Markdown
Collaborator

Rebased onto the updated #265 and added a few outline fixes:

  • <img>, <iframe> and <hr> returned early through their content painters and never drew the outline, so ReplacedFragmentPainter and HrFragmentPainter now call OutlineDrawHandler.Draw as well.
  • InheritStyle(..., everything: true) didn't copy the three outline fields, so the halves of a split inline box (e.g. a <span> around a <div>) and repeated <thead> rows lost their outline.
  • outline-color: invert ended up as an empty color and painted nothing, it now falls back to currentColor, as the doc comment already said.

All of them have tests in OutlineStylePaintIntegrationTests.

@eXpl0it3r
eXpl0it3r force-pushed the feature/css21-paint-coverage branch 2 times, most recently from 55a21d6 to 319babd Compare November 9, 2026 08:14
@eXpl0it3r eXpl0it3r added the CSS label Nov 9, 2026
jhaygood86 and others added 3 commits November 9, 2026 09:21
…nted

outline-style/-color/-width had CSS-OM parsing (and a shorthand) but
no CssBoxProperties fields and no paint code anywhere - an authored
outline had zero visual effect.

Adds OutlineDrawHandler: unlike border, an outline isn't part of the
box model and has no per-side bevel/corner-joining to account for, so
it paints as four flat filled rectangles forming a ring around the
border-box edge, hooked in right after DrawBoxBorders in
FragmentPainter (matching CSS2.1 Appendix E's after-border painting
order). Deliberately scoped to the common case: only solid/auto
paint (every other style is a no-op, same as none/hidden), and
outline-offset isn't implemented - this fork's CSS-OM has no
OutlineOffsetProperty at all to read a value from, and adding
outline-style:auto recognition would require a dedicated converter
rather than a shared-map edit (Map.LineStyles is also border-style's
own keyword table - adding "auto" there would wrongly make it a
legal border-style value too). outline-color falls back to
currentColor when unset, matching real browser behavior for the
property's nominal (and here unimplemented) "invert" initial value.

Ports the CSS2.1-relevant subset of PeachPDF's
OutlineStylePaintIntegrationTests.cs against this simpler
implementation - solid ring geometry, currentColor fallback,
paint-order after border, none/hidden/zero-width no-op all pass;
auto and outline-offset are ported [Ignore]d with the gaps above.
No test anywhere verified background-color actually paints a fill,
despite the paint code (CssBox.PaintBackground) already working -
only CSS-OM parsing (BackgroundPropertyTests.cs) was covered.
Verifies fill geometry, the transparent/default (also transparent)
no-op cases, and paint order relative to border/outline per CSS2.1
Appendix E.
- Paint the outline for replaced elements and <hr>
- Copy the outline when a box gets cloned
- Treat outline-color: invert as currentColor
@eXpl0it3r
eXpl0it3r force-pushed the feature/css21-paint-coverage branch from 319babd to 73e9021 Compare November 9, 2026 08:21
@eXpl0it3r
eXpl0it3r merged commit 2244f1c into ArthurHub:master Nov 9, 2026
9 checks passed
@eXpl0it3r

Copy link
Copy Markdown
Collaborator

Thank you!

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.

2 participants