mirror of
https://github.com/typst/typst
synced 2025-05-18 02:55:28 +08:00
store initial after repeats
This commit is contained in:
parent
6d4e71085d
commit
2127a9e044
@ -75,6 +75,12 @@ pub struct GridLayouter<'a> {
|
|||||||
pub(super) struct Current {
|
pub(super) struct Current {
|
||||||
/// The initial size of the current region before we started subtracting.
|
/// The initial size of the current region before we started subtracting.
|
||||||
pub(super) initial: Size,
|
pub(super) initial: Size,
|
||||||
|
/// The height of the region after repeated headers were placed and footers
|
||||||
|
/// prepared.
|
||||||
|
///
|
||||||
|
/// This is used to quickly tell if any additional space in the region has
|
||||||
|
/// been occupied since then.
|
||||||
|
pub(super) initial_after_repeats: Abs,
|
||||||
/// Rows in the current region.
|
/// Rows in the current region.
|
||||||
pub(super) lrows: Vec<Row>,
|
pub(super) lrows: Vec<Row>,
|
||||||
/// The amount of repeated header rows at the start of the current region.
|
/// The amount of repeated header rows at the start of the current region.
|
||||||
@ -246,6 +252,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
row_state: RowState::default(),
|
row_state: RowState::default(),
|
||||||
current: Current {
|
current: Current {
|
||||||
initial: regions.size,
|
initial: regions.size,
|
||||||
|
initial_after_repeats: regions.size.y,
|
||||||
lrows: vec![],
|
lrows: vec![],
|
||||||
repeated_header_rows: 0,
|
repeated_header_rows: 0,
|
||||||
last_repeated_header_end: 0,
|
last_repeated_header_end: 0,
|
||||||
@ -268,6 +275,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// presence of the footer.
|
// presence of the footer.
|
||||||
self.prepare_footer(footer, engine, 0)?;
|
self.prepare_footer(footer, engine, 0)?;
|
||||||
self.regions.size.y -= self.current.footer_height;
|
self.regions.size.y -= self.current.footer_height;
|
||||||
|
self.current.initial_after_repeats = self.regions.size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
@ -1526,6 +1534,11 @@ impl<'a> GridLayouter<'a> {
|
|||||||
if orphan_snapshot == 0 {
|
if orphan_snapshot == 0 {
|
||||||
// Removed all repeated headers.
|
// Removed all repeated headers.
|
||||||
self.current.last_repeated_header_end = 0;
|
self.current.last_repeated_header_end = 0;
|
||||||
|
|
||||||
|
// Although the footer is still subtracted, it should also
|
||||||
|
// be removed by widow prevention, so we'll get ahead of
|
||||||
|
// ourselves here.
|
||||||
|
self.current.initial_after_repeats = self.current.initial.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1737,6 +1750,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// to skip regions to fit headers, so there is no risk of
|
// to skip regions to fit headers, so there is no risk of
|
||||||
// subtracting this twice.
|
// subtracting this twice.
|
||||||
self.regions.size.y -= self.current.footer_height;
|
self.regions.size.y -= self.current.footer_height;
|
||||||
|
self.current.initial_after_repeats = self.regions.size.y;
|
||||||
|
|
||||||
if !self.repeating_headers.is_empty() || !self.pending_headers.is_empty() {
|
if !self.repeating_headers.is_empty() || !self.pending_headers.is_empty() {
|
||||||
// Add headers to the new region.
|
// Add headers to the new region.
|
||||||
@ -1759,6 +1773,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
self.rrows.push(resolved_rows);
|
self.rrows.push(resolved_rows);
|
||||||
self.regions.next();
|
self.regions.next();
|
||||||
self.current.initial = self.regions.size;
|
self.current.initial = self.regions.size;
|
||||||
|
self.current.initial_after_repeats = self.current.initial.y;
|
||||||
|
|
||||||
if !self.grid.headers.is_empty() {
|
if !self.grid.headers.is_empty() {
|
||||||
self.finished_header_rows.push(header_row_info);
|
self.finished_header_rows.push(header_row_info);
|
||||||
|
@ -237,6 +237,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
skipped_region = true;
|
skipped_region = true;
|
||||||
|
|
||||||
self.regions.size.y -= self.current.footer_height;
|
self.regions.size.y -= self.current.footer_height;
|
||||||
|
self.current.initial_after_repeats = self.regions.size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(Repeatable::Repeated(footer)) = &self.grid.footer {
|
if let Some(Repeatable::Repeated(footer)) = &self.grid.footer {
|
||||||
@ -322,6 +323,8 @@ impl<'a> GridLayouter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.current.repeated_header_rows = self.current.lrows.len();
|
self.current.repeated_header_rows = self.current.lrows.len();
|
||||||
|
self.current.initial_after_repeats = self.regions.size.y;
|
||||||
|
|
||||||
for header in self.pending_headers {
|
for header in self.pending_headers {
|
||||||
let header_height =
|
let header_height =
|
||||||
self.layout_header_rows(header.unwrap(), engine, disambiguator, false)?;
|
self.layout_header_rows(header.unwrap(), engine, disambiguator, false)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user