Reserve insertion class skip in the paged builder

This commit is contained in:
gloamxun committed 2026-10-24 00:23:55 +08:00
1 parent 1dc3e95a04
commit 0805f3c932
4 files changed
+90 -6

No files matched your search

+22 -2
View File
@@ -2240,13 +2240,18 @@ impl Engine {
page.floats = floats;
let reserved: i64 = insertions.values().map(|insertion| insertion.height).sum();
page.insertions = insertions.into_values().collect();
let insertion_skip: i64 = page
.insertions
.iter()
.map(|insertion| document.insertion_skip_for(insertion.class))
.sum();
page.sources = sources;
page.seal_in_place();
let shipped = match routine.as_mut() {
Some(routine) => routine.ship(
document,
&page,
(document.page_goal - reserved).max(0),
(document.page_goal - reserved - insertion_skip).max(0),
fragment.penalty,
fragment.depth,
fragment.stretch,
@@ -2287,12 +2292,17 @@ impl Engine {
let mut page = Page::empty();
let reserved: i64 = insertions.values().map(|insertion| insertion.height).sum();
page.insertions = insertions.into_values().collect();
let insertion_skip: i64 = page
.insertions
.iter()
.map(|insertion| document.insertion_skip_for(insertion.class))
.sum();
page.seal_in_place();
let shipped = match routine.as_mut() {
Some(routine) => routine.ship(
document,
&page,
(document.page_goal - reserved).max(0),
(document.page_goal - reserved - insertion_skip).max(0),
10_000,
0,
0,
@@ -2359,6 +2369,16 @@ impl Engine {
height: document.insertion_class_limit(class.number),
})
.collect(),
insertion_skips: document
.insertion_classes
.iter()
.map(|class| {
(
class.number,
class.skip.unwrap_or(document.insertion_skip).max(0),
)
})
.collect(),
text_float_sep: document.text_float_sep.max(0),
float_sep: document.float_sep.max(0),
bottom_fraction_percent: document.bottom_fraction_percent,