use cached value in auto row measurement, less todos

This commit is contained in:
PgBiel 2025-05-16 03:57:04 -03:00
parent 2c5045d210
commit 3fa425dc83
2 changed files with 3 additions and 18 deletions

View File

@ -240,6 +240,8 @@ impl<'a> GridLayouter<'a> {
// TODO(layout model): re-calculate heights of headers and footers // TODO(layout model): re-calculate heights of headers and footers
// on each region if 'full' changes? (Assuming height doesn't // on each region if 'full' changes? (Assuming height doesn't
// change for now...) // change for now...)
//
// Would remove the footer height update below (move it here).
skipped_region = true; skipped_region = true;
self.regions.size.y -= self.current.footer_height; self.regions.size.y -= self.current.footer_height;
@ -250,7 +252,6 @@ impl<'a> GridLayouter<'a> {
if skipped_region { if skipped_region {
// Simulate the footer again; the region's 'full' might have // Simulate the footer again; the region's 'full' might have
// changed. // changed.
// TODO: maybe this should go in the loop, a bit hacky as is...
self.regions.size.y += self.current.footer_height; self.regions.size.y += self.current.footer_height;
self.current.footer_height = self self.current.footer_height = self
.simulate_footer(footer, &self.regions, engine, disambiguator)? .simulate_footer(footer, &self.regions, engine, disambiguator)?

View File

@ -527,23 +527,7 @@ impl GridLayouter<'_> {
// we have to use initial header heights (note that // we have to use initial header heights (note that
// header height can change in the middle of the // header height can change in the middle of the
// region). // region).
// TODO: maybe cache this self.current.initial_after_repeats
// NOTE: it is safe to access 'lrows' here since
// 'breakable' can only be true outside of headers
// and unbreakable rows in general, so there is no risk
// of accessing an incomplete list of rows.
let initial_header_height = self.current.lrows
[..self.current.repeated_header_rows]
.iter()
.map(|row| match row {
Row::Frame(frame, _, _) => frame.height(),
Row::Fr(_, _, _) => Abs::zero(),
})
.sum();
self.current.initial.y
- initial_header_height
- self.current.footer_height
} else { } else {
// When measuring unbreakable auto rows, infinite // When measuring unbreakable auto rows, infinite
// height is available for content to expand. // height is available for content to expand.