Skip to content

Commit dbe33fe

Browse files
committed
Fix RelocateIfNeeded off-by-one: a box exactly one page tall can be moved
RelocateIfNeeded's own fits-nowhere guard read 'if (height >= container.PageSize.Height) return;' - treating a box exactly as tall as one page's content band the same as one too tall for ANY page. A box exactly that tall genuinely does fit a page exactly when started flush at that page's own top, so it was being left in place (straddling a boundary) rather than relocated to the fresh page it would fit perfectly. Changed >= to >. Full suite: HtmlRenderer.Test 2427 passed/128 skipped/0 failed (unchanged), HtmlRenderer.IntegrationTest 334 passed/92 skipped/0 failed (+1 unignored, 0 regressions elsewhere - this guard is exercised throughout the existing break-inside:avoid/monolithic relocation suite), HtmlRenderer.PdfSharp.Test 39 passed/0 failed (unchanged).
1 parent 267c3e0 commit dbe33fe

2 files changed

Lines changed: 1 addition & 6 deletions

File tree

‎Source/HtmlRenderer/Core/Fragmentation/BlockFragmentation.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ internal static void RelocateIfNeeded(RGraphics g, CssBox child)
138138
return;
139139

140140
var height = bottom - top;
141-
if (height >= container.PageSize.Height)
141+
if (height > container.PageSize.Height)
142142
return; // Fits on no single page - left in place rather than moved somewhere it also won't fit.
143143

144144
var target = container.PageTopOf(topSlot + 1);

‎Source/Test/HtmlRenderer.IntegrationTest/Fragmentation/MonolithicContentLayoutIntegrationTests.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ public async Task HiddenScrollContainer_IsNotRelocated()
214214

215215
// A box exactly as tall as the content band fits a page perfectly, so there is somewhere to move it to.
216216
[TestMethod]
217-
[Ignore("Confirmed off-by-one gap: BlockFragmentation.RelocateIfNeeded's own fits-nowhere guard reads "
218-
+ "'if (height >= container.PageSize.Height) return;' - a box exactly as tall as one page is treated "
219-
+ "the same as one too tall for any page (>=, not >), so it is left in place rather than relocated. "
220-
+ "A box exactly this tall really does fit one page exactly (started flush at that page's own top), "
221-
+ "so this is a genuine boundary bug, not just a difference in relaxation philosophy.")]
222217
public async Task ScrollContainerExactlyAsTallAsTheBand_StillMovesWhole()
223218
{
224219
var html = "<div style='height:60px'>filler</div>"

0 commit comments

Comments
 (0)