delete now unused header_height field

This commit is contained in:
PgBiel 2025-05-16 02:42:34 -03:00
parent 78c87c811d
commit be12824af2
2 changed files with 10 additions and 26 deletions

View File

@ -122,8 +122,13 @@ pub(super) struct Current {
/// until they fit and are not orphans in at least one region (or exactly /// until they fit and are not orphans in at least one region (or exactly
/// one, for non-repeated headers). /// one, for non-repeated headers).
pub(super) lrows_orphan_snapshot: Option<usize>, pub(super) lrows_orphan_snapshot: Option<usize>,
/// The total simulated height for all headers currently in /// The height of effectively repeating headers, that is, ignoring
/// `repeating_headers` and `pending_headers`. /// non-repeating pending headers, in the current region.
///
/// This is used by multi-page auto rows so they can inform cell layout on
/// how much space should be taken by headers if they break across regions.
/// In particular, non-repeating headers only occupy the initial region,
/// but disappear on new regions, so they can be ignored.
/// ///
/// This field is reset on each new region and properly updated by /// This field is reset on each new region and properly updated by
/// `layout_auto_row` and `layout_relative_row`, and should not be read /// `layout_auto_row` and `layout_relative_row`, and should not be read
@ -135,14 +140,6 @@ pub(super) struct Current {
/// updated whenever a new header is found, subtracting the height of /// updated whenever a new header is found, subtracting the height of
/// headers which stopped repeating and adding the height of all new /// headers which stopped repeating and adding the height of all new
/// headers. /// headers.
pub(super) header_height: Abs,
/// The height of effectively repeating headers, that is, ignoring
/// non-repeating pending headers.
///
/// This is used by multi-page auto rows so they can inform cell layout on
/// how much space should be taken by headers if they break across regions.
/// In particular, non-repeating headers only occupy the initial region,
/// but disappear on new regions, so they can be ignored.
pub(super) repeating_header_height: Abs, pub(super) repeating_header_height: Abs,
/// The height for each repeating header that was placed in this region. /// The height for each repeating header that was placed in this region.
/// Note that this includes headers not at the top of the region, before /// Note that this includes headers not at the top of the region, before
@ -261,7 +258,6 @@ impl<'a> GridLayouter<'a> {
repeated_header_rows: 0, repeated_header_rows: 0,
last_repeated_header_end: 0, last_repeated_header_end: 0,
lrows_orphan_snapshot: None, lrows_orphan_snapshot: None,
header_height: Abs::zero(),
repeating_header_height: Abs::zero(), repeating_header_height: Abs::zero(),
repeating_header_heights: vec![], repeating_header_heights: vec![],
footer_height: Abs::zero(), footer_height: Abs::zero(),
@ -1731,7 +1727,6 @@ impl<'a> GridLayouter<'a> {
if !last { if !last {
self.current.repeated_header_rows = 0; self.current.repeated_header_rows = 0;
self.current.last_repeated_header_end = 0; self.current.last_repeated_header_end = 0;
self.current.header_height = Abs::zero();
self.current.repeating_header_height = Abs::zero(); self.current.repeating_header_height = Abs::zero();
self.current.repeating_header_heights.clear(); self.current.repeating_header_heights.clear();

View File

@ -138,11 +138,6 @@ impl<'a> GridLayouter<'a> {
self.current.repeating_header_height -= removed_height; self.current.repeating_header_height -= removed_height;
} }
// Non-repeating headers stop at the pending stage for orphan
// prevention only. Flushing pending headers, so those will no longer
// appear in a future region.
self.current.header_height = self.current.repeating_header_height;
// Let's try to place them at least once. // Let's try to place them at least once.
// This might be a waste as we could generate an orphan and thus have // This might be a waste as we could generate an orphan and thus have
// to try to place old and new headers all over again, but that happens // to try to place old and new headers all over again, but that happens
@ -280,7 +275,6 @@ impl<'a> GridLayouter<'a> {
// Reset the header height for this region. // Reset the header height for this region.
// It will be re-calculated when laying out each header row. // It will be re-calculated when laying out each header row.
self.current.header_height = Abs::zero();
self.current.repeating_header_height = Abs::zero(); self.current.repeating_header_height = Abs::zero();
self.current.repeating_header_heights.clear(); self.current.repeating_header_heights.clear();
@ -306,7 +300,6 @@ impl<'a> GridLayouter<'a> {
while let Some(&header) = self.repeating_headers.get(i) { while let Some(&header) = self.repeating_headers.get(i) {
let header_height = let header_height =
self.layout_header_rows(header, engine, disambiguator, false)?; self.layout_header_rows(header, engine, disambiguator, false)?;
self.current.header_height += header_height;
self.current.repeating_header_height += header_height; self.current.repeating_header_height += header_height;
// We assume that this vector will be sorted according // We assume that this vector will be sorted according
@ -338,7 +331,6 @@ impl<'a> GridLayouter<'a> {
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)?;
self.current.header_height += header_height;
if matches!(header, Repeatable::Repeated(_)) { if matches!(header, Repeatable::Repeated(_)) {
self.current.repeating_header_height += header_height; self.current.repeating_header_height += header_height;
self.current.repeating_header_heights.push(header_height); self.current.repeating_header_heights.push(header_height);
@ -418,14 +410,11 @@ impl<'a> GridLayouter<'a> {
// it is guaranteed this header won't appear in a future // it is guaranteed this header won't appear in a future
// region, so multi-page rows and cells can effectively ignore // region, so multi-page rows and cells can effectively ignore
// this header. // this header.
if !short_lived { if !short_lived && matches!(header, Repeatable::Repeated(_)) {
self.current.header_height += header_height;
if matches!(header, Repeatable::Repeated(_)) {
self.current.repeating_header_height += header_height; self.current.repeating_header_height += header_height;
self.current.repeating_header_heights.push(header_height); self.current.repeating_header_heights.push(header_height);
} }
} }
}
Ok(should_snapshot) Ok(should_snapshot)
} }