Skip to content

Commit b056b6c

Browse files
committed
Remove the crude per-word/per-box BreakPage nudge (F3, partial)
CssBox.BreakPage and CssRect.BreakPage - the old modulo-arithmetic "does this straddle a page, nudge it down" mechanism - are now fully superseded: BlockFragmentation (D2), InlineFragmentation (D3), and CssLayoutEngineTable's row-avoidance correction (D4) all replace their call sites with page-grid-aware corrections. CssRect.BreakPage had exactly one remaining caller (CssLayoutEngine.FlowBox's per-word nudge, dead since D3 - a line box is monolithic, so lines move as a whole via InlineFragmentation.ApplyLineBreaking, not word by word); CssBox.BreakPage had none. Both deleted along with that call site. This is a *narrower* cleanup than the plan's original F3 scope ("delete CssBox.Paint/PaintImp"), by design: FragmentPainter turns out to still genuinely depend on CssBox.Paint/PaintImp, not just as a temporary fallback - it delegates to them for CssBoxImage/CssBoxHr/ CssBoxFrame's own PaintImp overrides (E1's deliberate scope reduction: real per-type content painters are follow-on work), and the base PaintImp is what actually paints CssBox.ListItemBox and CssBox.RepeatedHeaderRows (D4), neither of which override it. Deleting CssBox.Paint/PaintImp now would break list markers and repeated table headers, not just remove dead code - confirmed by grep before touching anything: FragmentPainter.cs has three live call sites into it, plus CssBox.PaintImp's own body still calls it for RepeatedHeaderRows. Full existing suite (35 image-diff/fragment tests + 15 PDF/PdfSharp tests) green - this change touches every paginated document's inline flow, verified rather than assumed safe.
1 parent dc2099e commit b056b6c

3 files changed

Lines changed: 0 additions & 43 deletions

File tree

‎Source/HtmlRenderer/Core/Dom/CssBox.cs‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,26 +1313,6 @@ internal double MarginTopCollapse(CssBoxProperties prevSibling)
13131313
return value;
13141314
}
13151315

1316-
public bool BreakPage()
1317-
{
1318-
var container = this.HtmlContainer;
1319-
1320-
if (this.Size.Height >= container.PageSize.Height)
1321-
return false;
1322-
1323-
var remTop = (this.Location.Y - container.MarginTop) % container.PageSize.Height;
1324-
var remBottom = (this.ActualBottom - container.MarginTop) % container.PageSize.Height;
1325-
1326-
if (remTop > remBottom)
1327-
{
1328-
var diff = container.PageSize.Height - remTop;
1329-
this.Location = new RPoint(this.Location.X, this.Location.Y + diff + 1);
1330-
return true;
1331-
}
1332-
1333-
return false;
1334-
}
1335-
13361316
/// <summary>
13371317
/// Calculate the actual right of the box by the actual right of the child boxes if this box actual right is not set.
13381318
/// </summary>

‎Source/HtmlRenderer/Core/Dom/CssLayoutEngine.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,6 @@ private static void FlowBox(RGraphics g, CssBox blockbox, CssBox box, double lim
505505
word.Left = curx;
506506
word.Top = cury;
507507

508-
if (!box.IsFixed)
509-
{
510-
word.BreakPage();
511-
}
512-
513508
curx = word.Left + word.FullWidth;
514509

515510
maxRight = Math.Max(maxRight, word.Right);

‎Source/HtmlRenderer/Core/Dom/CssRect.cs‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -269,23 +269,5 @@ public override string ToString()
269269
return string.Format("{0} ({1} char{2})", Text.Replace(' ', '-').Replace("\n", "\\n"), Text.Length, Text.Length != 1 ? "s" : string.Empty);
270270
}
271271

272-
public bool BreakPage()
273-
{
274-
var container = this.OwnerBox.HtmlContainer;
275-
276-
if (this.Height >= container.PageSize.Height)
277-
return false;
278-
279-
var remTop = (this.Top - container.MarginTop) % container.PageSize.Height;
280-
var remBottom = (this.Bottom - container.MarginTop) % container.PageSize.Height;
281-
282-
if (remTop > remBottom)
283-
{
284-
this.Top += container.PageSize.Height - remTop + 1;
285-
return true;
286-
}
287-
288-
return false;
289-
}
290272
}
291273
}

0 commit comments

Comments
 (0)