From be12824af2abfb1af86fcc3310048b5b7ab5c3b6 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Fri, 16 May 2025 02:42:34 -0300 Subject: [PATCH] delete now unused `header_height` field --- crates/typst-layout/src/grid/layouter.rs | 19 +++++++------------ crates/typst-layout/src/grid/repeated.rs | 17 +++-------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/crates/typst-layout/src/grid/layouter.rs b/crates/typst-layout/src/grid/layouter.rs index f1df1e341..316c4aecb 100644 --- a/crates/typst-layout/src/grid/layouter.rs +++ b/crates/typst-layout/src/grid/layouter.rs @@ -122,8 +122,13 @@ pub(super) struct Current { /// until they fit and are not orphans in at least one region (or exactly /// one, for non-repeated headers). pub(super) lrows_orphan_snapshot: Option, - /// The total simulated height for all headers currently in - /// `repeating_headers` and `pending_headers`. + /// The height of effectively repeating headers, that is, ignoring + /// 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 /// `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 /// headers which stopped repeating and adding the height of all new /// 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, /// 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 @@ -261,7 +258,6 @@ impl<'a> GridLayouter<'a> { repeated_header_rows: 0, last_repeated_header_end: 0, lrows_orphan_snapshot: None, - header_height: Abs::zero(), repeating_header_height: Abs::zero(), repeating_header_heights: vec![], footer_height: Abs::zero(), @@ -1731,7 +1727,6 @@ impl<'a> GridLayouter<'a> { if !last { self.current.repeated_header_rows = 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_heights.clear(); diff --git a/crates/typst-layout/src/grid/repeated.rs b/crates/typst-layout/src/grid/repeated.rs index 111bbfa41..907665ea4 100644 --- a/crates/typst-layout/src/grid/repeated.rs +++ b/crates/typst-layout/src/grid/repeated.rs @@ -138,11 +138,6 @@ impl<'a> GridLayouter<'a> { 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. // 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 @@ -280,7 +275,6 @@ impl<'a> GridLayouter<'a> { // Reset the header height for this region. // 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_heights.clear(); @@ -306,7 +300,6 @@ impl<'a> GridLayouter<'a> { while let Some(&header) = self.repeating_headers.get(i) { let header_height = self.layout_header_rows(header, engine, disambiguator, false)?; - self.current.header_height += header_height; self.current.repeating_header_height += header_height; // We assume that this vector will be sorted according @@ -338,7 +331,6 @@ impl<'a> GridLayouter<'a> { for header in self.pending_headers { let header_height = self.layout_header_rows(header.unwrap(), engine, disambiguator, false)?; - self.current.header_height += header_height; if matches!(header, Repeatable::Repeated(_)) { self.current.repeating_header_height += header_height; self.current.repeating_header_heights.push(header_height); @@ -418,12 +410,9 @@ impl<'a> GridLayouter<'a> { // it is guaranteed this header won't appear in a future // region, so multi-page rows and cells can effectively ignore // this header. - if !short_lived { - self.current.header_height += header_height; - if matches!(header, Repeatable::Repeated(_)) { - self.current.repeating_header_height += header_height; - self.current.repeating_header_heights.push(header_height); - } + if !short_lived && matches!(header, Repeatable::Repeated(_)) { + self.current.repeating_header_height += header_height; + self.current.repeating_header_heights.push(header_height); } }