use could_progress_at_top for footers

This commit is contained in:
PgBiel 2025-05-16 01:45:29 -03:00
parent 3ec699541a
commit 915743e6e8

View File

@ -1535,11 +1535,6 @@ 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;
} }
} }
} }
@ -1564,13 +1559,14 @@ impl<'a> GridLayouter<'a> {
// the grid resolving stage if it is short-lived, that is, if // the grid resolving stage if it is short-lived, that is, if
// it is at the start of the table (or right after headers at // it is at the start of the table (or right after headers at
// the start of the table). // the start of the table).
//
// TODO(subfooters): explicitly check for short-lived footers. // TODO(subfooters): explicitly check for short-lived footers.
// TODO(subfooters): widow prevention for non-repeated footers with a // TODO(subfooters): widow prevention for non-repeated footers with a
// similar mechanism / when implementing multiple footers. // similar mechanism / when implementing multiple footers.
let footer_would_be_widow = let footer_would_be_widow =
matches!(self.grid.footer, Some(Repeatable::Repeated(_))) matches!(self.grid.footer, Some(Repeatable::Repeated(_)))
&& self.current.lrows.is_empty() && self.current.lrows.is_empty()
&& self.may_progress_with_repeats(); && self.current.could_progress_at_top;
let mut laid_out_footer_start = None; let mut laid_out_footer_start = None;
if !footer_would_be_widow { if !footer_would_be_widow {
@ -1775,6 +1771,8 @@ impl<'a> GridLayouter<'a> {
// be gradually updated when preparing footers and repeating headers. // be gradually updated when preparing footers and repeating headers.
self.current.initial_after_repeats = self.current.initial.y; self.current.initial_after_repeats = self.current.initial.y;
self.current.could_progress_at_top = self.regions.may_progress();
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);
} }