Skip to content

Commit 8d6c60b

Browse files
committed
Port remaining Acid2 min/max-height and table cross-checks
Rounds out the box-model (ch.8/10) and table (ch.17) spot-checks this branch's plan originally called for: min-height/max-height precedence (CSS2.1 §10.7, including the percentage-height-against-auto-height- container edge case), table-cell height stretching to its row's height even when the cell's own explicit height is shorter (§17.5.3), and border-spacing:0 leaving no gap between adjacent cells. All pass against the existing engine unmodified. Chapter 11 (overflow/clip/visibility) and 13 (paged media) were spot-checked against PeachPDF's fuller suites and found already adequately covered for CSS 2.1 - PeachPDF's remaining OverflowClipIntegrationTests cases are border-radius+stacking-context specific (CSS3), and its paged-media margin-box/named-page tests are CSS3 Paged Media/GCPM, both out of this sweep's CSS 2.1 scope.
1 parent f5acb05 commit 8d6c60b

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using HtmlRenderer.IntegrationTest.TestSupport;
2+
3+
namespace HtmlRenderer.IntegrationTest.BoxModel;
4+
5+
/// <summary>
6+
/// Ported from PeachPDF.Tests' Acid2 min-height/max-height regression cases (CSS 2.1 §10.7).
7+
/// </summary>
8+
[DoNotParallelize]
9+
[TestClass]
10+
public sealed class MinMaxHeightIntegrationTests
11+
{
12+
private const double Delta = 0.5;
13+
14+
[TestMethod]
15+
public void MinHeightWinsOverConflictingMaxHeight()
16+
{
17+
// min-height (20px) and max-height (5px) conflict; min-height must win per §10.7, so the box's
18+
// actual height must be 20px, not clamped down to 5px.
19+
var html = LayoutHarness.Wrap("<div id='b' style='height:8px; min-height:20px; max-height:5px;'></div>");
20+
var (root, _) = LayoutHarness.Layout(html);
21+
var box = LayoutHarness.FindById(root, "b")!;
22+
23+
Assert.AreEqual(20, box.ActualBottom - box.Location.Y, Delta);
24+
}
25+
26+
[TestMethod]
27+
public void MaxHeightAppliesWhenNotConflictingWithMinHeight()
28+
{
29+
var html = LayoutHarness.Wrap("<div id='b' style='height:100px; max-height:20px;'></div>");
30+
var (root, _) = LayoutHarness.Layout(html);
31+
var box = LayoutHarness.FindById(root, "b")!;
32+
33+
Assert.AreEqual(20, box.ActualBottom - box.Location.Y, Delta);
34+
}
35+
36+
[TestMethod]
37+
public void PercentageHeight_AgainstAutoHeightContainingBlock_ResolvesToAuto_LettingMaxHeightWin()
38+
{
39+
// "height: 60%" must resolve to auto (zero intrinsic content) against an auto-height containing
40+
// block (CSS 2.1 §10.5/§10.7), not against the container's own content-driven height - so
41+
// max-height:20px is the only thing constraining #b's height.
42+
var html = LayoutHarness.Wrap(
43+
"<div id='cb'>"
44+
+ "<div id='content' style='height:50px;'></div>"
45+
+ "<div id='b' style='height:60%; max-height:20px;'></div>"
46+
+ "</div>");
47+
var (root, _) = LayoutHarness.Layout(html);
48+
var box = LayoutHarness.FindById(root, "b")!;
49+
50+
var height = box.ActualBottom - box.Location.Y;
51+
Assert.IsTrue(height is >= 0 and <= 20.5, $"expected height clamped to max-height:20px, was {height}");
52+
}
53+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using HtmlRenderer.IntegrationTest.TestSupport;
2+
3+
namespace HtmlRenderer.IntegrationTest.Tables;
4+
5+
/// <summary>
6+
/// Ported from PeachPDF.Tests' Acid2 table regression cases (CSS 2.1 §17.5.3 row-stretch, §17.6.1
7+
/// border-spacing).
8+
/// </summary>
9+
[DoNotParallelize]
10+
[TestClass]
11+
public sealed class Acid2TableIntegrationTests
12+
{
13+
private const double Delta = 0.5;
14+
15+
[TestMethod]
16+
public void TableCell_ExplicitHeightShorterThanRow_StretchesToRowHeight()
17+
{
18+
var html = LayoutHarness.Wrap(
19+
"<table><tr>"
20+
+ "<td id='tall' style='height:40px;'></td>"
21+
+ "<td id='short' style='height:5px;'></td>"
22+
+ "</tr></table>");
23+
var (root, _) = LayoutHarness.Layout(html);
24+
25+
var tall = LayoutHarness.FindById(root, "tall")!;
26+
var shortCell = LayoutHarness.FindById(root, "short")!;
27+
28+
Assert.AreEqual(tall.ActualBottom, shortCell.ActualBottom, Delta);
29+
}
30+
31+
[TestMethod]
32+
public void BorderSpacingZero_AdjacentCells_HaveNoGapBetweenThem()
33+
{
34+
var html = LayoutHarness.Wrap(
35+
"<table style='border-spacing:0;'><tr>"
36+
+ "<td id='c1' style='width:20px;'>a</td>"
37+
+ "<td id='c2' style='width:20px;'>b</td>"
38+
+ "</tr></table>");
39+
var (root, _) = LayoutHarness.Layout(html);
40+
41+
var c1 = LayoutHarness.FindById(root, "c1")!;
42+
var c2 = LayoutHarness.FindById(root, "c2")!;
43+
44+
Assert.AreEqual(c1.ActualRight, c2.Location.X, Delta);
45+
}
46+
}

0 commit comments

Comments
 (0)