Skip to content

Commit 0496e67

Browse files
committed
R10: delete dead break-token/relaxation scaffolding never wired up
InlineBreakToken, its FanOutContinuations base member, and the BreakRelaxation enum were ported early on for machinery this port's architecture turned out not to need (R2/R5/R6/R9 all found the local- correction model handles their cases without real cross-pass tokens - see each stage's commit). None had a single caller anywhere in the codebase. BlockBreakToken is the only token kind this port actually uses; the doc comments now say so directly instead of pointing at unused alternatives.
1 parent cb1bdf9 commit 0496e67

3 files changed

Lines changed: 11 additions & 107 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,8 @@ internal static void RelocateIfNeeded(RGraphics g, CssBox child)
168168
/// empirically reaching a box position around 8.6e11 for a 60-member chain on a short page). The
169169
/// fix is css-break-3 §4.3's actual staged relaxation: trim the run from its front (the earliest,
170170
/// least-important-to-keep members) until what remains actually fits the target page alongside
171-
/// <paramref name="child"/> (<see cref="BreakRelaxation.RunTrimmed"/>), or leave the run in place
172-
/// entirely if even its last member doesn't fit there (<see cref="BreakRelaxation.RunDropped"/>) -
173-
/// never pull a run that can't actually fit.
171+
/// <paramref name="child"/> ("RunTrimmed"), or leave the run in place entirely if even its last
172+
/// member doesn't fit there ("RunDropped") - never pull a run that can't actually fit.
174173
/// </remarks>
175174
internal static void EnforceKeepWithNext(RGraphics g, CssBox child)
176175
{

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

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
41
using TheArtOfDev.HtmlRenderer.Core.Dom;
52

63
namespace TheArtOfDev.HtmlRenderer.Core.Fragmentation
74
{
85
/// <summary>
96
/// A resumption record: where layout stopped in one fragmentainer, so the next one can pick up from
107
/// exactly that point (https://www.w3.org/TR/css-break-3/#breaking-controls, CSS Fragmentation Level 3
11-
/// §2/§4.4). Ported from PeachPDF's <c>BreakToken</c>, reduced to the two token kinds this port's
12-
/// block/inline scope needs (<see cref="TableBreakToken"/> is added in the table-fragmentation stage).
8+
/// §2/§4.4). Ported from PeachPDF's <c>BreakToken</c>, reduced to what this port's driver loop
9+
/// actually needs: only forced <c>break-before</c>/<c>break-after: page</c> ever produces a real
10+
/// cross-pass token here (see <see cref="BlockFragmentation.TryGetForcedBreakTarget"/>) - overflow,
11+
/// <c>break-inside:avoid</c>, keep-with-next, widows/orphans, and table-row breaks all turned out to
12+
/// be same-pass local corrections instead (confirmed empirically stage by stage while investigating
13+
/// the fragmentation-engine-parity plan's R2-R9), so PeachPDF's inline and table token kinds - and its
14+
/// per-token <c>FanOutContinuations</c> "parallel flows" mechanism, which only those kinds ever used -
15+
/// have no counterpart in this port and were never added.
1316
/// </summary>
1417
/// <remarks>
1518
/// Tokens form a chain, one link per ancestor between the fragmentation-context root and the box that
@@ -24,16 +27,7 @@ namespace TheArtOfDev.HtmlRenderer.Core.Fragmentation
2427
/// after this one": a box can be placed far down the document, so the fragmentainer it overflows is
2528
/// not in general the one after the fragmentainer the pass nominally started in.
2629
/// </param>
27-
internal abstract record BreakToken(CssBox Box, int ResumeSlotIndex)
28-
{
29-
/// <summary>
30-
/// This token's per-child continuations, for a token naming more than one -
31-
/// https://www.w3.org/TR/css-break-3/#parallel-flows (§2.1 parallel-flows), the shape
32-
/// <see cref="TableBreakToken"/> uses. Empty for every other kind, whose one child (if any) is
33-
/// <see cref="BlockBreakToken.ChildToken"/> instead.
34-
/// </summary>
35-
internal virtual IReadOnlyList<BreakToken> FanOutContinuations => Array.Empty<BreakToken>();
36-
}
30+
internal abstract record BreakToken(CssBox Box, int ResumeSlotIndex);
3731

3832
/// <summary>A block container stopped part-way through its in-flow children.</summary>
3933
/// <param name="Box">the block container to resume</param>
@@ -60,53 +54,4 @@ internal sealed record BlockBreakToken(
6054
BreakToken ChildToken,
6155
bool IsBreakBefore,
6256
double? ResumeTopOverride) : BreakToken(Box, ResumeSlotIndex);
63-
64-
/// <summary>A block container's inline flow stopped part-way through its content.</summary>
65-
/// <remarks>
66-
/// <see cref="ResumePath"/> is a path rather than a single index because inline layout walks the
67-
/// inline box tree recursively: resuming means descending the same path again and fast-forwarding to
68-
/// the word that did not fit, rather than replaying the walk from the top.
69-
/// </remarks>
70-
/// <param name="Box">the block container whose inline flow stopped</param>
71-
/// <param name="ResumeSlotIndex">the pagination slot the resumed pass fills</param>
72-
/// <param name="ResumePath">child indices from <paramref name="Box"/> down to the inline box owning the word</param>
73-
/// <param name="ResumeWordIndex">the index into that box's words to resume at</param>
74-
/// <param name="CompletedLineCount">
75-
/// how many line boxes the container had already produced when the break was taken. Everything below
76-
/// this index has been emitted into an earlier fragmentainer and must not be re-aligned or re-measured
77-
/// by the resumed pass.
78-
/// </param>
79-
/// <param name="LinesKeptHere">
80-
/// how many line boxes this fragmentainer kept - <see cref="CompletedLineCount"/> minus what the pass
81-
/// began with. This is the quantity <c>orphans</c> is defined over
82-
/// (https://www.w3.org/TR/css-break-3/#widows-orphans, §5.4: line boxes left in a fragment before the
83-
/// break), which the cumulative count cannot answer for any fragment but the first.
84-
/// </param>
85-
internal sealed record InlineBreakToken(
86-
CssBox Box,
87-
int ResumeSlotIndex,
88-
IReadOnlyList<int> ResumePath,
89-
int ResumeWordIndex,
90-
int CompletedLineCount,
91-
int LinesKeptHere = 0) : BreakToken(Box, ResumeSlotIndex)
92-
{
93-
/// <summary>
94-
/// Compared by contents, because the driver's no-progress backstop is an equality test. The
95-
/// compiler-generated record equality would compare <see cref="ResumePath"/> - an
96-
/// <see cref="IReadOnlyList{T}"/> - by reference, so two passes that legitimately stopped at the
97-
/// same word would compare unequal and the loop would spin to its pass-count cap instead of
98-
/// recognizing no progress was made. See the plan's "break-token equality footgun" risk note.
99-
/// </summary>
100-
public bool Equals(InlineBreakToken other) =>
101-
other is not null
102-
&& ReferenceEquals(Box, other.Box)
103-
&& ResumeSlotIndex == other.ResumeSlotIndex
104-
&& ResumeWordIndex == other.ResumeWordIndex
105-
&& CompletedLineCount == other.CompletedLineCount
106-
&& LinesKeptHere == other.LinesKeptHere
107-
&& ResumePath.SequenceEqual(other.ResumePath);
108-
109-
public override int GetHashCode() =>
110-
HashCode.Combine(Box, ResumeSlotIndex, ResumeWordIndex, CompletedLineCount, LinesKeptHere, ResumePath.Count);
111-
}
11257
}

0 commit comments

Comments
 (0)