Use the positioned renderer as the single pagination authority

This commit is contained in:
gloamxun committed 2026-10-19 14:06:08 +08:00
1 parent be6f8859c2
commit dd3a20890d
1 file changed
+28 -27
+28 -27
View File
@@ -40,33 +40,40 @@ pub(super) fn layout_document(
math_metrics: &math_font::MathFontMetrics, math_metrics: &math_font::MathFontMetrics,
math_layout: &MathLayoutEnvironment, math_layout: &MathLayoutEnvironment,
paragraph_cache: &mut ParagraphLayoutCache, paragraph_cache: &mut ParagraphLayoutCache,
page_layout_cache: &PageLayoutCache, _page_layout_cache: &PageLayoutCache,
) -> DocumentLayout { ) -> DocumentLayout {
let Some(plan) = build_page_break_plan( let config = PageLayoutConfig {
model, content_width_bits: content_width_mm.to_bits(),
source_dir, content_height_bits: content_height_mm.to_bits(),
content_width_mm, top_skip: i64::from(scaled_points(ARTICLE_11PT_TOPSKIP_PT).0),
content_height_mm, max_depth: i64::from(scaled_points(ARTICLE_11PT_MAX_DEPTH_PT).0),
metrics, text_font_fingerprint: metrics.fingerprint,
font_cache, math_font_fingerprint: math_metrics.fingerprint,
cjk_family, math_layout_font_fingerprint: math_layout.font_fingerprint,
mono_family, base_font_size: model.base_font_size,
sans_family, page_style_fingerprint: {
math_metrics, let mut hasher = DefaultHasher::new();
math_layout, model.page_style.hash(&mut hasher);
paragraph_cache, model.page_style_overrides.hash(&mut hasher);
page_layout_cache, hasher.finish()
) else { },
};
let Some(blocks) = page_block_keys(model, source_dir) else {
return DocumentLayout { return DocumentLayout {
plan: None, plan: None,
pages: None, pages: None,
snapshot: None, snapshot: None,
}; };
}; };
// The positioned renderer is the single pagination authority: explicit
// `\newpage`/float placement breaks are applied directly from the block
// stream, and natural breaks come from the same vertical placement pass
// that paints the page. No separate planner break set is needed.
let explicit_breaks = HashSet::new();
let Some(first_pages) = build_positioned_pages( let Some(first_pages) = build_positioned_pages(
model, model,
source_dir, source_dir,
&plan.breaks, &explicit_breaks,
content_width_mm, content_width_mm,
content_height_mm, content_height_mm,
metrics, metrics,
@@ -79,7 +86,7 @@ pub(super) fn layout_document(
paragraph_cache, paragraph_cache,
) else { ) else {
return DocumentLayout { return DocumentLayout {
plan: Some(plan), plan: None,
pages: None, pages: None,
snapshot: None, snapshot: None,
}; };
@@ -88,7 +95,7 @@ pub(super) fn layout_document(
Some(resolved) => build_positioned_pages( Some(resolved) => build_positioned_pages(
&resolved, &resolved,
source_dir, source_dir,
&plan.breaks, &explicit_breaks,
content_width_mm, content_width_mm,
content_height_mm, content_height_mm,
metrics, metrics,
@@ -104,16 +111,10 @@ pub(super) fn layout_document(
None => first_pages, None => first_pages,
}; };
let snapshot = (!model.show_title).then(|| { let snapshot = (!model.show_title).then(|| {
PageLayoutCache::snapshot( PageLayoutCache::snapshot(config, blocks, HashMap::new(), &pages, model.blocks.len())
plan.config.clone(),
plan.blocks.clone(),
plan.dependencies.clone(),
&pages,
model.blocks.len(),
)
}); });
DocumentLayout { DocumentLayout {
plan: Some(plan), plan: None,
pages: Some(pages), pages: Some(pages),
snapshot, snapshot,
} }