Repository navigation
Commit 380a207
committed
R5/R6: neither needed new resumption machinery - fixed real bugs instead
Investigated the plan's R5 (inline resumption via line-index
InlineBreakToken) and R6 (widows as a driver-level rewind) before
building either. Conclusion: CreateLineBoxes already computes a whole
paragraph's lines in one unbounded, side-effect-free, idempotent call -
there is never a point where a LATER pass would reveal information the
SAME-shot correction didn't already have, which is the entire reason
PeachPDF's resumption/rewind machinery exists. Building BreakToken/pass
machinery for inline flow would have been solving a problem this
architecture doesn't have (same conclusion as R2's finding for ordinary
block overflow).
What the investigation found instead: a real, confirmed bug in the
EXISTING same-shot algorithm. The old InlineFragmentation.ApplyLineBreaking
shifted lines incrementally as it walked them, driven by "did this line
straddle a page boundary". Once a shift happened to land a run in
perfect page-boundary alignment (common with uniform line heights), no
line ever straddled again for the rest of the paragraph - so widows was
silently never re-checked for any later page transition. Confirmed via
a paragraph spanning 60 pages: its final page ended with 1 line despite
widows:3, and nothing corrected it. Rewrote ApplyLineBreaking as two
phases: decide every break point from each line's own NATURAL
(never-shifted) position (immune to the alignment blind spot, and lets
widows cascade backward across more than one earlier break by removing
entries from a decided break list, rather than needing to undo a shift
already applied to specific lines), then apply the decided breaks as
shifts in one separate pass. Also handles a case the old code never
covered either: a box's own first line not fitting the room left on
its starting page.
Fixing this surfaced a second real bug in R4's own EnforceKeepWithNext:
it read CssBox.Location.Y to determine which page an already-laid-out
box's content starts on, but for an inline-only box, Location is
committed once before content layout runs and InlineFragmentation
never updates it - even though it can move the box's one-and-only line
to an entirely different page. A single-line heading whose own line
got pushed to the next page still reported its OLD page via Location.Y,
so keep-with-next silently compared against stale geometry. Added
CssBox.EffectiveTop (the first line's actual top for inline-only boxes,
Location.Y otherwise) and switched both RelocateIfNeeded and
EnforceKeepWithNext to use it.
New tests confirm both the fixable case (a long paragraph correctly
pulls lines back across more than one earlier page to satisfy widows
when room allows) and the honest unsatisfiable case (widows is left
unsatisfied rather than forcing an overflowing page, with word-count
conservation and per-page height checked directly). StageR4KeepWithNextTest
was also made self-calibrating (searches for the exact boundary filler
count rather than a hardcoded one) after the InlineFragmentation rewrite
shifted where that boundary falls by one - a hardcoded magic number
turned out to be fragile to unrelated, still-correct changes.
Full regression suite (41 IntegrationTest + 16 PdfSharp tests) passes.1 parent d8c4c00 commit 380a207
5 files changed
Lines changed: 278 additions & 57 deletions
File tree
- Source
- HtmlRenderer/Core
- Dom
- Fragmentation
- Test/HtmlRenderer.IntegrationTest
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
407 | 419 | | |
408 | 420 | | |
409 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | | - | |
16 | | - | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
23 | 41 | | |
24 | 42 | | |
25 | 43 | | |
| |||
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
42 | 72 | | |
43 | | - | |
44 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
45 | 76 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 77 | + | |
50 | 78 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
54 | 85 | | |
55 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
56 | 100 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
61 | 113 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 114 | + | |
| 115 | + | |
66 | 116 | | |
67 | | - | |
68 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
69 | 122 | | |
70 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
71 | 126 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
77 | 130 | | |
78 | 131 | | |
79 | | - | |
| 132 | + | |
| 133 | + | |
80 | 134 | | |
81 | 135 | | |
82 | 136 | | |
83 | 137 | | |
84 | 138 | | |
85 | | - | |
| 139 | + | |
86 | 140 | | |
87 | 141 | | |
88 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
67 | 65 | | |
68 | 66 | | |
69 | 67 | | |
70 | | - | |
71 | | - | |
| 68 | + | |
| 69 | + | |
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
78 | 76 | | |
79 | | - | |
80 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
87 | 103 | | |
88 | 104 | | |
| 105 | + | |
| 106 | + | |
89 | 107 | | |
90 | 108 | | |
91 | 109 | | |
| 110 | + | |
| 111 | + | |
92 | 112 | | |
93 | | - | |
| 113 | + | |
94 | 114 | | |
95 | 115 | | |
96 | | - | |
| 116 | + | |
97 | 117 | | |
98 | 118 | | |
99 | 119 | | |
| |||
0 commit comments