Use the positioned renderer as the single pagination authority
This commit is contained in:
1 parent
be6f8859c2
commit
dd3a20890d
1 file changed
+28
-27
@@ -40,33 +40,40 @@ pub(super) fn layout_document(
|
||||
math_metrics: &math_font::MathFontMetrics,
|
||||
math_layout: &MathLayoutEnvironment,
|
||||
paragraph_cache: &mut ParagraphLayoutCache,
|
||||
page_layout_cache: &PageLayoutCache,
|
||||
_page_layout_cache: &PageLayoutCache,
|
||||
) -> DocumentLayout {
|
||||
let Some(plan) = build_page_break_plan(
|
||||
model,
|
||||
source_dir,
|
||||
content_width_mm,
|
||||
content_height_mm,
|
||||
metrics,
|
||||
font_cache,
|
||||
cjk_family,
|
||||
mono_family,
|
||||
sans_family,
|
||||
math_metrics,
|
||||
math_layout,
|
||||
paragraph_cache,
|
||||
page_layout_cache,
|
||||
) else {
|
||||
let config = PageLayoutConfig {
|
||||
content_width_bits: content_width_mm.to_bits(),
|
||||
content_height_bits: content_height_mm.to_bits(),
|
||||
top_skip: i64::from(scaled_points(ARTICLE_11PT_TOPSKIP_PT).0),
|
||||
max_depth: i64::from(scaled_points(ARTICLE_11PT_MAX_DEPTH_PT).0),
|
||||
text_font_fingerprint: metrics.fingerprint,
|
||||
math_font_fingerprint: math_metrics.fingerprint,
|
||||
math_layout_font_fingerprint: math_layout.font_fingerprint,
|
||||
base_font_size: model.base_font_size,
|
||||
page_style_fingerprint: {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
model.page_style.hash(&mut hasher);
|
||||
model.page_style_overrides.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
},
|
||||
};
|
||||
let Some(blocks) = page_block_keys(model, source_dir) else {
|
||||
return DocumentLayout {
|
||||
plan: None,
|
||||
pages: 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(
|
||||
model,
|
||||
source_dir,
|
||||
&plan.breaks,
|
||||
&explicit_breaks,
|
||||
content_width_mm,
|
||||
content_height_mm,
|
||||
metrics,
|
||||
@@ -79,7 +86,7 @@ pub(super) fn layout_document(
|
||||
paragraph_cache,
|
||||
) else {
|
||||
return DocumentLayout {
|
||||
plan: Some(plan),
|
||||
plan: None,
|
||||
pages: None,
|
||||
snapshot: None,
|
||||
};
|
||||
@@ -88,7 +95,7 @@ pub(super) fn layout_document(
|
||||
Some(resolved) => build_positioned_pages(
|
||||
&resolved,
|
||||
source_dir,
|
||||
&plan.breaks,
|
||||
&explicit_breaks,
|
||||
content_width_mm,
|
||||
content_height_mm,
|
||||
metrics,
|
||||
@@ -104,16 +111,10 @@ pub(super) fn layout_document(
|
||||
None => first_pages,
|
||||
};
|
||||
let snapshot = (!model.show_title).then(|| {
|
||||
PageLayoutCache::snapshot(
|
||||
plan.config.clone(),
|
||||
plan.blocks.clone(),
|
||||
plan.dependencies.clone(),
|
||||
&pages,
|
||||
model.blocks.len(),
|
||||
)
|
||||
PageLayoutCache::snapshot(config, blocks, HashMap::new(), &pages, model.blocks.len())
|
||||
});
|
||||
DocumentLayout {
|
||||
plan: Some(plan),
|
||||
plan: None,
|
||||
pages: Some(pages),
|
||||
snapshot,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user