Honor e-TeX split shrink masks on native vertical lists

This commit is contained in:
gloamxun committed 2026-11-28 08:46:51 +08:00
1 parent 69efe0b895
commit 34325317d2
11 files changed
+187 -28

No files matched your search

@@ -1,3 +1,4 @@
use super::page_builder::PageObservation;
use super::*;
use std::collections::{BTreeMap, BTreeSet};
@@ -71,14 +72,14 @@ impl PageInsertions {
pub fn record_front(
&mut self,
node: &NativeInsertion,
node: &mut NativeInsertion,
at: usize,
dims: &mut [i64; 8],
state: &State,
reads: &mut BTreeSet<Dependency>,
steps: &mut usize,
limit: usize,
trace: &mut Vec<PageTrace>,
observations: &mut Vec<PageObservation>,
) -> Result<(), String> {
let index = u16::from(node.class);
let placement = Placement {
@@ -141,20 +142,36 @@ impl PageInsertions {
space / factor * 1000
}
.min(max - entry.size);
let split =
super::vertical_break::find_break(&node.nodes, target, node.split_depth, steps, limit)?;
let mut ignored_shrinks = 0;
let split = super::vertical_break::find_break(
&mut node.nodes,
target,
node.split_depth,
state,
reads,
steps,
limit,
|| {
ignored_shrinks += 1;
Ok(())
},
);
if ignored_shrinks != 0 {
observations.push(PageObservation::IgnoredSplitShrink(ignored_shrinks));
}
let split = split?;
let penalty = match node.nodes.get(split.index) {
None => -10000,
Some(NativeVerticalNode::Penalty(p)) => *p,
_ => 0,
};
if state.parameter(Parameter::Tracingpages).width() > 0 {
trace.push(PageTrace::InsertionSplit {
observations.push(PageObservation::Trace(PageTrace::InsertionSplit {
class: node.class,
target,
natural_size: split.natural_size,
penalty,
});
}));
}
entry.size += split.natural_size;
dims[0] -= scale(split.natural_size, factor);